Bug 462574 - On Wayland, window's doesn't become active when calling QWidget::activateWindow and QWidget::raise
Summary: On Wayland, window's doesn't become active when calling QWidget::activateWind...
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.26.3
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-03 08:43 UTC by Michael Weghorn
Modified: 2022-12-04 16:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Sample app to reproduce (726 bytes, text/x-c++src)
2022-12-03 08:43 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2022-12-03 08:43:11 UTC
Created attachment 154260 [details]
Sample app to reproduce

SUMMARY

On X11, raising a window can be done by calling QWidget::activateWindow and QWidget::raise. However, that does not have the desired effect in a Plasma Wayland session.

STEPS TO REPRODUCE

0. run a KDE Plasma Wayland session
1. compile attached sample program against Qt 6
2. run sample program
3. click the "raise other window button" in window "two"

OBSERVED RESULT

The window "one" is highlighted in the taskbar, but does not become the active window instead of window "two"

EXPECTED RESULT

Window "one" should become the active window, as is the case when run on X11.

SOFTWARE/OS VERSIONS
Debian testing with Qt 6.3.1

Linux/KDE Plasma: 
Operating System: Debian GNU/Linux
KDE Plasma Version: 5.26.3
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.6
Kernel Version: 6.0.0-5-amd64 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-5300U CPU @ 2.30GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 5500
Manufacturer: LENOVO
Product Name: 20CJS11C00
System Version: ThinkPad T550

ADDITIONAL INFORMATION

It works as expected when run with QT_QPA_PLATFORM=xcb, i.e. forcing use of Qt's xcb platform plugin.

For Qt 5, this is not expected to work since QWindow::requestActivate isn't handled there on Qt side and I don't know whether the underlying problem(s) is in Qt or KWin or elsewhere.
This issue was originally reported against LibreOffice, https://bugs.documentfoundation.org/show_bug.cgi?id=152205#c7 contains some more information on 2 scenarios that fail in different ways and might haver different root causes. (A LibreOffice scenario with gtk3 integration works on GNOME, but not KDE Plasma. The sample Qt app doesn't work in any of them, so there might be different issues.)
Comment 1 Nicolas Fella 2022-12-04 16:16:15 UTC
In general for QWindow::requestActivate to work an activation token needs to be set. It can't just work in all cases.

For the case where a window activates another window of the same app Qt can do that automatically since https://codereview.qt-project.org/c/qt/qtwayland/+/418094. That was added after Qt 6.3.1 though