Workaround xkbcommon behavior concerning consumed modifiers

Summary:
If a key could be turned into a keysym with a modifier xkbcommon
considers the modifier as consumed even if not pressed.
E.g. Alt+F3 considers alt as consumed as there is a keysym gnerated with
Ctrl+Alt+F3 (vt switching).

This change tries to workaround the problem by ignoring the consumed
modifiers if there are more modifiers consumed than active. It's
possible that this will create regressions for other shortcuts - we need
to test it in the wild. Although this might cause regressions I'm aiming
for Plasma/5.8 branch with the change. It only affects Wayland and fixes
quite important shortcuts from window manager perspective (desktop
switching (ctrl+f1 to ctrl+f4), desktop grid (ctrl+f8), present windows
(ctrl+f9, ctrl+10), cube (ctrl+f11), user actions (alt+f3), close window
(alt+f4)). If it causes regressions they need to be fixed as well in the
Plasma/5.8 branch.

A new API entry point for xkbcommon was proposed, but is not yet merged
and there is no release with it yet. Once that is available the
workaround should get removed and replaced by the new API call.

BUG: 368989
FIXED-IN: 5.8.1

Test Plan: Going to restart session now with the change

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2945
This commit is contained in:
Martin Gräßlin 2016-10-05 15:33:21 +02:00
parent 3bc6089394
commit 421824b654
2 changed files with 18 additions and 1 deletions

View file

@ -164,7 +164,6 @@ void GlobalShortcutsTest::testUserActionsMenu()
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
kwinApp()->platform()->keyboardKeyPressed(KEY_F3, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_F3, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_F3, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_F3, timestamp++);
QEXPECT_FAIL("", "BUG 368989", Continue);
QTRY_VERIFY(workspace()->userActionsMenu()->isShown()); QTRY_VERIFY(workspace()->userActionsMenu()->isShown());
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
} }

View file

@ -403,6 +403,24 @@ Qt::KeyboardModifiers Xkb::modifiersRelevantForGlobalShortcuts() const
if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) {
mods |= Qt::MetaModifier; mods |= Qt::MetaModifier;
} }
// workaround xkbcommon limitation concerning consumed modifiers
// if a key could be turned into a keysym with a modifier xkbcommon
// considers the modifier as consumed even if not pressed
// e.g. alt+F3 considers alt as consumed as there is a keysym generated
// with ctrl+alt+F3 (vt switching)
// For more information see:
// https://bugs.freedesktop.org/show_bug.cgi?id=92818
// https://github.com/xkbcommon/libxkbcommon/issues/17
// the workaround is to not consider the modifiers as consumed
// if they are not a currently
// this might have other side effects, though. The only proper way to
// handle this is through new API in xkbcommon which doesn't exist yet
if (m_consumedModifiers & ~m_modifiers) {
return mods;
}
return mods & ~m_consumedModifiers; return mods & ~m_consumedModifiers;
} }