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

X.{A.{{Grid,Tree}Select,Submap},Prompt}: KeyPress handling fixes #686

Merged
merged 4 commits into from
Feb 13, 2022

Conversation

liskin
Copy link
Member

@liskin liskin commented Feb 10, 2022

Description

This is a cleaned up version of #590 which additionally addresses #290 (I believe nobody really depends on the XKB and mouse state not being stripped so it's okay to change behaviour) and xmonad/xmonad#172 (this needs xmonad/xmonad#374).

Original description from #590 follows:

This changes makeXEventhandler to behave much closer to how xmonad itself handles keypresses. The primary difference lies in that xmonad reads raw keycode and then converts it to unmodified keysym, while makeXEventhandler was reading actual keysyms. As a consequence, key definitions like (shiftMap, xK_Tab) didn't work with makeXEventhandler on many layouts because an actual keysym for 'Shift+Tab' is commonly ISO_LEFT_TAB, and not Tab.

Additionally, the mask is stripped of its high bits, because apparently X likes to encode current layout group information in bits 13 and up, and we don't really want our control keys to depend on the current layout group. Please let me know if there is a better way to handle this.

One thing to consider: if we are concerned that unconditionally stripping XKB and mouse state might break someone's workflow, we'll need to make this configurable, and then we'll need to move cleanKeyMask out of X.Prelude as we can't import X.U.ExtensibleConf.

Checklist

  • I've read CONTRIBUTING.md

  • I've considered how to best test these changes (property, unit, manually, ...) and concluded: I manually tested TreeSelect and Prompt and haven't found any breakage.

  • I updated the CHANGES.md file

liskin and others added 4 commits February 9, 2022 23:53
We didn't clean XKB group bits out of the KeyPress events' state so key
bindings only worked in the primary keyboard layout (first XKB group).
To fix this, this adds a `cleanKeyMask` function to X.Prelude which is
analogous to `cleanMask` but aimed at cleaning regular KeyPress states
(as opposed to just KeyPresses from passive key grabs), and this is then
used instead of `cleanMask`.

Related: xmonad#290
Related: xmonad#590
This replaces the custom `cleanMask` extension in these modules—which
only filtered out XKB group bits and Button5Mask¹—with the new
`cleanKeyMask` which additionally filters out all mouse buttons, as
these aren't relevant for key bindings.

¹) Filtering out Button5Mask was probably an off-by-one mistake.

Fixes: xmonad#290
Related: xmonad#590
…imilar

This changes KeyPress handling in these modules to behave much closer to
how xmonad core itself handles keypresses. The primary difference lies
in that xmonad reads raw KeyCode and then converts it to unmodified
KeySym, while these modules used `lookupString` to find the actual
keysyms. As a consequence, key definitions like `(shiftMap, xK_Tab)`
didn't work on many layouts because an actual KeySym for `Shift-Tab` is
commonly `ISO_LEFT_TAB`, and not `Tab`.

Closes: xmonad#590
Co-authored-by: Tomas Janousek <[email protected]>
Copy link
Member

@slotThe slotThe left a comment

Choose a reason for hiding this comment

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

Compiles and doesn't seem to break the prompt for me and the code also looks reasonable, so LGTM!

One thing to consider: if we are concerned that unconditionally stripping XKB and mouse state might break someone's workflow, we'll need to make this configurable, and then we'll need to move cleanKeyMask out of X.Prelude as we can't import X.U.ExtensibleConf.

Reminds me a bit of this—probably not going to be a problem :)

@liskin liskin merged commit 493b6ad into xmonad:master Feb 13, 2022
@liskin liskin deleted the keypress-fixes branch February 13, 2022 10:22
@liskin
Copy link
Member Author

liskin commented Feb 13, 2022

(merged without the stripModMask bit which has a separate PR now: #687)

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.

3 participants