Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
qt
macdockiconhandler.mm
Go to the documentation of this file.
1
// Copyright (c) 2011-2019 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include "
macdockiconhandler.h
"
6
7
#include <AppKit/AppKit.h>
8
#include <objc/runtime.h>
9
10
static
MacDockIconHandler
*
s_instance
=
nullptr
;
11
12
bool
dockClickHandler
(
id
self
,
SEL
_cmd
, ...) {
13
Q_UNUSED
(
self
)
14
Q_UNUSED
(
_cmd
)
15
16
Q_EMIT
s_instance
->
dockIconClicked
();
17
18
// Return NO (false) to suppress the default macOS actions
19
return
false
;
20
}
21
22
void
setupDockClickHandler
() {
23
Class
delClass
=
24
(Class)[[[
NSApplication
sharedApplication
]
delegate
]
class
];
25
SEL
shouldHandle
=
26
sel_registerName
(
"applicationShouldHandleReopen:hasVisibleWindows:"
);
27
class_replaceMethod
(
delClass
,
shouldHandle
, (
IMP
)
dockClickHandler
,
"B@:"
);
28
}
29
30
MacDockIconHandler::MacDockIconHandler
() : QObject() {
31
setupDockClickHandler
();
32
}
33
34
MacDockIconHandler
*
MacDockIconHandler::instance
() {
35
if
(!
s_instance
)
s_instance
=
new
MacDockIconHandler
();
36
return
s_instance
;
37
}
38
39
void
MacDockIconHandler::cleanup
() {
40
delete
s_instance
;
41
}
42
48
void
ForceActivation
() {
49
[[
NSApplication
sharedApplication
]
activateIgnoringOtherApps
:
YES
];
50
}
MacDockIconHandler
macOS-specific Dock icon handler.
Definition
macdockiconhandler.h:13
MacDockIconHandler::MacDockIconHandler
MacDockIconHandler()
Definition
macdockiconhandler.mm:30
MacDockIconHandler::dockIconClicked
void dockIconClicked()
MacDockIconHandler::cleanup
static void cleanup()
Definition
macdockiconhandler.mm:39
MacDockIconHandler::instance
static MacDockIconHandler * instance()
Definition
macdockiconhandler.mm:34
macdockiconhandler.h
s_instance
static MacDockIconHandler * s_instance
Definition
macdockiconhandler.mm:10
setupDockClickHandler
void setupDockClickHandler()
Definition
macdockiconhandler.mm:22
dockClickHandler
bool dockClickHandler(id self, SEL _cmd,...)
Definition
macdockiconhandler.mm:12
ForceActivation
void ForceActivation()
Force application activation on macOS.
Definition
macdockiconhandler.mm:48
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
Generated on Thu Dec 26 2024 02:38:03 for Bitcoin ABC by
1.9.8