summaryrefslogtreecommitdiffhomepage
path: root/qxt-mini
diff options
context:
space:
mode:
authorMatteo Ceruti <matteo.ceruti@gmail.com>2023-08-24 00:12:03 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-25 12:47:03 +0200
commit39bcce3786ac9f08f0ff80b7c51bd4b2e7a96106 (patch)
tree262d6ad97aca2f85154402c7385513b28b6e283e /qxt-mini
parent1ea5bb0aa7f2f271724ded372957b6f3759fa5a8 (diff)
Fix shortcuts on macOS: Must distinguish Key Pressed and Release. Otherise Shortcuts do not work
Diffstat (limited to 'qxt-mini')
-rw-r--r--qxt-mini/qxtglobalshortcut.cpp2
-rw-r--r--qxt-mini/qxtglobalshortcut_mac.cpp15
2 files changed, 9 insertions, 8 deletions
diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp
index 52758f71..dec11dc4 100644
--- a/qxt-mini/qxtglobalshortcut.cpp
+++ b/qxt-mini/qxtglobalshortcut.cpp
@@ -180,7 +180,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ
shortcut->qxt_d().keystate = false;
if (shortcut->isEnabled())
- emit shortcut->activated(true);
+ emit shortcut->activated(is_down);
}
#endif
}
diff --git a/qxt-mini/qxtglobalshortcut_mac.cpp b/qxt-mini/qxtglobalshortcut_mac.cpp
index 59d0a40c..c91d763d 100644
--- a/qxt-mini/qxtglobalshortcut_mac.cpp
+++ b/qxt-mini/qxtglobalshortcut_mac.cpp
@@ -49,14 +49,13 @@ OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event,
{
Q_UNUSED(nextHandler);
Q_UNUSED(data);
- if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
+ if (GetEventClass(event) == kEventClassKeyboard && (GetEventKind(event) == kEventHotKeyPressed || GetEventKind(event) == kEventHotKeyReleased))
{
EventHotKeyID keyID;
GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID);
Identifier id = keyIDs.key(keyID.id);
if(id != Identifier()) {
- QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, true);
- QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, false);
+ QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, GetEventKind(event) == kEventHotKeyPressed);
}
}
return noErr;
@@ -235,10 +234,12 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ
if (!qxt_mac_handler_installed)
{
qxt_mac_handler_installed = true;
- EventTypeSpec t;
- t.eventClass = kEventClassKeyboard;
- t.eventKind = kEventHotKeyPressed;
- InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL);
+ EventTypeSpec t[2];
+ t[0].eventClass = kEventClassKeyboard;
+ t[0].eventKind = kEventHotKeyPressed;
+ t[1].eventClass = kEventClassKeyboard;
+ t[1].eventKind = kEventHotKeyReleased;
+ InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 2, t, NULL, NULL);
}
EventHotKeyID keyID;