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

_NET_ACTIVE_WINDOW: invalidate focus to force SetInputFocus call #3027

Merged
merged 1 commit into from Oct 22, 2017

Conversation

stapelberg
Copy link
Member

The sender of the _NET_ACTIVE_WINDOW client message might know better when to
set focus than i3, as i3 does not know about unmanaged (override_redirect=1)
windows.

related to i3/i3lock#35

The sender of the _NET_ACTIVE_WINDOW client message might know better when to
set focus than i3, as i3 does not know about unmanaged (override_redirect=1)
windows.

related to i3/i3lock#35
stapelberg added a commit to stapelberg/i3lock that referenced this pull request Oct 22, 2017
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, effectively force-closing any open
   context menus (tested with Google Chrome).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes i3#35
@Airblader
Copy link
Member

I don't understand this change. This path is never reached for unmanaged windows?

@stapelberg
Copy link
Member Author

Correct, and it doesn’t need to be. In i3lock, we’re using the _NET_ACTIVE_WINDOW ClientMessage on the managed window which had focus before i3lock took it. Without this change, though, i3 won’t send a SetInputFocus request, because it didn’t notice the focus changes by the unmanaged window.

@Airblader
Copy link
Member

IMHO we are supporting broken client behavior with this change, just that in this case the broken client is i3lock. The reason we need this change is because the client caused us to be out of sync. Wouldn't a correct fix to avoid running out of sync, e.g., by processing FocusOut events? Openbox seems to do this, but unfortunately it is rather involved since one has to coordinate with FocusIn events.

But I think I've already lost the argument that we are turning i3lock into a broken client, so let's move on. At the very least the one positive thing about this change is that it's a safety net for when the request originates not from the broken client, but somewhere else.

stapelberg added a commit to stapelberg/i3lock that referenced this pull request Oct 22, 2017
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, effectively force-closing any open
   context menus (tested with Google Chrome).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes i3#35
@stapelberg
Copy link
Member Author

IIUC, maintaining sync would result in 1 fewer force-focus at the expense of more complicated code paths. If it turns out that this 1 force-focus is a problem, we can always switch to the maintain-sync approach :).

stapelberg added a commit to stapelberg/i3lock that referenced this pull request Oct 22, 2017
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, effectively force-closing any open
   context menus (tested with Google Chrome).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes i3#35
stapelberg added a commit to stapelberg/i3lock that referenced this pull request Oct 22, 2017
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, thereby possibly force-closing
   open context menus (works with e.g. Google Chrome, does not work with
   e.g. thunar, gedit).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes i3#35
@stapelberg stapelberg merged commit 4f75161 into i3:next Oct 22, 2017
@stapelberg stapelberg deleted the activate branch October 22, 2017 20:16
stapelberg added a commit to i3/i3lock that referenced this pull request Oct 22, 2017
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, thereby possibly force-closing
   open context menus (works with e.g. Google Chrome, does not work with
   e.g. thunar, gedit).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes #35
Hedroed pushed a commit to Hedroed/i3lock that referenced this pull request Nov 23, 2021
When grabbing the pointer/keyboard fails, a new code path is activated, which:

1. Uses the standards-compliant _NET_ACTIVE_WINDOW root window property to
   determine the window to restore focus to.

2. Sets the input focus to the i3lock window, thereby possibly force-closing
   open context menus (works with e.g. Google Chrome, does not work with
   e.g. thunar, gedit).

3. Upon exiting, restores focus to the window from step ① by sending a
   _NET_ACTIVE_WINDOW ClientMessage to the root window. Note that this step
   requires i3/i3#3027 in i3 to not mess up focus.

fixes i3#35
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.

None yet

2 participants