[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
This commit is contained in:
Martin Gräßlin 2016-09-14 13:19:43 +02:00
parent b56a28e19c
commit c71b002b24
4 changed files with 9 additions and 9 deletions

View file

@ -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

View file

@ -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 {

View file

@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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) {

View file

@ -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;