Skip to content

fix(wayland): recover the startup activation token GTK unsets - #407

Merged
devmobasa merged 1 commit into
mainfrom
fix/startup-activation-token
Oct 4, 2026
Merged

devmobasa merged 1 commit into
mainfrom
fix/startup-activation-token

Conversation

@devmobasa

Copy link
Copy Markdown
Owner

GTK 4.16 and later remove XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID when libgtk-4 loads, before main. In default builds, the overlay therefore lost the token supplied by a desktop launcher or the GlobalShortcuts portal, preventing the xdg fallback window from applying it and potentially leaving the overlay unfocused.

Recover startup-notification values from /proc/self/environ, with a live-environment fallback when /proc cannot be read. Prefer XDG_ACTIVATION_TOKEN, then DESKTOP_STARTUP_ID, with trimming and empty-value handling. Forward both values through the detached --active relaunch, and share the reader with the fake overlay fixture.

Validation:

  • Local tools/lint-and-test.sh passed: 26 steps and 11,558 Cargo tests across both feature modes.
  • The GTK gate passed.
  • Whitespace checks passed for tracked and new files.
  • Child-process regression coverage removes the live variables explicitly, so it works independently of GTK version. Broker coverage checks forwarded and unforwarded relaunches; mutation checks confirmed that dropping forwarding or using only the live environment fails the tests.

Real GNOME focus behavior remains unvalidated. A manual check of overlay focus after the portal shortcut is still needed.

GTK 4.16 and later save XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID for
their own windows and unset both as soon as libgtk-4 loads, before main.
With the default toolbar-gtk feature, the overlay's std::env read of the
token always came back empty, so the xdg fallback window (GNOME and other
compositors without layer-shell) never applied the token a launcher or the
portal global shortcut passed, and could open without focus.

- Read startup-notification variables from the launch environment,
  /proc/self/environ, falling back to the live environment without /proc.
- Use XDG_ACTIVATION_TOKEN, else DESKTOP_STARTUP_ID, keeping the trimming
  and empty-value handling.
- Forward both variables when `--active` relaunches itself detached: the
  broker relaunches with the live environment, which no longer has them.
- Reuse the reader in the fake overlay fixture.
@devmobasa
devmobasa merged commit 2c5061d into main Oct 4, 2026
3 checks passed
@devmobasa
devmobasa deleted the fix/startup-activation-token branch October 4, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant