Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdg_activation: Allow passing all data in XdgActivationState::create_external_token #1658

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bbb651
Copy link
Contributor

@bbb651 bbb651 commented Feb 14, 2025

I'm not sure about the api style, alternatively this could return a &mut XdgActivationTokenData instead and drop the argument. This is breaking, but not for the common case of activation_state.create_external_token(None).

Example usage in niri ipc (not upstreamed), creating an activation token as if it was created by the focused/requested window:

        Request::DebugCreateActivationToken { id } => {
            let (tx, rx) = async_channel::bounded(1);

            ctx.event_loop.insert_idle(move |state| {
                let window = id
                    .and_then(|id| {
                        state
                            .niri
                            .layout
                            .windows()
                            .find(|(_, m)| m.id().get() == id)
                            .map(|(_, w)| w)
                    })
                    .or_else(|| state.niri.layout.focus());
                let toplevel = window.map(|window| window.toplevel());
                let app_id = toplevel
                    .and_then(|toplevel| with_toplevel_role(toplevel, |role| role.app_id.clone()));
                let surface = toplevel.map(|toplevel| toplevel.wl_surface().clone());
                let (token, data) =
                    state
                        .niri
                        .activation_state
                        .create_external_token(XdgActivationTokenData {
                            app_id,
                            surface,
                            ..Default::default()
                        });
                let _ = tx.send_blocking(token.to_string());
            });

            let result = rx.recv().await;
            let token = result.map_err(|_| String::from("error creating activation token"))?;
            Response::DebugCreateActivationToken(token)
        }

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