From 0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:56:00 +0200 Subject: Checkpoint: preserve all uncommitted rust-rewrite worktree work Safety commit before reconciling this worktree with main, which has diverged with its own separate fixes today. Nothing here is reviewed or curated yet - this exists purely so none of this work can be lost to a git operation, disk issue, or worktree cleanup while that reconciliation happens. --- crates/wayland/src/protocols/xdg_activation.rs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 crates/wayland/src/protocols/xdg_activation.rs (limited to 'crates/wayland/src/protocols/xdg_activation.rs') diff --git a/crates/wayland/src/protocols/xdg_activation.rs b/crates/wayland/src/protocols/xdg_activation.rs new file mode 100644 index 0000000..846a213 --- /dev/null +++ b/crates/wayland/src/protocols/xdg_activation.rs @@ -0,0 +1,36 @@ +//! `xdg_activation_v1`: a launcher hands a spawned app a token, and the +//! app's own first window presents it back to ask to be raised and focused. + +use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::wayland::xdg_activation::{XdgActivationHandler, XdgActivationState, XdgActivationToken, XdgActivationTokenData}; + +use crate::state::CompState; + +impl XdgActivationHandler for CompState { + fn activation_state(&mut self) -> &mut XdgActivationState { + &mut self.xdg_activation_state + } + + /// A launcher spawns an app after first getting a token + /// (`get_activation_token`) and handing it to the new process (usually + /// via `XDG_ACTIVATION_TOKEN`); the app's own first window then + /// presents that same token back here via `activate`, asking to be + /// raised. Without this, that request was silently ignored - the new + /// window opened and just sat there unfocused behind everything, + /// exactly the gap `docs/PANEL_SUPPORT_TODO.md`'s P1 flagged. + /// + /// No token bookkeeping of our own: `token_created`'s default already + /// accepts every token (fine for a single-user session with no + /// cross-client trust boundary to enforce), so all that's left is + /// mapping the activating `surface` to a `WindowId` and reusing the + /// exact same `focus_window` path a dock's "activate" request already + /// goes through (`foreign_toplevel.rs`). If the surface isn't tracked + /// yet - the activation raced ahead of this window's own mapping -- + /// there is nothing to focus yet, so this is a no-op rather than an + /// error; the protocol doesn't require honoring every activation. + fn request_activation(&mut self, _token: XdgActivationToken, _token_data: XdgActivationTokenData, surface: WlSurface) { + if let Some(&id) = self.surface_to_id.get(&surface) { + crate::input::focus_window(self, id); + } + } +} -- cgit v1.2.3