1
- // Copyright (c) 2011-2018 The Bitcoin Core developers
1
+ // Copyright (c) 2011-2019 The Bitcoin Core developers
2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include " macdockiconhandler.h"
6
6
7
- #undef slots
8
- #include < objc/objc.h>
9
- #include < objc/message.h>
7
+ #include < AppKit/AppKit.h>
8
+ #include < objc/runtime.h>
10
9
11
10
static MacDockIconHandler *s_instance = nullptr ;
12
11
@@ -21,9 +20,7 @@ bool dockClickHandler(id self, SEL _cmd, ...) {
21
20
}
22
21
23
22
void setupDockClickHandler () {
24
- id app = objc_msgSend ((id )objc_getClass (" NSApplication" ), sel_registerName (" sharedApplication" ));
25
- id delegate = objc_msgSend (app, sel_registerName (" delegate" ));
26
- Class delClass = (Class )objc_msgSend (delegate, sel_registerName (" class" ));
23
+ Class delClass = (Class )[[[NSApplication sharedApplication ] delegate ] class ];
27
24
SEL shouldHandle = sel_registerName (" applicationShouldHandleReopen:hasVisibleWindows:" );
28
25
class_replaceMethod (delClass, shouldHandle, (IMP )dockClickHandler, " B@:" );
29
26
}
@@ -44,3 +41,13 @@ void setupDockClickHandler() {
44
41
{
45
42
delete s_instance;
46
43
}
44
+
45
+ /* *
46
+ * Force application activation on macOS. With Qt 5.5.1 this is required when
47
+ * an action in the Dock menu is triggered.
48
+ * TODO: Define a Qt version where it's no-longer necessary.
49
+ */
50
+ void ForceActivation ()
51
+ {
52
+ [[NSApplication sharedApplication ] activateIgnoringOtherApps: YES ];
53
+ }
0 commit comments