-
Notifications
You must be signed in to change notification settings - Fork 124
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
Support querying whether virtual modifiers are active (alternative with overlapping mods API) #353
Conversation
Thanks for looking into this @wismill. I'm not ready to do any review though, sorry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few nitpicks but this LGTM though I fully admit I'm not aware enough of the API to really make decisions on this.
I would like to see the evdev define commit as a separate PR though because that is one that we can merge at any time and it's almost independent of this one here.
#define XKB_MOD_NAME_GUI "Super" | ||
#define XKB_MOD_NAME_SUPER "Super" | ||
#define XKB_MOD_NAME_HYPER "Hyper" | ||
#define XKB_MOD_NAME_NUM "NumLock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I wonder if that and the ALT
/LOGO
changes are an API/ABI break...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They may be breaking changes in the case that the modifier mapping is different.
For Alt
, I found only 2 vendor layouts in xkeyboard-config which does not map to Mod1
:
symbols/fujitsu_vndr/us
symbols/hp_vndr/us
For NumLock
, I found only 2 vendor layouts in xkeyboard-config which does not map to Mod2
:
symbols/fujitsu_vndr/us
symbols/digital_vndr/pc
I did not find other mapping for Super
than Mod4
.
The other possible issue is when these modifiers are not even mapped! But with the base layout pc
they should be mapped by default.
Previously it was not possible to query the status of virtual modifiers with the following functions: - xkb_state_mod_index_is_active - xkb_state_mod_indices_are_active - xkb_state_mod_name_is_active - xkb_state_mod_names_are_active Note that it may overmatch if some modifier mappings overlap. For example, the default “us” PC layout maps “Alt” and “Meta” to the real modifier “Mod1”; thus “Mod1”, “Alt” and “Meta” modifiers will return the same result with these functions.
This new function enables: - Checking if a modifier overlaps with another one. xkb_keymap_mod_get_overlapping_mods(keymap, mod, XKB_MOD_OVERLAPPING_NON_CANONICAL) For example, it allows to check if `Alt` and `Meta` are distinct modifiers and act in consequence. - Get the mapping of a modifier xkb_keymap_mod_get_overlapping_mods(keymap, mod, XKB_MOD_OVERLAPPING_CANONICAL) - Check if a modifier is mapped. For example: xkb_keymap_mod_get_overlapping_mods(keymap, mod, XKB_MOD_OVERLAPPING_CANONICAL) would return 0 if the modifier mod is not mapped.
See #512 for a smaller version of this PR. |
#512 has been merged, closing. |
I would like to revive #36. I found some issues (see #36), so I used another implementation. It only lifts the restriction to real modifiers of some functions.
xkb_keymap_mod_get_overlapping_mods
API. It exposes the internal mapping of modifiers, but I use the term canonical to refer to real modifiers: having modifiers defined as a set of other modifiers does make sense, even if we drop the limitations of X11 real modifiers.