Repository navigation
ui: Use the caller's activation token when showing the dialog - #262
Merged
Merged
Conversation
The daemon already forwards the activation token from the portal request to the UI, but the UI dropped it. Pass it through to the GTK window with set_startup_id() before presenting it, so GTK hands it to the compositor (xdg_activation_v1.activate on Wayland). This lets the dialog take focus when the requesting window is in the background and the compositor would otherwise refuse it. Empty tokens are treated as no token. Closes linux-credentials#152.
iinuwa
approved these changes
Nov 13, 2026
Member
|
Thanks!
Yeah, we've got to go through and remove unwraps. We can probably just log and ignore, as the event loop on the receiver would just end and stop the program anyway. an issue or PR for this one is welcome! |
1 similar comment
Member
|
Thanks!
Yeah, we've got to go through and remove unwraps. We can probably just log and ignore, as the event loop on the receiver would just end and stop the program anyway. an issue or PR for this one is welcome! |
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #152.
The daemon already forwards the activation token from the portal request in
PortalBackendOptions.activation_token, but the UI never used it. This PR:activation_tokentoViewRequest. An empty string counts as no token.run_guiandstart_gtk_apptoCredentialsUi, next toparent_window.window.set_startup_id(&token)before the window is presented. On map, GTK passes the token togdk_toplevel_set_startup_id, which becomesxdg_activation_v1.activate(token, surface)on Wayland. The token is taken once, because activation tokens are single-use and each request creates a newCredentialsUianyway.Testing
I ran the dev
credentialsd-uiwithWAYLAND_DEBUG=1on Hyprland and sentCreateSessionfrom a small client:credsd-test-token-1, no parent: the log showsxdg_activation_v1.activate("credsd-test-token-1", wl_surface#44).wayland:parent handle:import_toplevel(...), thenactivate("credsd-test-token-2", ...). This is the path where the window is already realized beforeset_startup_id.cargo test -p credentialsd-ui(adds tests for passing the token through and for missing or empty tokens),cargo clippy,cargo fmt --check: clean.I didn't use a real token from a background caller window, so I haven't seen the compositor grant focus because of it.
On X11,
set_startup_idsets_NET_STARTUP_ID. That's harmless, but an xdg-activation token there won't help focus.Unrelated: a panic I hit while testing
If the caller disconnects right after
CreateSession(a one-shotbusctl call, for example), the request is cancelled before the window exists.credentialsd-uithen aborts atcredentialsd-ui/src/gui/view_model/gtk/mod.rs:121withcalled Result::unwrap() on an Err value: SendError(..), raised inside a function that cannot unwind. The bug is already on main, so I left it out of this PR. I can open an issue or a fix if you want.