Bitcoin Core 31.99.0
P2P Digital Currency
macdockiconhandler.mm
Go to the documentation of this file.
1// Copyright (c) 2011-present 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
6
7#include <AppKit/AppKit.h>
8#include <objc/runtime.h>
9
11
12bool dockClickHandler(id self, SEL _cmd, ...) {
13 Q_UNUSED(self)
14 Q_UNUSED(_cmd)
15
17
18 // Return NO (false) to suppress the default macOS actions
19 return false;
20}
21
23 if (NSApp == nil) return;
24 Class delClass = (Class)[[NSApp delegate] class];
25 SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
26 class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");
27}
28
30{
32}
33
35{
36 if (!s_instance)
38 return s_instance;
39}
40
42{
43 delete s_instance;
44}
45
52{
53 if (NSApp == nil) return;
54 [NSApp activateIgnoringOtherApps:YES];
55}
macOS-specific Dock icon handler.
static MacDockIconHandler * instance()
static MacDockIconHandler * s_instance
void setupDockClickHandler()
bool dockClickHandler(id self, SEL _cmd,...)
void ForceActivation()
Force application activation on macOS.