Commit d3aa33b5 authored by Martin Flöser's avatar Martin Flöser
Browse files

Reevaluate window rules when the (xdg) shell surface's appId changes

Summary:
Especially when a window is first mapped it might be that the appId is
not yet set. So window rule matching doesn't happen. This change
evaluates the window rules again after the appId changes, so rules for
the appId match.

Test Plan: added test case

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11268
parent d61eaa2d
......@@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "workspace.h"
#include <KWayland/Client/surface.h>
#include <KWayland/Client/xdgshell.h>
using namespace KWin;
using namespace KWayland::Client;
......@@ -62,6 +63,7 @@ private Q_SLOTS:
void testApplyInitialDesktopfile();
void testOpacityActive_data();
void testOpacityActive();
void testMatchAfterNameChange();
};
void TestShellClientRules::initTestCase()
......@@ -416,5 +418,37 @@ void TestShellClientRules::testOpacityActive()
QCOMPARE(c2->opacity(), 0.8);
}
void TestShellClientRules::testMatchAfterNameChange()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("General").writeEntry("count", 1);
auto group = config->group("1");
group.writeEntry("above", true);
group.writeEntry("aboverule", 2);
group.writeEntry("wmclass", "org.kde.foo");
group.writeEntry("wmclasscomplete", false);
group.writeEntry("wmclassmatch", 1);
group.sync();
RuleBook::self()->setConfig(config);
workspace()->slotReconfigure();
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellV6Surface(surface.data()));
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QVERIFY(c->isActive());
QCOMPARE(c->keepAbove(), false);
QSignalSpy desktopFileNameSpy(c, &AbstractClient::desktopFileNameChanged);
QVERIFY(desktopFileNameSpy.isValid());
shellSurface->setAppId(QByteArrayLiteral("org.kde.foo"));
QVERIFY(desktopFileNameSpy.wait());
QCOMPARE(c->keepAbove(), true);
}
WAYLANDTEST_MAIN(TestShellClientRules)
#include "shell_client_rules_test.moc"
......@@ -138,6 +138,10 @@ void ShellClient::initSurface(T *shellSurface)
connect(shellSurface, &T::windowClassChanged, this,
[this, resourceName] (const QByteArray &windowClass) {
setResourceClass(resourceName, windowClass);
if (!m_internal) {
setupWindowRules(true);
applyWindowRules();
}
setDesktopFileName(windowClass);
}
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment