You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lxqt-globalkeys-packaging/debian/patches/add-super-key-binding-suppo...

146 lines
6.6 KiB

Description: Triggering shortcuts with meta keys
The left and right meta keys can trigger shortcuts
at the KeyRelease event.
Author: ska67 <git17@ska67.de>
Origin: backport
Bug: https://github.com/lxde/lxqt/issues/1259
Applied-Upstream: commit
Last-Update: 2018-02-05
--- a/daemon/core.cpp
+++ b/daemon/core.cpp
@@ -1140,6 +1140,8 @@ void Core::run()
allModifiers.insert(ignoreLocks);
}
+ const QString metaLeft = XKeysymToString(XK_Super_L);
+ const QString metaRight = XKeysymToString(XK_Super_R);
char signal = 0;
if (write(mX11ResponsePipe[STDOUT_FILENO], &signal, sizeof(signal)) == sizeof(signal))
@@ -1316,65 +1318,84 @@ void Core::run()
}
else
{
+ if (event.type == KeyRelease)
+ {
+ event.xkey.state &= ~allShifts; // Modifier keys must not use shift states.
+ }
+
X11Shortcut shortcutKey = qMakePair(static_cast<KeyCode>(event.xkey.keycode), event.xkey.state & allShifts);
ShortcutByX11::const_iterator shortcutIt = mShortcutByX11.constFind(shortcutKey);
- if(shortcutIt != mShortcutByX11.constEnd())
+ if (shortcutIt == mShortcutByX11.constEnd())
{
- const QString& shortcut = shortcutIt.value();
- log(LOG_DEBUG, "KeyPress %08x %08x %s", event.xkey.state & allShifts, event.xkey.keycode, qPrintable(shortcut));
+ continue;
+ }
+ const QString& shortcut = shortcutIt.value();
- IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
- if (idsByShortcut != mIdsByShortcut.end())
+ if (event.type == KeyPress)
+ {
+ if ((shortcut == metaLeft) || (shortcut == metaRight))
{
- Ids &ids = idsByShortcut.value();
- switch (mMultipleActionsBehaviour)
- {
- case MULTIPLE_ACTIONS_BEHAVIOUR_FIRST:
- {
- Ids::iterator lastIds = ids.end();
- for (Ids::iterator idi = ids.begin(); idi != lastIds; ++idi)
- if (mShortcutAndActionById[*idi].second->call())
- {
- break;
- }
- }
- break;
+ keyReleaseExpected = true;
+ continue;
+ }
+ log(LOG_DEBUG, "KeyPress %08x %08x %s", event.xkey.state & allShifts, event.xkey.keycode, qPrintable(shortcut));
+ }
+ else
+ {
+ log(LOG_DEBUG, "KeyRelease %08x %08x %s", event.xkey.state & allShifts, event.xkey.keycode, qPrintable(shortcut));
+ }
- case MULTIPLE_ACTIONS_BEHAVIOUR_LAST:
- {
- Ids::iterator firstIds = ids.begin();
- for (Ids::iterator idi = ids.end(); idi != firstIds;)
+ IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
+ if (idsByShortcut != mIdsByShortcut.end())
+ {
+ Ids &ids = idsByShortcut.value();
+ switch (mMultipleActionsBehaviour)
+ {
+ case MULTIPLE_ACTIONS_BEHAVIOUR_FIRST:
+ {
+ Ids::iterator lastIds = ids.end();
+ for (Ids::iterator idi = ids.begin(); idi != lastIds; ++idi)
+ if (mShortcutAndActionById[*idi].second->call())
{
- --idi;
- if (mShortcutAndActionById[*idi].second->call())
- {
- break;
- }
+ break;
}
- }
- break;
+ }
+ break;
- case MULTIPLE_ACTIONS_BEHAVIOUR_NONE:
- if (ids.size() == 1)
+ case MULTIPLE_ACTIONS_BEHAVIOUR_LAST:
+ {
+ Ids::iterator firstIds = ids.begin();
+ for (Ids::iterator idi = ids.end(); idi != firstIds;)
+ {
+ --idi;
+ if (mShortcutAndActionById[*idi].second->call())
{
- mShortcutAndActionById[*(ids.begin())].second->call();
+ break;
}
- break;
+ }
+ }
+ break;
- case MULTIPLE_ACTIONS_BEHAVIOUR_ALL:
+ case MULTIPLE_ACTIONS_BEHAVIOUR_NONE:
+ if (ids.size() == 1)
{
- Ids::iterator lastIds = ids.end();
- for (Ids::iterator idi = ids.begin(); idi != lastIds; ++idi)
- {
- mShortcutAndActionById[*idi].second->call();
- }
+ mShortcutAndActionById[*(ids.begin())].second->call();
}
break;
- default:
- ;
+ case MULTIPLE_ACTIONS_BEHAVIOUR_ALL:
+ {
+ Ids::iterator lastIds = ids.end();
+ for (Ids::iterator idi = ids.begin(); idi != lastIds; ++idi)
+ {
+ mShortcutAndActionById[*idi].second->call();
}
}
+ break;
+
+ default:
+ ;
+ }
}
}