Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Merged

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)
        }

@PolyMeilex
Copy link
Member

PolyMeilex commented Feb 23, 2025

This seems fine, but what is the use case for pretending that a given surface created the token when in fact it didn't?

@bbb651
Copy link
Contributor Author

bbb651 commented Feb 23, 2025

My use case is to workaround the lack of terminal xdg-activation support (see VTE issue, ghostty discussion, it seems unlikely to be solved soon) for implementing xdg-activation based window swallowing which is particularly useful for terminals.

@PolyMeilex PolyMeilex merged commit c24b431 into Smithay:master Feb 24, 2025
13 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants