aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-11-12 14:49:30 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-11-12 14:52:35 +0100
commit48223256cf6cb7c4bbfb78bebab08640eeccff2c (patch)
tree4b7a34ad12390ef80025cd23fec2be4b48c4475d /src/qt/guiutil.cpp
parentae32806ea20235c4542b1a5d4011df5ae267b58a (diff)
parent0a656f85a9c694f25b06c6464d6e986816eecd58 (diff)
downloadbitcoin-48223256cf6cb7c4bbfb78bebab08640eeccff2c.tar.xz
Merge #14123: gui: Add GUIUtil::bringToFront
0a656f85a9c694f25b06c6464d6e986816eecd58 qt: All tray menu actions call showNormalIfMinimized (João Barbosa) 6fc21aca6d5e16c3ece104fec8e5b3df116893b4 qt: Use GUIUtil::bringToFront where possible (João Barbosa) 5796671e1dd8a2d0b1e750c2dce19a10af624095 qt: Add GUIUtil::bringToFront (João Barbosa) 6b1d2972bf9a40f97ba3a5c95831fd179b1054cf Remove obj_c for macOS Dock icon menu (Hennadii Stepanov) 2464925e7be832d4926b6204169bbbc1646c6368 Use Qt signal for macOS Dock icon click event (Hennadii Stepanov) 53bb6be3f8a50ee9e5c4d7e9155236152e7c4b7c Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) Pull request description: The sequence `show -> raise -> activateWindow` is factored out to the new function `GUIUtil::bringToFront` where a macOS fix is added in order to fix #13829. Also included: - simplification of `BitcoinGUI::showNormalIfMinimized` - simplified some connections to `BitcoinGUI::showNormalIfMinimized` - added missing connections to `BitcoinGUI::showNormalIfMinimized`. Tree-SHA512: a8e301aebc359aa353821e2af352ae356f44555724921b01da907e128653ef9dc55d8764a1bff72a579e5ff96df8a681f6804bfe83acba441da92fedff974a55
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 a68140ccf9..b1cd2f77d0 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -60,6 +60,14 @@
#include <QFontDatabase>
#endif
+#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)
@@ -353,6 +361,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";
@@ -663,13 +692,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)
{