aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-01-03 09:53:13 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2019-01-03 09:54:44 +0100
commit5ff7b372cdbdf301b74e70dec0a68ec27737c8ad (patch)
tree39ea96841577bc6d12132f30f590c43d69c00240 /src/qt/guiutil.cpp
parent16521ce08676db36d1e1db65749e54180d5201b4 (diff)
parent27beb8322297d70dccc4db0605b22470e50e9010 (diff)
downloadbitcoin-5ff7b372cdbdf301b74e70dec0a68ec27737c8ad.tar.xz
Merge #15065: 0.17: GUI Backports #14123 #14133 #14383 #14597
27beb8322297d70dccc4db0605b22470e50e9010 qt: All tray menu actions call showNormalIfMinimized (João Barbosa) c470bbd19db048e771ad7495b24b7d09e63e9e1b qt: Use GUIUtil::bringToFront where possible (João Barbosa) ac73c7d433e609f4516136c543623c6c6f0245e2 qt: Add GUIUtil::bringToFront (João Barbosa) 0c2fb87dc1ec1b13fa7abab038f6c52ce0c749e9 Remove obj_c for macOS Dock icon menu (Hennadii Stepanov) 90347141bdb4020875c55ff51375aada46a1a4d9 Use Qt signal for macOS Dock icon click event (Hennadii Stepanov) 4d4bc37df983a8c8bb7a2d926521836e4ce8c913 Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) d2ed162ce0c83782d6a66cfdbe1c6aedcb485697 Clean systray icon menu for -disablewallet mode (Hennadii Stepanov) 298dc15686ce38855e41543c833b75e31bf89bce gui: Favor macOS show / hide action in dock menu (João Barbosa) Pull request description: Backport #14123 #14133 #14383 and #14597 to 0.17 branch to fix https://github.com/bitcoin/bitcoin/issues/13606#issuecomment-449846983. Tree-SHA512: 543c80e7e2130870e801e0c9a69b06b9eea27c288478fc5dddeb662f7f3ec5b56b30916e5a9a629fced3fffcb8be77e2cd155e75cfd0a4392299add9730840f4
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index f8f031041c..0d80651431 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -64,6 +64,14 @@
static fs::detail::utf8_codecvt_facet utf8;
+#if defined(Q_OS_MAC)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#include <objc/objc-runtime.h>
+#include <CoreServices/CoreServices.h>
+#endif
+
namespace GUIUtil {
QString dateTimeStr(const QDateTime &date)
@@ -357,6 +365,27 @@ bool isObscured(QWidget *w)
&& checkPoint(QPoint(w->width() / 2, w->height() / 2), w));
}
+void bringToFront(QWidget* w)
+{
+#ifdef Q_OS_MAC
+ // Force application activation on macOS. With Qt 5.4 this is required when
+ // an action in the dock menu is triggered.
+ id app = objc_msgSend((id) objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
+ objc_msgSend(app, sel_registerName("activateIgnoringOtherApps:"), YES);
+#endif
+
+ if (w) {
+ // activateWindow() (sometimes) helps with keyboard focus on Windows
+ if (w->isMinimized()) {
+ w->showNormal();
+ } else {
+ w->show();
+ }
+ w->activateWindow();
+ w->raise();
+ }
+}
+
void openDebugLogfile()
{
fs::path pathDebug = GetDataDir() / "debug.log";
@@ -682,13 +711,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
#elif defined(Q_OS_MAC)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
-#include <CoreFoundation/CoreFoundation.h>
-#include <CoreServices/CoreServices.h>
-
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
{