diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2024-08-12 17:12:36 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2024-08-12 17:18:59 +0100 |
commit | 1873e4116ff53daacde7849f8b7f23ac0b527bec (patch) | |
tree | b84a031025c1859668c7c5d28b45b70d50edddf0 /src/qt | |
parent | b21ba081be89a6716cce91d8a01b8c0abe9c77a3 (diff) | |
parent | 15aa7d023688700a47997b92108de95f2d864f5a (diff) |
Merge bitcoin-core/gui#831: GUIUtil::brintToFront workaround for Wayland
15aa7d023688700a47997b92108de95f2d864f5a gui, qt: brintToFront workaround for Wayland (pablomartin4btc)
Pull request description:
There are known issues around handling windows focus in `Wayland` ([this one specific](https://bugs.kde.org/show_bug.cgi?id=462574) in KDE but also in [gnome](https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/730)).
The idea is that the workaround will be executed if `bitcoin-qt` is running using `Wayland` platform (e.g.: `QT_QPA_PLATFORM=wayland ./src/qt/bitcoin-qt -regtest`), since the workaround behaviour looks like re-opening the window again (which I tried to fix by moving the window to the original position and/ or re-setting the original geometry without success) while in `X11` (not sure in Mac) the current `GUIUtil::brintToFront` actually sets the focus to the desired window, keeping its original position as expected, and I didn't want to change that (`X11` behaviour).
The solution was [initially discussed](https://github.com/bitcoin-core/gui/pull/817#issuecomment-2256158902) with hebasto in #817.
ACKs for top commit:
hebasto:
ACK 15aa7d023688700a47997b92108de95f2d864f5a.
Tree-SHA512: 141d6cc4a618026e551627b9f4cc284285980db02a54a7b19c7de91e8c5adccf0c1d67380625146b5413e58c59f39c9e944ed5ba68cb8644f67647518918b6f7
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/guiutil.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index baa19d7c24..f04e5c86f8 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -405,19 +405,26 @@ bool isObscured(QWidget *w) void bringToFront(QWidget* w) { -#ifdef Q_OS_MACOS - ForceActivation(); -#endif - if (w) { - // activateWindow() (sometimes) helps with keyboard focus on Windows - if (w->isMinimized()) { - w->showNormal(); - } else { + if (QGuiApplication::platformName() == "wayland") { + auto flags = w->windowFlags(); + w->setWindowFlags(flags|Qt::WindowStaysOnTopHint); + w->show(); + w->setWindowFlags(flags); w->show(); + } else { +#ifdef Q_OS_MACOS + ForceActivation(); +#endif + // activateWindow() (sometimes) helps with keyboard focus on Windows + if (w->isMinimized()) { + w->showNormal(); + } else { + w->show(); + } + w->activateWindow(); + w->raise(); } - w->activateWindow(); - w->raise(); } } |