From 9b32615ab4d59566172ace706acf6eb69c64bef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 12 Sep 2016 10:05:49 +0200 Subject: [PATCH] Don't bind ShellClient::acceptsFocus to whether the window is shown Summary: A not shown window may accept focus (e.g. when minimized). Given that the condition was wrong and broke when making minimized windows not shown. This change takes the idea of not passing focus to a closing or unmapped window directly into acceptsFocus. Which also means that this condition now works for xdg_shell windows. BUG: 368673 Reviewers: #kwin, #plasma_on_wayland, bshah Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2745 --- autotests/integration/shell_client_test.cpp | 2 -- shell_client.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp index f84eb6bc4c..016e793a1a 100644 --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -276,9 +276,7 @@ void TestShellClient::testMinimizeActiveWindow() workspace()->slotWindowMinimize(); QVERIFY(!c->isShown(true)); - QEXPECT_FAIL("wlShell", "BUG 368673", Continue); QVERIFY(c->wantsInput()); - QEXPECT_FAIL("wlShell", "BUG 368673", Continue); QVERIFY(c->wantsTabFocus()); QVERIFY(!c->isActive()); QVERIFY(!workspace()->activeClient()); diff --git a/shell_client.cpp b/shell_client.cpp index 25507c3b10..d11800862e 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -807,12 +807,19 @@ bool ShellClient::acceptsFocus() const return false; } } + if (m_closing) { + // a closing window does not accept focus + return false; + } + if (m_unmapped) { + // an unmapped window does not accept focus + return false; + } if (m_shellSurface) { if (m_shellSurface->isPopup()) { return false; } - // if the window is not visible it doesn't get input - return m_shellSurface->acceptsKeyboardFocus() && isShown(true); + return m_shellSurface->acceptsKeyboardFocus(); } if (m_xdgShellSurface) { // TODO: proper