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

Support querying whether virtual modifiers are active (alternative with overlapping mods API) #353

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wismill
Copy link
Member

@wismill wismill commented Jun 30, 2023

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.

  • Doc to warn of possible over matching.
  • I am not satisfied with the 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.

@wismill wismill requested review from whot and bluetech June 30, 2023 11:51
@wismill wismill added enhancement Indicates new feature requests state Indicates a need for improvements or additions to the xkb_state API labels Jun 30, 2023
@bam80
Copy link

bam80 commented Jun 30, 2023

Thanks for looking into this @wismill. I'm not ready to do any review though, sorry.

@wismill wismill mentioned this pull request Jun 30, 2023
Copy link
Contributor

@whot whot left a 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.

src/state.c Outdated Show resolved Hide resolved
src/state.c Outdated Show resolved Hide resolved
src/state.c Outdated Show resolved Hide resolved
include/xkbcommon/xkbcommon-names.h Outdated Show resolved Hide resolved
#define XKB_MOD_NAME_GUI "Super"
#define XKB_MOD_NAME_SUPER "Super"
#define XKB_MOD_NAME_HYPER "Hyper"
#define XKB_MOD_NAME_NUM "NumLock"
Copy link
Contributor

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...

Copy link
Member Author

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.

include/xkbcommon/xkbcommon.h Outdated Show resolved Hide resolved
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.
@wismill
Copy link
Member Author

wismill commented Sep 23, 2024

See #512 for a smaller version of this PR.

@wismill wismill changed the title Support querying whether virtual modifiers are active (alternative) Support querying whether virtual modifiers are active (alternative with overlapping mods API) Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests state Indicates a need for improvements or additions to the xkb_state API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants