Linux-specific: Handle Qt::Meta key in hotkeys (issue #404)

This commit is contained in:
Abs62 2013-09-24 17:55:58 +04:00
parent 5a6c88ea09
commit 1a8bb0ae10
2 changed files with 14 additions and 1 deletions

View file

@ -412,6 +412,9 @@ void HotkeyWrapper::init()
lAltCode = XKeysymToKeycode( display, XK_Alt_L );
rAltCode = XKeysymToKeycode( display, XK_Alt_R );
lMetaCode = XKeysymToKeycode( display, XK_Super_L );
rMetaCode = XKeysymToKeycode( display, XK_Super_R );
cCode = XKeysymToKeycode( display, XK_c );
insertCode = XKeysymToKeycode( display, XK_Insert );
kpInsertCode = XKeysymToKeycode( display, XK_KP_Insert );
@ -493,6 +496,10 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
key == rAltCode )
currentModifiers |= Mod1Mask;
else
if ( key == lMetaCode ||
key == rMetaCode )
currentModifiers |= Mod4Mask;
else
{
// Here we employ a kind of hack translating KP_Insert key
// to just Insert. This allows reacting to both Insert keys.
@ -518,6 +525,10 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
if ( key == lAltCode ||
key == rAltCode )
currentModifiers &= ~Mod1Mask;
else
if ( key == lMetaCode ||
key == rMetaCode )
currentModifiers &= ~Mod4Mask;
}
}
@ -540,6 +551,8 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2,
mod |= ControlMask;
if (modifier & Qt::AltModifier)
mod |= Mod1Mask;
if (modifier & Qt::MetaModifier)
mod |= Mod4Mask;
hotkeys.append( HotkeyStruct( vk, vk2, mod, handle, 0 ) );

View file

@ -111,7 +111,7 @@ private:
// We do one-time init of those, translating keysyms to keycodes
KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode,
cCode, insertCode, kpInsertCode;
cCode, insertCode, kpInsertCode, lMetaCode, rMetaCode;
quint32 currentModifiers;