From c71b002b24bed549e4f8086901b9cda68e7c5951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 14 Sep 2016 13:19:43 +0200 Subject: [PATCH] [wayland] Fix release of TabBox on Wayland Summary: The interaction is changed to trigger the check for release from the TabBoxInputFilter instead of reacting on modifier changes. That way it's possible to check for the relevant modifiers getting released instead of getting all modifiers in. Also this means that the checks are only performed when relevant. BUG: 368590 Reviewers: #kwin, #plasma_on_wayland, bshah Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2773 --- autotests/integration/tabbox_test.cpp | 2 -- input.cpp | 5 ++++- tabbox/tabbox.cpp | 9 ++++----- tabbox/tabbox.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autotests/integration/tabbox_test.cpp b/autotests/integration/tabbox_test.cpp index 8e04c5e67e..5577d3bc1a 100644 --- a/autotests/integration/tabbox_test.cpp +++ b/autotests/integration/tabbox_test.cpp @@ -127,9 +127,7 @@ void TabBoxTest::testCapsLock() // release alt kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); - QEXPECT_FAIL("", "bug 368590", Continue); QCOMPARE(tabboxClosedSpy.count(), 1); - QEXPECT_FAIL("", "bug 368590", Continue); QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false); // release caps lock diff --git a/input.cpp b/input.cpp index 4b63c82034..f95eb4e6a2 100644 --- a/input.cpp +++ b/input.cpp @@ -745,8 +745,11 @@ public: return false; } waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); - if (event->type() == QEvent::KeyPress) + if (event->type() == QEvent::KeyPress) { TabBox::TabBox::self()->keyPress(event->modifiers() | event->key()); + } else if (input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) { + TabBox::TabBox::self()->modifiersReleased(); + } return true; } bool wheelEvent(QWheelEvent *event) override { diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 9686239947..43eb6736eb 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -36,6 +36,7 @@ along with this program. If not, see . #include "client.h" #include "effects.h" #include "input.h" +#include "keyboard_input.h" #include "focuschain.h" #include "screenedge.h" #include "screens.h" @@ -498,8 +499,6 @@ TabBox::TabBox(QObject *parent) m_tabBoxMode = TabBoxDesktopMode; // init variables connect(&m_delayedShowTimer, SIGNAL(timeout()), this, SLOT(show())); connect(Workspace::self(), SIGNAL(configChanged()), this, SLOT(reconfigure())); - - connect(input(), &InputRedirection::keyboardModifiersChanged, this, &TabBox::modifiersChanged); } TabBox::~TabBox() @@ -1076,7 +1075,7 @@ static bool areModKeysDepressedX11(const QKeySequence &seq) static bool areModKeysDepressedWayland(const QKeySequence &seq) { const int mod = seq[seq.count()-1] & Qt::KeyboardModifierMask; - const Qt::KeyboardModifiers mods = input()->keyboardModifiers(); + const Qt::KeyboardModifiers mods = input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(); if ((mod & Qt::SHIFT) && mods.testFlag(Qt::ShiftModifier)) { return true; } @@ -1570,9 +1569,9 @@ void TabBox::keyRelease(const xcb_key_release_event_t *ev) } } -void TabBox::modifiersChanged(Qt::KeyboardModifiers mods) +void TabBox::modifiersReleased() { - if (m_noModifierGrab || !(!mods)) { + if (m_noModifierGrab) { return; } if (m_tabGrab) { diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index ac11f2d169..fb9c093937 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -181,6 +181,7 @@ public: int previousDesktopStatic(int iDesktop) const; void keyPress(int key); void keyRelease(const xcb_key_release_event_t *ev); + void modifiersReleased(); bool forcedGlobalMouseGrab() const { return m_forcedGlobalMouseGrab; @@ -243,7 +244,6 @@ private: private Q_SLOTS: void reconfigure(); void globalShortcutChanged(QAction *action, const QKeySequence &seq); - void modifiersChanged(Qt::KeyboardModifiers mods); private: TabBoxMode m_tabBoxMode;