diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbkeyboard.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbkeyboard.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 751bd168f6..5fbc23c049 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1043,6 +1043,10 @@ void QXcbKeyboard::updateVModMapping() vmod_masks.meta = bit; else if (qstrcmp(vmod_name, "AltGr") == 0) vmod_masks.altgr = bit; + else if (qstrcmp(vmod_name, "Super") == 0) + vmod_masks.super = bit; + else if (qstrcmp(vmod_name, "Hyper") == 0) + vmod_masks.hyper = bit; } free(name_reply); @@ -1104,9 +1108,14 @@ void QXcbKeyboard::updateVModToRModMapping() rmod_masks.meta = modmap; else if (vmod_masks.altgr == bit) rmod_masks.altgr = modmap; + else if (vmod_masks.super == bit) + rmod_masks.super = modmap; + else if (vmod_masks.hyper == bit) + rmod_masks.hyper = modmap; } free(map_reply); + resolveMaskConflicts(); } #else void QXcbKeyboard::updateModifiers() @@ -1131,7 +1140,8 @@ void QXcbKeyboard::updateModifiers() // for Alt and Meta L and R are the same static const xcb_keysym_t symbols[] = { - XK_Alt_L, XK_Meta_L, XK_Mode_switch + XK_Alt_L, XK_Meta_L, XK_Mode_switch, XK_Super_L, XK_Super_R, + XK_Hyper_L, XK_Hyper_R }; static const size_t numSymbols = sizeof symbols / sizeof *symbols; @@ -1157,6 +1167,10 @@ void QXcbKeyboard::updateModifiers() rmod_masks.meta = mask; if (sym == XK_Mode_switch) rmod_masks.altgr = mask; + if ((sym == XK_Super_L) || (sym == XK_Super_R)) + rmod_masks.super = mask; + if ((sym == XK_Hyper_L) || (sym == XK_Hyper_R)) + rmod_masks.hyper = mask; } } } @@ -1165,9 +1179,28 @@ void QXcbKeyboard::updateModifiers() for (size_t i = 0; i < numSymbols; ++i) free(modKeyCodes[i]); free(modMapReply); + resolveMaskConflicts(); } #endif +void QXcbKeyboard::resolveMaskConflicts() +{ + // if we don't have a meta key (or it's hidden behind alt), use super or hyper to generate + // Qt::Key_Meta and Qt::MetaModifier, since most newer XFree86/Xorg installations map the Windows + // key to Super + if (rmod_masks.alt == rmod_masks.meta) + rmod_masks.meta = 0; + + if (rmod_masks.meta == 0) { + // no meta keys... s/meta/super, + rmod_masks.meta = rmod_masks.super; + if (rmod_masks.meta == 0) { + // no super keys either? guess we'll use hyper then + rmod_masks.meta = rmod_masks.hyper; + } + } +} + class KeyChecker { public: |