diff options
Diffstat (limited to 'qxt-mini/qxtglobalshortcut_mac.cpp')
| -rw-r--r-- | qxt-mini/qxtglobalshortcut_mac.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/qxt-mini/qxtglobalshortcut_mac.cpp b/qxt-mini/qxtglobalshortcut_mac.cpp index c6b20fa2..c91d763d 100644 --- a/qxt-mini/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/qxtglobalshortcut_mac.cpp @@ -49,13 +49,14 @@ 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); + if(id != Identifier()) { + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, GetEventKind(event) == kEventHotKeyPressed); + } } return noErr; } @@ -76,11 +77,11 @@ quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifier return native; } -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key keys) { UTF16Char ch; // Constants found in NSEvent.h from AppKit.framework - switch (key) + switch (keys) { case Qt::Key_Return: return kVK_Return; @@ -170,11 +171,11 @@ quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) ; } - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; + if (keys == Qt::Key_Escape) ch = 27; + else if (keys == Qt::Key_Return) ch = 13; + else if (keys == Qt::Key_Enter) ch = 3; + else if (keys == Qt::Key_Tab) ch = 9; + else ch = keys; CFDataRef currentLayoutData; TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); @@ -233,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; |
