Skip to content

Draft: Implement XDG session management protocol

Carlos Garnacho requested to merge carlosg/gtk:wip/session-management into main

Add the GDK/wayland glue to implement the XDG session management protocol, and the following high-level API to let applications deal with session management:

  • gtk_application_set_session_id() (plus getter/property) to set a session identifier, obtained from previous runs, and stored by the application.
  • gtk_application_get_current_session_id() to get the session identifier in use. This will be the source of the session identifier to preserve for future runs, left up to the application.
  • gtk_window_set_session_id() to specify a per-GtkWindow identifier to use within the session. This identifier will be used during map to (maybe) recover the window state from previous runs, all performed by the compositor. This identifier needs to be persistent between calls, either statically or dynamically generated by the app (would require further state saving by the app in the latter case)

Used right, and with a compositor implementing this protocol, this is enough to let windows be restored to their previous positions/sizes when launched. The GtkApplication integration also checks on GtkWindow.hide_on_close to decide whether windows should be preserved or forgotten on future runs. gtk4-demo was changed to also demo what is expected to have this working.

In the future, this could/should be integrated with client-side persistent state-saving, so that the session identifiers are part of the persistent data. It perhaps makes sense for these to be loosely connected, in order to give applications some leeway on how sessions are applied and restored.

Related: mutter!3825 (merged)

Merge request reports

Loading