wayfire icon indicating copy to clipboard operation
wayfire copied to clipboard

xdg-activation: add focus stealing prevention when using tokens

Open dkondor opened this issue 9 months ago • 3 comments

Continuation of #2527

This implements focus stealing in a straightforward way by disallowing xdg-activation tokens if the view that generated them is not focused anymore. So this is about the case when the user switches to another view before a token is used.

dkondor avatar Apr 12 '25 14:04 dkondor

I am wondering how does this compare to https://github.com/WayfireWM/wayfire-plugins-extra/blob/master/src/focus-steal-prevent.cpp ?

ammen99 avatar Apr 12 '25 19:04 ammen99

This works based on xdg-activation and only tracks which view has focus. Mainly, it is to prevent the following scenario:

  1. User interacts with app A, which generates a token and passes it to app B
  2. App B is slow to use its token, the user switches to app C in the meantime
  3. Now app B uses the token to activate itself, which might be unexpected

In contrast, the plugin in wpe focuses on keyboard (if I understand correctly), to prevent taking focus while typing, regardless of whether the requesting app has a valid token or not. So I think these can complement each other, with this PR more focusing on users' attention and also reducing the cases that even trigger the fsp plugin in wpe.

dkondor avatar Apr 13 '25 10:04 dkondor

Marking it a draft, since I this prevents focusing also in some valid cases, especially when used in combination with #2627 and desktop components, specifically when launching apps / actions from a menu opened from a layer-shell panel (such as with https://github.com/WayfireWM/wf-shell/pull/293)

dkondor avatar Apr 13 '25 12:04 dkondor