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

Don't cancel grabs on Escape. #1126

Merged
merged 1 commit into from
Jan 17, 2025
Merged

Conversation

jneem
Copy link
Contributor

@jneem jneem commented Jan 10, 2025

fcitx5 (and maybe other input methods?) listen for the global input- switching shortcut by maintaining a constant keyboard grab: every time you change focus, they take a grab on the newly focused window. This interacts badly with cosmic-comp's previous behavior, where the first press of Escape after switching windows would always go towards cancelling that grab. This meant that

  • the first Escape on any newly-focused window wouldn't get delivered to the window, and
  • after pressing Escape on any window, fcitx would no longer listen to the input-switching shortcut.

This commit removes the grab-cancelling behavior altogether. Probably it breaks something, because I don't know what the original purpose was. It may be that the correct behavior depends on what kind of grab it is.

Fixes #680

@Drakulix
Copy link
Member

This commit removes the grab-cancelling behavior altogether. Probably it breaks something, because I don't know what the original purpose was. It may be that the correct behavior depends on what kind of grab it is.

The original purpose was to provide a global way to cancel grabs mostly for server-side grabs, where the compositor is responsible to allow the user to cancel without taking any action.

So a proper fix likely needs a way to check the type of the grab in smithay.

@jneem
Copy link
Contributor Author

jneem commented Jan 14, 2025

Thanks for the response!

So a proper fix likely needs a way to check the type of the grab in smithay.

It looks like some version of this is already possible, by calling Keyboard::with_grab and downcasting the grab object. I looked for grabs that cosmic-comp takes, and they seem to be only SwapWindowGrab and PopupKeyboardGrab. Would it be reasonable to cancel those two grabs on Escape, and ignore all others?

Another approach that would solve my issue is to cancel all grabs except InputMethodKeyboardGrab. It bothers me a bit that I don't know the "right" way to distinguish between keyboard grabs that should be cancelled on Escape and those that shouldn't...

@Drakulix
Copy link
Member

Thanks for the response!

So a proper fix likely needs a way to check the type of the grab in smithay.

It looks like some version of this is already possible, by calling Keyboard::with_grab and downcasting the grab object. I looked for grabs that cosmic-comp takes, and they seem to be only SwapWindowGrab and PopupKeyboardGrab. Would it be reasonable to cancel those two grabs on Escape, and ignore all others?

Another approach that would solve my issue is to cancel all grabs except InputMethodKeyboardGrab. It bothers me a bit that I don't know the "right" way to distinguish between keyboard grabs that should be cancelled on Escape and those that shouldn't...

I think the first approach is reasonable here, we can always extend this list, but given this was initially conceived for compositor-initiated grabs an allow-list seems like the right approach.

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this! Seems good to me now :)

@Drakulix Drakulix merged commit 3836670 into pop-os:master Jan 17, 2025
3 checks passed
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.

Missing first Esc keypress after a window is focused
2 participants