Skip to content

Commit 1873e41

Browse files
committed
Merge #831: GUIUtil::brintToFront workaround for Wayland
15aa7d0 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](#817 (comment)) with hebasto in #817. ACKs for top commit: hebasto: ACK 15aa7d0. Tree-SHA512: 141d6cc4a618026e551627b9f4cc284285980db02a54a7b19c7de91e8c5adccf0c1d67380625146b5413e58c59f39c9e944ed5ba68cb8644f67647518918b6f7
2 parents b21ba08 + 15aa7d0 commit 1873e41

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/qt/guiutil.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,26 @@ bool isObscured(QWidget *w)
405405

406406
void bringToFront(QWidget* w)
407407
{
408-
#ifdef Q_OS_MACOS
409-
ForceActivation();
410-
#endif
411-
412408
if (w) {
413-
// activateWindow() (sometimes) helps with keyboard focus on Windows
414-
if (w->isMinimized()) {
415-
w->showNormal();
416-
} else {
409+
if (QGuiApplication::platformName() == "wayland") {
410+
auto flags = w->windowFlags();
411+
w->setWindowFlags(flags|Qt::WindowStaysOnTopHint);
412+
w->show();
413+
w->setWindowFlags(flags);
417414
w->show();
415+
} else {
416+
#ifdef Q_OS_MACOS
417+
ForceActivation();
418+
#endif
419+
// activateWindow() (sometimes) helps with keyboard focus on Windows
420+
if (w->isMinimized()) {
421+
w->showNormal();
422+
} else {
423+
w->show();
424+
}
425+
w->activateWindow();
426+
w->raise();
418427
}
419-
w->activateWindow();
420-
w->raise();
421428
}
422429
}
423430

0 commit comments

Comments
 (0)