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

bindings: Do not grab pointer when executing bindings #5755

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

orestisfl
Copy link
Member

Grabing the pointer produces a GrabFrozen error in applications that are run from key bindings. Since we don't need the pointer in such cases, we can change the call to use ASYNC. This seems to be a historical leftover.

I've tested locally that these still work:

  • bindsym $mod+x ...
  • bindsym --release $mod+x ...
  • bindsym $mod+button1 ...
  • bindsym --release $mod+button1 ...
  • bindsym --release $mod+x exec program that grabs the keyboard now works (see original issue)

Even in the main branch, I actually couldn't get import and xdotool to fail with the pointer being frozen, potentially because these programs wait a bit for the pointer to be unfrozen like i3lock does.

This patch came up in
#5735 (comment)

I wonder why the pointer is actually grabbed.

The argument I change in xcb_grab_key there, is pointer_mode, from https://www.x.org/releases/X11R7.7/doc/man/man3/xcb_grab_key.3.xhtml:

pointer_mode

One of the following values:
XCB_GRAB_MODE_SYNC

The state of the keyboard appears to freeze: No further keyboard events are generated by the server until the grabbing client issues a releasing AllowEvents request or until the keyboard grab is released.

XCB_GRAB_MODE_ASYNC

Keyboard event processing continues normally.

I traced via git blame the usage of xcb_grab_key throughout 14 years of i3 development and it seems that pointer_mode was always set to XCB_GRAB_MODE_SYNC, going all the way back to
b664456.

Fixes #5735

Grabing the pointer produces a `GrabFrozen` error in applications that
are run from key bindings. Since we don't need the pointer in such
cases, we can change the call to use ASYNC. This seems to be a
historical leftover.

I've tested locally that these still work:
- bindsym $mod+x ...
- bindsym --release $mod+x ...
- bindsym $mod+button1 ...
- bindsym --release $mod+button1 ...
- bindsym --release $mod+x exec program that grabs the keyboard
  now works (see original issue)

Even in the main branch, I actually couldn't get `import` and `xdotool`
to fail with the pointer being frozen, potentially because these
programs wait a bit for the pointer to be unfrozen like i3lock does.

This patch came up in
i3#5735 (comment)

I wonder why the pointer is actually grabbed.

The argument I change in `xcb_grab_key` there, is `pointer_mode`, from
https://www.x.org/releases/X11R7.7/doc/man/man3/xcb_grab_key.3.xhtml:
```
pointer_mode

One of the following values:
XCB_GRAB_MODE_SYNC

The state of the keyboard appears to freeze: No further keyboard events are generated by the server until the grabbing client issues a releasing AllowEvents request or until the keyboard grab is released.

XCB_GRAB_MODE_ASYNC

Keyboard event processing continues normally.
```

I traced via `git blame` the usage of `xcb_grab_key` throughout 14 years
of i3 development and it seems that `pointer_mode` was always set to
`XCB_GRAB_MODE_SYNC`, going all the way back to
b664456.

Fixes i3#5735
@orestisfl orestisfl self-assigned this Nov 4, 2023
@orestisfl
Copy link
Member Author

CC @MikuChan03

@MikuChan03
Copy link

Thank!

@stapelberg stapelberg merged commit b42dc21 into i3:next Nov 5, 2023
3 checks passed
@stapelberg stapelberg deleted the async-pointer branch November 5, 2023 10:04
desmana pushed a commit to desmana/i3 that referenced this pull request Apr 3, 2024
Grabing the pointer produces a `GrabFrozen` error in applications that
are run from key bindings. Since we don't need the pointer in such
cases, we can change the call to use ASYNC. This seems to be a
historical leftover.

I've tested locally that these still work:
- bindsym $mod+x ...
- bindsym --release $mod+x ...
- bindsym $mod+button1 ...
- bindsym --release $mod+button1 ...
- bindsym --release $mod+x exec program that grabs the keyboard
  now works (see original issue)

Even in the main branch, I actually couldn't get `import` and `xdotool`
to fail with the pointer being frozen, potentially because these
programs wait a bit for the pointer to be unfrozen like i3lock does.

This patch came up in
i3#5735 (comment)

I wonder why the pointer is actually grabbed.

The argument I change in `xcb_grab_key` there, is `pointer_mode`, from
https://www.x.org/releases/X11R7.7/doc/man/man3/xcb_grab_key.3.xhtml:
```
pointer_mode

One of the following values:
XCB_GRAB_MODE_SYNC

The state of the keyboard appears to freeze: No further keyboard events are generated by the server until the grabbing client issues a releasing AllowEvents request or until the keyboard grab is released.

XCB_GRAB_MODE_ASYNC

Keyboard event processing continues normally.
```

I traced via `git blame` the usage of `xcb_grab_key` throughout 14 years
of i3 development and it seems that `pointer_mode` was always set to
`XCB_GRAB_MODE_SYNC`, going all the way back to
b664456.

Fixes i3#5735
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.

The pointer is grabbed after executing a hotkey
3 participants