Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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 #if QT_VERSION < 0x050000
11 extern void qt_mac_set_dock_menu(QMenu *);
12 #endif
13 
14 static MacDockIconHandler *s_instance = nullptr;
15 
16 bool dockClickHandler(id self, SEL _cmd, ...) {
17  Q_UNUSED(self)
18  Q_UNUSED(_cmd)
19 
20  Q_EMIT s_instance->dockIconClicked();
21 
22  // Return NO (false) to suppress the default macOS actions
23  return false;
24 }
25 
27  Class delClass = (Class)[[[NSApplication sharedApplication] delegate] class];
28  SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
29  class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");
30 }
31 
33 {
35 }
36 
38 {
39  if (!s_instance)
41  return s_instance;
42 }
43 
45 {
46  delete s_instance;
47 }
48 
55 {
56  [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
57 }
void setupDockClickHandler()
void qt_mac_set_dock_menu(QMenu *)
macOS-specific Dock icon handler.
static MacDockIconHandler * instance()
static MacDockIconHandler * s_instance
bool dockClickHandler(id self, SEL _cmd,...)
void ForceActivation()
Force application activation on macOS.
Released under the MIT license