Skip to content

eframe: use the activation token from the environment on window creation - #8406

Open
Le-Syl21 wants to merge 2 commits into
emilk:mainfrom
Le-Syl21:activation-token-from-env
Open

eframe: use the activation token from the environment on window creation#8406
Le-Syl21 wants to merge 2 commits into
emilk:mainfrom
Le-Syl21:activation-token-from-env

Conversation

@Le-Syl21

Copy link
Copy Markdown
Contributor

A desktop entry with StartupNotify=true hands the launched process an activation token through XDG_ACTIVATION_TOKEN (Wayland) or DESKTOP_STARTUP_ID (X11). winit can apply one, but only at window creation, via WindowAttributesExtStartupNotify::with_activation_token. eframe never reads it, so the token our launcher went to the trouble of issuing is thrown away.

winit's own docs are blunt about the consequence:

The ActivationToken is essential to ensure that your newly created window will obtain the focus, otherwise the user could be required to click on the window.

That is what I ran into: under Mutter the window opens unfocused and cannot recover, since ViewportCommand::Focus is precisely the request focus-stealing prevention blocks. On a kiosk-style setup the cost goes past a missing title-bar highlight — a compositor only grants a pointer constraint to a focused surface, so CursorGrab silently does nothing too.

This reads the variable when building the window attributes and passes it to winit. The environment is cleared afterwards through winit's reset_activation_token_env(), per the startup-notification spec: a token is single-use, and leaving it around would have every later viewport, and every child process, replay it.

Linux only, behind the existing wayland/x11 features; a no-op when the variables are absent.

…reation

A desktop entry with `StartupNotify=true` hands the application a token
through `XDG_ACTIVATION_TOKEN` (Wayland) or `DESKTOP_STARTUP_ID` (X11),
and winit can only apply one at window creation
(`WindowAttributesExtStartupNotify::with_activation_token`). eframe never
read it, so the first window opened without it.

On a compositor that enforces focus-stealing prevention that is not a
cosmetic loss: the window opens unfocused and cannot recover, since
`ViewportCommand::Focus` is precisely the request being refused. Measured
on a pinball cabinet under Mutter — the launcher stayed unfocused from
startup until the user clicked it, which also cost it the pointer
constraint (a compositor only grants one to a focused surface), so the
mouse could neither be confined nor move the cursor.

The variables are cleared once read, per the startup-notification spec: a
token is single-use, and leaving it in the environment would have every
later viewport, and every child process, replay it.
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/8406-activation-token-from-env
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@emilk emilk added native-linux Problem specific to Linux bug Something is broken eframe Relates to epi and eframe labels Aug 11, 2026
@emilk
emilk requested a review from lucasmerlin August 11, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken eframe Relates to epi and eframe native-linux Problem specific to Linux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants