diff --git a/CMakeLists.txt b/CMakeLists.txt index d3e2979..9a60fd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,3 +28,5 @@ include(cmake/library.cmake) include(cmake/platform.cmake) include(cmake/qt.cmake) include(cmake/pkg-config.cmake) + +add_subdirectory(example) \ No newline at end of file diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 710e05a..9ed8e5b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,11 +1,7 @@ -cmake_minimum_required(VERSION 2.8.8) -project(qxtglobalshortcut_test) - -find_package(qxtglobalshortcut REQUIRED) find_package(Qt6 REQUIRED COMPONENTS Widgets) -set(bin qxtglobalshortcut_test) -add_executable(${bin} src/main.cpp) +include_directories(${PROJECT_BINARY_DIR}/exports) -target_link_libraries(${bin} qxtglobalshortcut) -target_link_libraries(${bin} Qt6::Widgets) +add_executable(qxtglobalshortcut_test src/main.cpp) + +target_link_libraries(qxtglobalshortcut_test qxtglobalshortcut Qt6::Widgets) diff --git a/src/qxtglobalshortcut_mac.cpp b/src/qxtglobalshortcut_mac.cpp index 945ade5..9564608 100644 --- a/src/qxtglobalshortcut_mac.cpp +++ b/src/qxtglobalshortcut_mac.cpp @@ -34,6 +34,7 @@ #include #include #include +#include using Identifier = QPair; static QMap keyRefs; @@ -43,6 +44,9 @@ static bool qxt_mac_handler_installed = false; 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(data); if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) @@ -359,7 +363,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ EventTypeSpec t; t.eventClass = kEventClassKeyboard; 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; @@ -367,7 +371,7 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ keyID.id = ++hotKeySerial; EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + bool rv = true; // = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); if (rv) { keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);