From 2eeae0aea64b4906224bf6d89f19aa99493edcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 9 Dec 2022 18:16:01 +0100 Subject: [PATCH] Make window activation specific to the GUI platform, in the hope of finding a workaround to the fact that window activation request is impossible in Wayland. [GB.QT5] * BUG: Make window activation specific to the GUI platform, in the hope of finding a workaround to the fact that window activation request is impossible in Wayland. --- gb.qt4/src/CWindow.cpp | 5 +++-- gb.qt5/src/gb.qt.platform.h | 1 + gb.qt5/src/wayland/main.cpp | 6 ++++++ gb.qt5/src/x11/main.cpp | 8 +++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gb.qt4/src/CWindow.cpp b/gb.qt4/src/CWindow.cpp index 5a4070678..21fb849e3 100644 --- a/gb.qt4/src/CWindow.cpp +++ b/gb.qt4/src/CWindow.cpp @@ -2880,9 +2880,10 @@ void MyMainWindow::setBetterMask(QPixmap &bg) void MyMainWindow::activate(void) { #ifdef QT5 - if (!MAIN_platform_is_wayland) + PLATFORM.Window.Activate(this); +#else + activateWindow(); #endif - activateWindow(); } bool MyMainWindow::focusNextPrevChild(bool next) diff --git a/gb.qt5/src/gb.qt.platform.h b/gb.qt5/src/gb.qt.platform.h index ac797a720..2ee5d9ec9 100644 --- a/gb.qt5/src/gb.qt.platform.h +++ b/gb.qt5/src/gb.qt.platform.h @@ -72,6 +72,7 @@ typedef void (*SetProperties)(QWidget *window, int which, QT_WINDOW_PROP *prop); void (*SetUserTime)(QWidget *window, int timestamp); void (*SetTransientFor)(QWidget *window, QWidget *parent); + void (*Activate)(QWidget *window); } Window; } QT_PLATFORM_INTERFACE; diff --git a/gb.qt5/src/wayland/main.cpp b/gb.qt5/src/wayland/main.cpp index dfabad037..0c02906b4 100644 --- a/gb.qt5/src/wayland/main.cpp +++ b/gb.qt5/src/wayland/main.cpp @@ -171,6 +171,11 @@ static void window_set_transient_for(QWidget *window, QWidget *parent) #endif } +static void window_activate(QWidget *win) +{ + win->windowHandle()->alert(0); +} + //------------------------------------------------------------------------- extern "C" { @@ -198,6 +203,7 @@ void *GB_QT5_WAYLAND_1[] EXPORT = { (void *)window_set_properties, (void *)window_set_user_time, (void *)window_set_transient_for, + (void *)window_activate, NULL }; diff --git a/gb.qt5/src/x11/main.cpp b/gb.qt5/src/x11/main.cpp index 8450134b0..5a431d753 100644 --- a/gb.qt5/src/x11/main.cpp +++ b/gb.qt5/src/x11/main.cpp @@ -357,6 +357,11 @@ static void window_set_transient_for(QWidget *window, QWidget *parent) X11_set_transient_for(window->effectiveWinId(), parent->effectiveWinId()); } +static void window_activate(QWidget *window) +{ + window->activateWindow(); +} + //------------------------------------------------------------------------- static void x11_set_event_filter(int (*filter)(XEvent *)) @@ -391,7 +396,8 @@ void *GB_QT5_X11_1[] EXPORT = { (void *)window_set_properties, (void *)window_set_user_time, (void *)window_set_transient_for, - + (void *)window_activate, + NULL };