Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include "macdockiconhandler.h"7#include <AppKit/AppKit.h>8#include <objc/runtime.h>10static MacDockIconHandler *s_instance = nullptr;12bool dockClickHandler(id self, SEL _cmd, ...) {13Q_UNUSED(self)14Q_UNUSED(_cmd)16Q_EMIT s_instance->dockIconClicked();18// Return NO (false) to suppress the default macOS actions19return false;20}22void setupDockClickHandler() {23if (NSApp == nil) return;24Class delClass = (Class)[[NSApp delegate] class];25SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");26class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");27}29MacDockIconHandler::MacDockIconHandler() : QObject()30{31setupDockClickHandler();32}34MacDockIconHandler *MacDockIconHandler::instance()35{36if (!s_instance)37s_instance = new MacDockIconHandler();38return s_instance;39}41void MacDockIconHandler::cleanup()42{43delete s_instance;44}46/**47* Force application activation on macOS. With Qt 5.5.1 this is required when48* an action in the Dock menu is triggered.49* TODO: Define a Qt version where it's no-longer necessary.50*/51void ForceActivation()52{53if (NSApp == nil) return;54[NSApp activateIgnoringOtherApps:YES];55}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.