-
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 2) #512
Support querying whether virtual modifiers are active (alternative 2) #512
Conversation
946ec04
to
06597bd
Compare
TODO: more tests, with all modifiers. We want this to be 100% reliable, with no breaking changes in the known and foreseen uses. |
06597bd
to
700d0a7
Compare
9d79bb6
to
3d6eb0b
Compare
3d6eb0b
to
e278b15
Compare
We should probably deprecate the following in favor of the new names:
|
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.
I think this LGTM though admittedly I haven't managed to page everything back in in detail. Two nitpicks, otherwise 👍
172830b
to
3646804
Compare
Respect the claim that real modifiers names are built-in: - Add `XKB_MOD_NAME_MOD[1-5]` constants. - Replace modifiers names with their corresponding constants.
Added support for the following virtual modifiers: - `Alt` - `Meta` - `NumLock` - `Super` - `Hyper` - `LevelThree` - `LevelFive` - `ScrollLock`
3646804
to
9032f10
Compare
Added support for |
I do not see other functions requiring changes. |
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.
It will be very cool if we can make this work.
I only did a very shallow skim of the code. I too have mostly forgotten the details unfortunately. Some questions:
-
Is the overmatching possibility fundamental to the way virtual modifiers work, or is it possible to rework the internals such that they track particular vmods?
-
Does this work for xkbcommon-x11?
-
In practice, I think most users ignore the
is_active
functions and just usexkb_state_serialize_mods
, despite it being documented as for serialization only. Unfortunate, and maybe it has changed by now, but probably not, since people always take the path of least resistance. The question is -- is there anything we can do about it?
@bluetech Unfortunately it’s fundamental, at least until #450 is merged. Here some examples:
In practice, 1) is already an issue so DE and apps handle it already. 2) is probably extremely rare and more due to an accident. The only use I know is to differentiate left and right variant of a modifier.
Yes, AFAICT: in the end we rely on the real modifiers. It will start to change when #450 is merged.
That is a good question! State and its value are supposed to be opaque, as stated by Daniel in this Wayland issue. This may change, but apps working on states values directly expose themselves to bugs. Do you have some examples in mind? More probably they replicate the logic, like KDE KWin. Anyway, if they work directly with the state mod masks they must already work with real modifiers and I did not change the state representation/serialization with the current MR. Again, what is a real modifier will change when #450 get merged: we will have to distinguish X11 and non-X11 real modifiers, because “pure” virtual modifiers as stated in #450 are in fact non-X11 real modifiers. So, until this Wayland issue declare the contrary, the only thing we can do about it is to document that the state values should only be processed by the xkbcommon API. |
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 both “Alt” and “Meta” to the real modifier “Mod1”; thus “Mod1”, “Alt” and “Meta” modifiers will return the same result with these functions.
Previously it was not possible to query the status of virtual modifiers with the following functions: - `xkb_state_mod_index_is_consumed` - `xkb_state_mod_index_is_consumed2` Note that it may *overmatch* if some modifier mappings overlap. For example, the default “us” PC layout maps both “Alt” and “Meta” to the real modifier “Mod1”; thus “Mod1”, “Alt” and “Meta” modifiers will return the same result with these functions.
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.
Updated according to @bluetech review.
ad0b6cb
to
fe78832
Compare
Allow to query also virtual modifiers with the following functions, so they work with any modifiers (real and virtual):
xkb_state_mod_index_is_active
xkb_state_mod_indices_are_active
xkb_state_mod_name_is_active
xkb_state_mod_names_are_active
xkb_state_mod_index_is_consumed
xkb_state_mod_index_is_consumed2
Warning: they may overmatch in case there are overlappings virtual-to-real
modifiers mappings.
Also added the following modifiers names definitions in
xkbcommon-names.h
:XKB_MOD_NAME_MOD1
XKB_MOD_NAME_MOD2
XKB_MOD_NAME_MOD3
XKB_MOD_NAME_MOD4
XKB_MOD_NAME_MOD5
XKB_VMOD_NAME_ALT
XKB_VMOD_NAME_META
XKB_VMOD_NAME_NUM
XKB_VMOD_NAME_SUPER
XKB_VMOD_NAME_HYPER
XKB_VMOD_NAME_LEVEL3
XKB_VMOD_NAME_LEVEL5
XKB_VMOD_NAME_SCROLL
This is a simplier version of #353, which is also an alternative to #36.
This is necessary to implement fully #450.
Fixes #88