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

Refocus on application close is broken with focus stealing prevention #3694

Open
tarek-y-ismail opened this issue Dec 5, 2024 · 2 comments

Comments

@tarek-y-ismail
Copy link
Contributor

Related: #2586

Whenever a window is closed, it's expected that the window visually below it should become the one in focus. But at the moment with focus stealing prevention enabled, an incorrect surface (decoration?) is selected which cannot have focus. This requires the user to manually select the application they want via clicking (haven't tried alt+tab)

@AlanGriffiths
Copy link
Collaborator

I don't think focus stealing prevention is part of this. But as you don't provide a reproducer, it isn't clear whether this is the same thing:

  1. run miral-app
  2. Ctrl-Alt-T to start a terminal [gnome-terminal]
  3. From terminal start kgx [kgx#1]
  4. Ctrl-Shift-N for another kgx terminal [kgx#2]
  5. Rearrange windows in order [kgx#2], [gnome-terminal], [kgx#1]
  6. Close the top window [kgx#2]

Expect: [gnome-terminal] gets focus and order is [gnome-terminal], [kgx#1]
Actual: [kgx#1] gets focus and order is [kgx#1], [gnome-terminal]

@tarek-y-ismail
Copy link
Contributor Author

Oh, sorry for leaving that out.

  1. run miral-app with --focus-stealing="prevent"
  2. Launch multiple terminals.
  3. Close the focused (first) one via Ctrl+D

In mir on main, it will automatically focus the window underneath the one we just closed. In mir on control-new-window-placement-in-policies, focus is not properly set so you can't close all terminals by repeatedly pressing Ctrl+D.

Another scenario which might help pinpoint the issue:

  1. run miral-app with --focus-stealing="prevent"
  2. Launch multiple terminals.
  3. Click on each terminal just to set focus
  4. Click on the first one to focus it
  5. Close it with Ctrl+D

You'll notice that the the last window focused before the one you just closed is now focused. If you close it, the window before it, and so on.

github-merge-queue bot pushed a commit that referenced this issue Jan 20, 2025
Closes #2586.

Adds a new constructor to `FloatingWindowManagerPolicy` to control focus
stealing prevention. This in a nutshell stops new windows from being
focused and raised. When used with xdg-activation-v1, this improves
security as external actors can't just steal focus by opening a new
window (in addition to the niceties xdg-activation-v1 adds to
usability).

TODO:
- [ ] ~Fix window offsetting. This is built off the position of the
focused window, so all windows after the second one open in the same
(x,y) position.~
Split off to #3695
- [ ] ~Fix windows closing in the order of opening instead of front to
back. see
#3693 (comment)
Moved to #3694
- [ ] ~Make sure Xwayland applications work properly. My focus has been
on Wayland applications so far.~
Xwayland doesn't seem to support xdg-activation at the moment?
- [x] Alt + tab predictably broken :/
Have to focus other applications before they work with alt + tab
- [x] Decorations are not pushed behind the focused window
- [ ] ~Need some way to focus applications launched via Mir
(Ctrl-Alt+t/T for example)~
Will be in its own PR (#3703)
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

No branches or pull requests

2 participants