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