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

Fix focus handling (attempt 2) #154

Closed
wants to merge 19 commits into from
Closed

Conversation

iacore
Copy link

@iacore iacore commented Apr 1, 2022

This resolves most focus-related issues.

@iacore iacore changed the title Fix focus 2 Fix focus (attempt 2) Apr 1, 2022
@iacore iacore changed the title Fix focus (attempt 2) Fix focus handling (attempt 2) Apr 1, 2022
@iacore
Copy link
Author

iacore commented Jun 17, 2022

The client side is working. The server side still need some work. QubesOS/qubes-gui-daemon#98

@iacore
Copy link
Author

iacore commented Jun 20, 2022

I hope this is the last fix about window focus before wayland.

@iacore
Copy link
Author

iacore commented Jun 25, 2022

Before 1c5b880: consistently buggy (when VM intra-transfer focus)

After: sometimes window will lose keyboard focus (mouse works fine). Minimize->maximize won't fix the problem. Have to click desktop when window is showing to fix.

Solution: have VM report window focus to dom0 QubesOS/qubes-issues#7403

@iacore
Copy link
Author

iacore commented Jul 4, 2022

Remaining problems:

  1. Release all keys pressed after none of a VM's window is focused, like, 1 second after. (what keys are pressed could be tracked by dom0) By the time switched back, the VM should think all keys are released. Example: when VM think Ctrl + D is stuck, it close terminal immediately after you open one.
  2. Decide which window has decoration, that we should give focus implicitly.
    Focusing every X "window" on click is working... mostly, except for VS Code's context menu, or Firefox's context menu. Leafpad's context menu works fine though. You cannot click on context menu with that attempt, so I didn't add this behaviour.

// TODO: check if window is "top-level" (has border), and only focus if it or its child was not focused
// some applications get confused if you give focus to its context menu
// I'm not sure how this works yet
bool need_focus = false;
Copy link
Author

@iacore iacore Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Problem 2 mentioned.

If anyone know how to do this properly, please send pull request to my branch (fix-focus-2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows have decorations if and only if they are not override-redirect. Context menus can just be not given focus.

@DemiMarie
Copy link
Contributor

@locriacyber Would you mind splitting the PKGBUILD changes into a separate PR?

Remaining problems:

  1. Release all keys pressed after none of a VM's window is focused, like, 1 second after. (what keys are pressed could be tracked by dom0) By the time switched back, the VM should think all keys are released. Example: when VM think Ctrl + D is stuck, it close terminal immediately after you open one.
  2. Decide which window has decoration, that we should give focus implicitly.
    Focusing every X "window" on click is working... mostly, except for VS Code's context menu, or Firefox's context menu. Leafpad's context menu works fine though. You cannot click on context menu with that attempt, so I didn't add this behaviour.

Are these regressions, or are they problems with the current agent too?

@iacore
Copy link
Author

iacore commented Jul 6, 2022

They are new problems (recalling from memory, since I haven't use old agent for awhile).

Problem 1: Before this patch, key repeat was disabled in AppVM. Even if a key was stuck in AppVM, it won't generate stuff likeeeeeeeeeeeeeeeeee <- this.
Problem 2: I remember the old xside + vmside code send focus event to window on every click. I browsed the git history, but couldn't find a trace of the behavior "focus window on click".

@DemiMarie Can you try to reproduce this?

One way for you to reproduce problem 2 is (related: QubesOS/qubes-issues#7403)
In AppVM:

  • In xfce4-terminal, type open "http://localhost/" while Firefox is open
  • now Firefox should have focus, while Terminal is still on top of Firefox
  • since Terminal doesn't have focus, the cursor should become outlined rectangle (instead of solid when focused)
  • click anywhere in Terminal

It it was not buggy, the cursor should become solid, meaning Terminal has regained focus.

iacore added 2 commits July 9, 2022 04:07
This fixed the bug that the mouse remains grabbed when the focused window is killed with "Close Window" from XFCE
Seem to have less focus problem with this change
@iacore
Copy link
Author

iacore commented Aug 11, 2022

Superseded by #169

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.

2 participants