Skip to main content

Module window_activation

Module window_activation 

Source
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_v1 startup token from the environment (set by the process that spawned us) and apply it to attrs, 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 window above others and give it keyboard focus, best-effort.
request_activation_token
Ask the compositor for an xdg_activation_v1 token for window (to hand to another window or a child process). Returns true if a request was issued — the token then arrives via WindowEvent::ActivationTokenDone. Returns false where unsupported (everything but Wayland/X11), so the caller treats “no token” as immediate.
set_child_activation_env
Inject an xdg_activation_v1 token into a child process’s environment so its first window (built with WindowConfig::activate_from_env) comes up focused on Wayland. Sets both the Wayland and X11 startup-notify variables that winit’s read_token_from_env looks for. No-op off Wayland/X11.