Expand description
Cross-platform window “raise / activate” — the per-OS backend behind
WindowState::focus() / WindowOps::focus_window.
winit’s Window::focus_window already performs a real cross-process raise on
X11 (_NET_ACTIVE_WINDOW), Windows (SetForegroundWindow + the SendInput
foreground-lock defeat) and macOS (activateIgnoringOtherApps +
makeKeyAndOrderFront) — including when the target window raises itself in
response to a cross-process request. On Wayland it is a hard no-op, so a
real raise there requires driving xdg_activation_v1 over the window’s raw
wl_surface (see the private wayland submodule).
Callers keep the single focus() API. The optional activation token — an
opaque string minted by the focused requester and handed across the process
boundary — is only ever consulted on Wayland; everywhere else it is ignored
because focus_window() already suffices.
Functions§
- apply_
creation_ token - Consume an
xdg_activation_v1startup token from the environment (set by the process that spawned us) and apply it toattrs, so the created window comes up focused on Wayland. Resets the env afterwards so later windows / grandchild processes don’t reuse a stale token. No-op off Wayland/X11. - raise
- Raise
windowabove others and give it keyboard focus, best-effort. - request_
activation_ token - Ask the compositor for an
xdg_activation_v1token forwindow(to hand to another window or a child process). Returnstrueif a request was issued — the token then arrives viaWindowEvent::ActivationTokenDone. Returnsfalsewhere unsupported (everything but Wayland/X11), so the caller treats “no token” as immediate. - set_
child_ activation_ env - Inject an
xdg_activation_v1tokeninto a child process’s environment so its first window (built withWindowConfig::activate_from_env) comes up focused on Wayland. Sets both the Wayland and X11 startup-notify variables that winit’sread_token_from_envlooks for. No-op off Wayland/X11.