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: add options to make it more strict #2527

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

Conversation

dkondor
Copy link
Contributor

@dkondor dkondor commented Nov 29, 2024

This adds three options to configure xdg-activation and allow more strict behavior. These include:

  • reject requests without a view supplied (disabled by default)
  • only allow activating with the last issued token (disabled by default)
  • set the timeout used by wlroots (default: 30s, which is also used by wlroots)

Currently, wlroots already rejects token creation if the client supplied a wl_surface which is not focused. However, if there is no surface, creating a token always succeeds, basically allowing any app to focus itself (e.g. using gtk_window_present() which falls back to self-generated tokens with no surface if none is available in the environment). This can be a good thing e.g. when interacting with already running apps from the terminal, but can lead to unexpected focus changes as well. With this PR, this behavior can be changed according to individual preferences.

A small test program is here: https://github.com/dkondor/xdg_activation_test -- it is a case of a parent passing tokens to a child process. Without this PR, all three cases in it always work. With the new, restrictive options enabled, only the first case works.

Note that this still does not do full focus stealing prevention, for that, we would need to keep track if the surface that requested the token loses focus. I would consider looking into that next if there is interest.

If this gets merged, I'm happy to add some notes to the Wiki on the options (and also on xdg-activation more generally).

These allow:
 - reject requests without a view supplied
 - only allow activating with the last issued token
Both are disabled by default.

Also added an option to control the timeout used by wlroots for invalidating tokens.
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