From 01aaa0ba0b126cacff08e93a97a92c6afb9913f2 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 20 Nov 2024 18:12:20 +0100 Subject: [PATCH] Disable SPMediaKeyTap Workaround issue #1606 --- CMakeLists.txt | 7 +++---- src/core/mac_startup.mm | 34 +++++++++++++++++----------------- src/includes/mac_delegate.h | 6 +++--- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 738dcb80c..204d9570b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,9 +271,9 @@ else() add_definitions(-DKDSINGLEAPPLICATION_STATIC_BUILD) endif() -if(APPLE) - find_package(SPMediaKeyTap REQUIRED) -endif() +# if(APPLE) +# find_package(SPMediaKeyTap REQUIRED) +# endif() if(WIN32) find_package(getopt-win REQUIRED) @@ -1537,7 +1537,6 @@ if(APPLE) "-framework DiskArbitration" "-framework IOKit" "-framework ScriptingBridge" - SPMediaKeyTap ) endif() diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index 40d031035..89923e610 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -41,7 +41,7 @@ #import -#import +//#import #include "config.h" @@ -145,18 +145,18 @@ QDebug operator<<(QDebug dbg, NSObject *object) { [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; - key_tap_ = [[SPMediaKeyTap alloc] initWithDelegate:self]; - if ([SPMediaKeyTap usesGlobalMediaKeyTap]) { - if ([key_tap_ startWatchingMediaKeys]) { - qLog(Debug) << "Media key monitoring started"; - } - else { - qLog(Warning) << "Failed to start media key monitoring"; - } - } - else { - qLog(Warning) << "Media key monitoring disabled"; - } + // key_tap_ = [[SPMediaKeyTap alloc] initWithDelegate:self]; + // if ([SPMediaKeyTap usesGlobalMediaKeyTap]) { + // if ([key_tap_ startWatchingMediaKeys]) { + // qLog(Debug) << "Media key monitoring started"; + // } + // else { + // qLog(Warning) << "Failed to start media key monitoring"; + // } + // } + // else { + // qLog(Warning) << "Media key monitoring disabled"; + // } } @@ -192,10 +192,10 @@ QDebug operator<<(QDebug dbg, NSObject *object) { } -- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event { - #pragma unused(keyTap) - [self handleMediaEvent:event]; -} +// - (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event { +// #pragma unused(keyTap) +// [self handleMediaEvent:event]; +// } - (BOOL) handleMediaEvent:(NSEvent*)event { // if it is not a media key event, then ignore diff --git a/src/includes/mac_delegate.h b/src/includes/mac_delegate.h index d1bb72e23..8d91a553e 100644 --- a/src/includes/mac_delegate.h +++ b/src/includes/mac_delegate.h @@ -4,13 +4,13 @@ #include "globalshortcuts/globalshortcutsbackend-macos.h" class PlatformInterface; -@class SPMediaKeyTap; +//@class SPMediaKeyTap; @interface AppDelegate : NSObject { PlatformInterface *application_handler_; NSMenu *dock_menu_; GlobalShortcutsBackendMacOS *shortcut_handler_; - SPMediaKeyTap *key_tap_; + //SPMediaKeyTap *key_tap_; } @@ -29,5 +29,5 @@ class PlatformInterface; - (void) setDockMenu: (NSMenu*)menu; - (GlobalShortcutsBackendMacOS*) shortcut_handler; - (void) setShortcutHandler: (GlobalShortcutsBackendMacOS*)backend; -- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event; +//- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event; @end