Repository navigation
libaudqt: Use unique window role for core & plugin windows, fix crash with QT 6.12, follow x11 rule - #1889
Conversation
…ger_v1 under qt 3.12, complies with icccm sect. 5.1 as well for xwindowsystem
There was a problem hiding this comment.
🟡 Changes recommended
The global serial makes persistent Wayland window identities depend on unrelated window creation order.
1 open finding
What changed in this PR
Introduces unique Qt window roles to prevent Qt 6.12 Wayland session-ID collisions.
Changes:
- Adds an internal window-role helper with serialized identifiers.
- Migrates all core Qt windows and dialogs to the helper.
- Preserves role prefixes for existing window rules.
| File | Description |
|---|---|
src/libaudqt/about-qt.cc |
Migrates the About dialog role. |
src/libaudqt/audqt.cc |
Implements role serialization and migrates messages. |
src/libaudqt/colorbutton.cc |
Migrates color-dialog roles. |
src/libaudqt/eq-preset-qt.cc |
Migrates preset file-dialog roles. |
src/libaudqt/file-entry.cc |
Migrates file-entry dialog roles. |
src/libaudqt/fileopener.cc |
Migrates file-opener dialog roles. |
src/libaudqt/infowin-qt.cc |
Migrates song-information roles. |
src/libaudqt/libaudqt-internal.h |
Declares the internal helper. |
src/libaudqt/log-inspector.cc |
Migrates log-inspector roles. |
src/libaudqt/playlist-management.cc |
Migrates playlist-dialog roles. |
src/libaudqt/prefs-plugin.cc |
Migrates plugin-settings roles. |
src/libaudqt/prefs-window-qt.cc |
Migrates application-settings roles. |
src/libaudqt/queue-manager-qt.cc |
Migrates queue-manager roles. |
src/libaudqt/song-window-qt.cc |
Migrates jump-to-song roles. |
src/libaudqt/url-opener-qt.cc |
Migrates URL-dialog roles. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Addressing since marking not-changed collapsed it, This isn't a concern for this change. Audacious doesn't participate in session restore. It only ran into the protocol because Qt 6.12 now registers window roles as xdg_session_v1 toplevel IDs, and the compositor enforces their uniqueness. src/libaudqt/audqt.cc constructs its QApplication with a dummy argv, so Qt never sees -session and always calls get_session(reason_launch, nil). Every launch is a fresh compositor session, so IDs are never matched across restarts. The fixed roles used before this PR weren't restored across restarts either. The global serial is scoped to a single run and exists only to guarantee uniqueness within that run, which is the requirement this PR addresses. |
|
Obsolete now with 612bd8b. |

Related to audacious-media-player/audacious-plugins#215, these changes complement the fix addressing #1887. This remedies a crash new to QT 6.12 & related to the new session restore protocol.
This also, as I discovered while fixing the crash, incidentally makes both occurrences of setWindowRole (in core repo, and in the plugins repo) comply with ICCCM §5.1. This historically was not a problem as it seems X11 was not strictly enforcing compliance with 5.1, but wayland compositors/qt are now doing so in support of the new session restore functionality, introducing a crash instead of a quiet error.
We provide a helper declared in
libaudqt-internal.hwith a little explainer comment in that file since it'd be unique among these QT setX methods where it is used, leaving the public API unchanged and being fully independent from the changes made under theaudacious-pluginsrepo due to the way their concerns are separated.Opted for a helper instead of the per-window handler change like the plugins repo due to
setWindowRoleappearing in a multitude of areas undersrc/libaudqt/. All 16 audacious coresetWindowRolecalls now go through it:audqt::set_window_role(window, role), next towindow_bring_to_frontinaudqt.cc. That includes the windows that can only ever have one copy open, so every role works the same way to avoid confusion as to why some window roles are set through this and why some don't.Functionally, it simply appends a per-process serial number to the role. Each window gets a unique role (settings-1, file-dialog-4, etc).
For those users that use window rules that rely on the window's role, prefix rules like
^settingskeep matching. This DOES break exact-match rules, necessarily, but prefix rules will continue working:KWin (my environment): Substring rule matching
settings-, or regex matching^settings-[0-9]+$sway/i3 type:
window_role="^settings-"Most changed files follow as shown in
src/libaudqt/colorbutton.ccas an example:Uniquely, about-qt.cc calls it as audqt::set_window_role because it's in a separate namespace. Eight files gained an include of
libaudqt-internal.hin order to call this helper.Testing: built a patched 4.6.1 with patched libaudqt as well as the fixes for the plugins repo applied. Ran with the generic QT platform theme, as this had more crash cases than my normal KWin environment - file dialogs and message boxes use native helpers in platform themes that provide them, but generic QT would previously crash on two of those being opened with this enforced, due to not handing it off to a native helper that doesn't exist in that setting.
The new roles appear in the Wayland trace next to plugin- and mainwindow, with no errors.
Every case that would have crashed with the old fixed roles survived: two+ plugin settings dialogs, two+ file dialogs, combinations of those along with windows having their role set by the fixes on the plugins side. On stock 4.6.1 each of these is a duplicate "plugin-settings" or "file-dialog" ID, and a crash. The fixes for plugins and the core audacious repo coexist without issues; I had settings-9, plugin-settings-10, plugin-settings-11, plugin-blur_scope-qt, plugin-qt-spectrum, file-dialog-5, file-dialog-6 all open at once with no issues. Closing one of the core windows affected by this PR, and indeed just opening a new copy of any core window without regard for whether or not it was previously closed, properly increments the window's role ID, preventing any possible collisions.
Two plugins with their settings windows opened simultaneously, with generic QT enforced on the patches. No wayland errors.