Implement support for Wayland session management protocol (Issue #26324)

79 views
Skip to first unread message

VZ

unread,
Mar 28, 2026, 11:27:51 AMMar 28
to wx-...@googlegroups.com, Subscribed
vadz created an issue (wxWidgets/wxWidgets#26324)

Support for this protocol has been merged and it has implementations for mutter and kwin, so it should become usable soon.

We should provide a way to use this protocol to restore the windows positions, ideally by integrating it with wxPersistentTLW (but I'm not sure if this is going to be really doable).


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324@github.com>

Neal Gompa (ニール・ゴンパ)

unread,
Apr 6, 2026, 8:23:31 AMApr 6
to wx-...@googlegroups.com, Subscribed
Conan-Kudo left a comment (wxWidgets/wxWidgets#26324)

Does wxWidgets need to do anything special beyond gluing to the Qt/GTK APIs?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/4192223412@github.com>

VZ

unread,
Apr 6, 2026, 10:47:06 AMApr 6
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I think only GTK 4 provides (will provide?) support for this and we don't have a working wxGTK4 port, so we'll have to implement this ourselves on top of GTK 3.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/4192883109@github.com>

VZ

unread,
Jul 26, 2026, 9:52:37 AMJul 26
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I've decided to finally look at doing this but I've hit a stumbling block from the very beginning: we need the xdg_toplevel of the window to use it with this protocol, but there doesn't seem to be any way to get it from GTK 3.

Any ideas for workarounds? The only thing I can think of is to use GTK private structs directly and hope they don't change their ABI (even though they can perfectly well do it because, well, they are private).


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5083769060@github.com>

Neal Gompa (ニール・ゴンパ)

unread,
Jul 26, 2026, 9:58:17 AMJul 26
to wx-...@googlegroups.com, Subscribed
Conan-Kudo left a comment (wxWidgets/wxWidgets#26324)

I don't think there's a way to do that... You might only be able to do it with wxQt.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5083787771@github.com>

dsa-t

unread,
Jul 26, 2026, 1:21:59 PMJul 26
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26324)

Is it possible to use gdk_wayland_window_get_xdg_toplevel (since GTK 3.24)?

e.g. see Firefox implementation: https://github.com/mozilla-firefox/firefox/blob/34ce15fe54f759aedcbf1d73f914f68e080bd880/widget/gtk/nsWindowWayland.cpp#L82


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5084568721@github.com>

VZ

unread,
Jul 26, 2026, 1:50:21 PMJul 26
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

This may be slightly better than my idea to dereference a private impl struct, but it's still using a private function which may disappear/change semantics at any moment. Still, in practice it probably won't and we have to do something like this to be able to do anything at all at Wayland level.

The only other alternative I could see would be to do what I think Chromium does and create its TLWs on its own and then using them with GTK. But this would require a lot of work, even if it's possible to make it work like this.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5084671258@github.com>

paulcor

unread,
Jul 26, 2026, 2:41:00 PMJul 26
to wx-...@googlegroups.com, Subscribed
paulcor left a comment (wxWidgets/wxWidgets#26324)

gdk_wayland_window_get_xdg_toplevel() is actually available in the current F44 gtk3 package, and it seems it's been added to GTK3:
https://gitlab.gnome.org/GNOME/gtk/-/commit/edc9d508c3227d96de1e34aa3d5808a255f0e10b


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5084860132@github.com>

dsa-t

unread,
Jul 26, 2026, 2:54:28 PMJul 26
to wx-...@googlegroups.com, Subscribed
dsa-t left a comment (wxWidgets/wxWidgets#26324)

Looks like it was patched in Fedora 3 days ago. But there is no upstream GTK3 release with that change yet.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5084910023@github.com>

VZ

unread,
Jul 26, 2026, 3:04:48 PMJul 26
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

This is actually both great because it also adds the signal that we need and not so great because it means that support for session management protocol won't work with any but the very latest GTK3 (3.24.53+).


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5084947844@github.com>

VZ

unread,
Jul 26, 2026, 7:06:52 PMJul 26
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I've asked an LLM to create a small example using the SM protocol with just Wayland and it seems correct to me, but doesn't work even under the latest Mutter version (51.alpha-81-g52924b84de): the window is always restored at (0,0) and not at its previous position.

The code is at https://gist.github.com/vadz/6921cb54662bac254f0ac0db9dc7298d, could someone please test it with KWin? If it doesn't work there either, there must be a bug in the code, but if it does, it looks like Mutter doesn't really implement this protocol, even though it provides support for it (provided MUTTER_DEBUG_SESSION_MANAGEMENT_PROTOCOL=1 and MUTTER_DEBUG=session-management are set).


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5085829182@github.com>

Seth Hillbrand

unread,
Jul 26, 2026, 8:59:51 PMJul 26
to wx-...@googlegroups.com, Subscribed
sethhillbrand left a comment (wxWidgets/wxWidgets#26324)

@vadz Your LLM did not call add_toplevel(). Without that, I think that Mutter doesn't know what to call the saved session


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5086283636@github.com>

VZ

unread,
Jul 27, 2026, 1:08:42 PM (14 days ago) Jul 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I thought restore_toplevel() would be sufficient and do what add_toplevel() does too, and even if I was wrong about it, adding it doesn't seem to help. In fact, I forgot to mention that I see (both with and without add_toplevel()) SESSION_MANAGEMENT messages from libmutter saying that it saved and restored session-demo-main-window, but somehow its position is not actually restored.

But before spending more time on this, I'd like to do something else: support for "xx-session-management" protocol was already replaced with support for with "xdg-session-management" one, so I'll change the code to use the latter and test it with Mutter 51.alpha that I have already built anyhow because I was trying to find a workaround for their bug preventing running Mutter as a nested compositor (unsuccessfully). Maybe Mutter 51 fixed this, at least? And I think it makes sense to use the new(er) protocol, even if it's still very recent right now.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5094377656@github.com>

VZ

unread,
Jul 27, 2026, 1:27:31 PM (14 days ago) Jul 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I don't understand what's going on here :-( With Mutter 51 and the new name of the protocol I see the following in the Mutter output:

libmutter-Message: 19:11:18.624: SESSION_MANAGEMENT: Saved window state session-demo-main-window: floating Rect [1432,1001 +480,320]
libmutter-Message: 19:11:22.047: SESSION_MANAGEMENT: Serializing state
libmutter-Message: 19:11:22.047: SESSION_MANAGEMENT: Serializing toplevel state session-demo-main-window
libmutter-Message: 19:11:22.047: SESSION_MANAGEMENT: Serializing state
libmutter-Message: 19:11:22.047: SESSION_MANAGEMENT: Serializing toplevel state session-demo-main-window
libmutter-Message: 19:11:46.862: SESSION_MANAGEMENT: Restoring window session-demo-main-window
libmutter-Message: 19:11:46.862: SESSION_MANAGEMENT: Restored window state session-demo-main-window: floating Rect [1432,1001 +480,320]

so it seems to both store and restore the correct position for showing the window in the bottom right corner — but it still actually appears in the top left one. Further testing shows that if I move the window to another monitor, it's getting restored (whatever its position on the monitor) in the top left corner of that monitor.

I'm very tempted to chalk it up to being a Mutter bug, but knowing that Chrome and Firefox use this protocol, I don't believe it could be as broken as this. Or could it? I need to build KWin (6.3.6 in Debian is just too old to have support for either of these protocols) to try it there.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5094564583@github.com>

VZ

unread,
Jul 27, 2026, 1:46:57 PM (14 days ago) Jul 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

I'm very tempted to chalk it up to being a Mutter bug, but knowing that Chrome and Firefox use this protocol, I don't believe it could be as broken as this.

I should have trusted my feelings, it was my code that was broken. After removing an extra wl_display_roundtrip() call and adding the call to xdg_session_v1_add_toplevel(), just as @sethhillbrand advised, everything works fine now with Mutter 51 alpha, see the updated gist.

So now I have everything needed to add support for restoring windows positions when using GTK 3.24.53 and Mutter 51 or KWin 6.6.90 or later. It wouldn't be difficult to support both the new and the old protocol, which would allow us support older GNOME/KDE versions but as it would still require the latest GTK, I don't think it's worth it.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5094778803@github.com>

VZ

unread,
Aug 6, 2026, 1:32:52 PM (4 days ago) Aug 6
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

Well, I'm almost afraid to say it, but this turned out to be simpler than I thought, see the linked PR.

Of course, this is only the case because our GTK overlords have graciously added support for just what we need to use this protocol, so I'm dutifully thankful for that — better late than never.

Testing is very welcome, especially with KDE, as I didn't test this there yet. But it seems to work perfectly fine with Mutter 51.alpha.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5207844960@github.com>

VZ

unread,
Aug 9, 2026, 1:34:07 PM (13 hours ago) Aug 9
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26324)

Actually I could test it myself pretty easily by just installing the latest kwin package in my Fedora toolbox, unlike Mutter it runs perfectly fine as a nested compositor (the more I look into Wayland stuff, the more I like KDE compared to GNOME1) and the sample restores its geometry under it just fine.

So I'll merge the PR and consider this is done until bug reports start coming.

Footnotes

  1. Which is a bit unfortunate for a maintainer of a GTK-based toolkit.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26324/5232811363@github.com>

VZ

unread,
Aug 9, 2026, 1:37:18 PM (13 hours ago) Aug 9
to wx-...@googlegroups.com, Subscribed

Closed #26324 as completed via 59f3ad3.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26324/issue_event/29188510803@github.com>

Reply all
Reply to author
Forward
0 new messages