Compare commits
1 Commits
master
...
experiment
| Author | SHA1 | Date |
|---|---|---|
|
|
8c372a136a |
|
|
@ -28,3 +28,5 @@ include(cmake/library.cmake)
|
||||||
include(cmake/platform.cmake)
|
include(cmake/platform.cmake)
|
||||||
include(cmake/qt.cmake)
|
include(cmake/qt.cmake)
|
||||||
include(cmake/pkg-config.cmake)
|
include(cmake/pkg-config.cmake)
|
||||||
|
|
||||||
|
add_subdirectory(example)
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 2.8.8)
|
|
||||||
project(qxtglobalshortcut_test)
|
|
||||||
|
|
||||||
find_package(qxtglobalshortcut REQUIRED)
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
||||||
|
|
||||||
set(bin qxtglobalshortcut_test)
|
include_directories(${PROJECT_BINARY_DIR}/exports)
|
||||||
add_executable(${bin} src/main.cpp)
|
|
||||||
|
|
||||||
target_link_libraries(${bin} qxtglobalshortcut)
|
add_executable(qxtglobalshortcut_test src/main.cpp)
|
||||||
target_link_libraries(${bin} Qt6::Widgets)
|
|
||||||
|
target_link_libraries(qxtglobalshortcut_test qxtglobalshortcut Qt6::Widgets)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
using Identifier = QPair<uint, uint>;
|
using Identifier = QPair<uint, uint>;
|
||||||
static QMap<quint32, EventHotKeyRef> keyRefs;
|
static QMap<quint32, EventHotKeyRef> keyRefs;
|
||||||
|
|
@ -43,6 +44,9 @@ static bool qxt_mac_handler_installed = false;
|
||||||
|
|
||||||
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||||
{
|
{
|
||||||
|
QTextStream out(stdout);
|
||||||
|
out << QLatin1String("Shortcut maybe pressed!") << Qt::endl;
|
||||||
|
|
||||||
Q_UNUSED(nextHandler);
|
Q_UNUSED(nextHandler);
|
||||||
Q_UNUSED(data);
|
Q_UNUSED(data);
|
||||||
if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
|
if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
|
||||||
|
|
@ -359,7 +363,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ
|
||||||
EventTypeSpec t;
|
EventTypeSpec t;
|
||||||
t.eventClass = kEventClassKeyboard;
|
t.eventClass = kEventClassKeyboard;
|
||||||
t.eventKind = kEventHotKeyPressed;
|
t.eventKind = kEventHotKeyPressed;
|
||||||
InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, nullptr, nullptr);
|
// InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHotKeyID keyID;
|
EventHotKeyID keyID;
|
||||||
|
|
@ -367,7 +371,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ
|
||||||
keyID.id = ++hotKeySerial;
|
keyID.id = ++hotKeySerial;
|
||||||
|
|
||||||
EventHotKeyRef ref = 0;
|
EventHotKeyRef ref = 0;
|
||||||
bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
|
bool rv = true; // = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
|
||||||
if (rv)
|
if (rv)
|
||||||
{
|
{
|
||||||
keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);
|
keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue