From 4560f8d25302ea5ad619c938ba7f8ce7d902ed4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 14 Jun 2016 13:46:28 +0200 Subject: [PATCH] Handle ShellClient::windowShown in Workspace Summary: When a ShellClient gets unmapped and mapped again the signal windowShown gets emitted. We need to handle this in Workspace to ensure the window is in the proper layer and gets focus. This fixes applications like KRunner/Yakuake not having focus on a second show. Unfortunately it also brings back the problem that notifiations steal focus (this needs to be fixed by passing a proper window type to a notification). Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D1864 --- autotests/wayland/shell_client_test.cpp | 4 ++++ workspace.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/autotests/wayland/shell_client_test.cpp b/autotests/wayland/shell_client_test.cpp index 94e39c4362..525eb8a529 100644 --- a/autotests/wayland/shell_client_test.cpp +++ b/autotests/wayland/shell_client_test.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "shell_client.h" #include "screens.h" #include "wayland_server.h" +#include "workspace.h" #include #include @@ -170,6 +171,7 @@ void TestShellClient::testMapUnmapMap() auto client = clientAddedSpy.first().first().value(); QVERIFY(client); QVERIFY(client->isShown(true)); + QCOMPARE(workspace()->activeClient(), client); // now unmap QSignalSpy hiddenSpy(client, &ShellClient::windowHidden); @@ -180,6 +182,7 @@ void TestShellClient::testMapUnmapMap() surface->commit(Surface::CommitFlag::None); QVERIFY(hiddenSpy.wait()); QVERIFY(windowClosedSpy.isEmpty()); + QVERIFY(!workspace()->activeClient()); QSignalSpy windowShownSpy(client, &ShellClient::windowShown); QVERIFY(windowShownSpy.isValid()); @@ -190,6 +193,7 @@ void TestShellClient::testMapUnmapMap() QVERIFY(windowShownSpy.wait()); QCOMPARE(windowShownSpy.count(), 1); QCOMPARE(clientAddedSpy.count(), 1); + QCOMPARE(workspace()->activeClient(), client); // let's unmap again surface->attachBuffer(Buffer::Ptr()); diff --git a/workspace.cpp b/workspace.cpp index 85fc170579..16fcf29e4b 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -394,6 +394,17 @@ void Workspace::init() if (c->wantsInput()) { activateClient(c); } + connect(c, &ShellClient::windowShown, this, + [this, c] { + updateClientLayer(c); + x_stacking_dirty = true; + updateStackingOrder(true); + updateClientArea(); + if (c->wantsInput()) { + activateClient(c); + } + } + ); } ); connect(w, &WaylandServer::shellClientRemoved, this,