https://bugs.kde.org/show_bug.cgi?id=522008

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #16 from [email protected] ---
I dug into the root cause and I don't think it's the wl_surface persisting
across hide/show (as MR !156 assumed). It's Qt 6.12's new
xdg-session-management support, triggered by KMainWindow's window role.

Root cause:
1. Since Qt 6.12, QWidget::setWindowRole() also sets the Wayland session
restore id (qtbase src/widgets/kernel/qwidget.cpp:
waylandWindow->setSessionRestoreId(topData()->role)). The xdg-shell plugin then
passes it to xdg_session_v1.restore_toplevel().
2. KMainWindow always sets the window role to its object name (kxmlgui
src/kmainwindow.cpp: q->setWindowRole(s)), unless Qt::AA_DisableSessionManager
is set.
3. Yakuake's toplevel is still destroyed on retract and recreated on open:
workspace.windowRemoved/windowAdded fire in a KWin script on every toggle. The
new toplevel comes back with the same restore id, so KWin restores its previous
state, including the virtual desktop. The window is then activated, and KWin
switches to that desktop.

Verification (KWin script logging):
- On desktop 2, toggling Yakuake: currentDesktopChanged "Desktop 2 -> Desktop
1" fires ~20 ms after the toggle, before windowAdded for Yakuake.
- I moved the open Yakuake window to desktop 3, retracted it there, switched to
desktop 2 and opened it again. KWin jumped to desktop 3. So the window is
restored to the last desktop it was on, not to the desktop Yakuake was started
on.
- Starting Yakuake with QT_WAYLAND_DISABLED_INTERFACES=xdg_session_manager_v1
fixes it. Yakuake opens on the current desktop and stays behind when switching
desktops, as before Qt 6.12. With the "Virtual desktops: Force, All desktops"
rule, Yakuake instead follows you to every desktop.

Possible fix (untested): Yakuake doesn't rely on session restore. Setting
QCoreApplication::setAttribute(Qt::AA_DisableSessionManager) before the
MainWindow is created should prevent the restore: KMainWindow then skips
setWindowRole(), and Qt doesn't create the Wayland session. Clearing the role
with setWindowRole(QString()) should also work.

Workaround for users: add the env var to Exec= in
~/.config/autostart/org.kde.yakuake.desktop,
~/.local/share/applications/org.kde.yakuake.desktop and
~/.local/share/dbus-1/services/org.kde.yakuake.service:
Exec=env QT_WAYLAND_DISABLED_INTERFACES=xdg_session_manager_v1 yakuake

openSUSE Tumbleweed, Yakuake 26.08.2, KF 6.31.0, Plasma/KWin 6.8.1, Qt 6.12.0,
Wayland.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to