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

input: add Super as alternative for Mod4 #8085

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

Ferdi265
Copy link
Contributor

@Ferdi265 Ferdi265 commented Mar 23, 2024

This PR implements alternative human-readable names for the logo key (Mod4) as proposed in #8084.

Implemented in this PR are the names "Super", "Meta", and "Logo".

This is the first time the supported modifier names have been touched since #153, almost 9 years ago (besides moving the code around into different files and switching from wlc to wlroots).

@emersion
Copy link
Member

I'd be fine with adding a more user-friendly name, but would prefer not to add a whole bunch of aliases that mean the same thing. My preference would be to follow the libxkbcommon naming here.

Also this needs a man page update as well.

@Ferdi265
Copy link
Contributor Author

Right. So just "Logo", plus documentation updates IIUC.

I expected this and I'm fine with any of these, I mostly made this PR so broad so all options are on the table.

Will adjust accordingly.

@Ferdi265
Copy link
Contributor Author

updated to allow only "Logo" instead of "Super", "Meta", and "Logo".

I haven't found any explanation of modifier names in the man pages except a few examples. Would you accept a separate PR adding such a section that explains all of the supported modifier names or would you like this to be done in this PR? Should we update examples in the man pages or config to use symbolic names where possible?

(The branch name doesn't fit any more, but that's on me, and renaming a branch while keeping the PR attached doesn't work IIRC, so so be it.)

@Ferdi265
Copy link
Contributor Author

Ferdi265 commented Mar 24, 2024

ahh, sorry, I was confused by <xkbcommon-names.h> calling the key "LOGO", while the rest of xkbcommon seems to call it Super or Meta (notably, here and here). I'm not 100% sure which one to take.

I'm leaving this choice to you. I'm fine with either of them, so please tell me which one you prefer.

(also, changing this to Super for now, which seems to be the recommended choice for Mod4 according to here)

@Ferdi265
Copy link
Contributor Author

Ferdi265 commented Mar 24, 2024

Modifier documentation is now in branch feature-modifier-docs. I added it to the documentation for bindsym, which is the only place I found that explicitly talks about XKB keysyms with regards to keybindings.

I also noticed that AltGr is also missing a human readable alias, so I added that in feature-altgr-modifier. Not sure if the sway project wants/needs that as well, but it's there if needed. Let me know and I will make a PR.

@Ferdi265 Ferdi265 changed the title input: add Super, Meta, and Logo as alternatives for Mod4 input: add Super as alternatives for Mod4 Mar 24, 2024
@Ferdi265 Ferdi265 changed the title input: add Super as alternatives for Mod4 input: add Super as alternative for Mod4 Mar 24, 2024
@rpigott
Copy link
Member

rpigott commented Mar 25, 2024

Is there a way we can just get the virtual modifier names from the keymap to alias their real modifiers? That would basically implement this then, right?

@emersion
Copy link
Member

Is there a way we can just get the virtual modifier names from the keymap to alias their real modifiers? That would basically implement this then, right?

You mean xkb_keymap_mod_get_name()? This returns the names used by XKB_MOD_NAME_* and we already have these listed.

I haven't found any explanation of modifier names in the man pages except a few examples. Would you accept a separate PR adding such a section that explains all of the supported modifier names or would you like this to be done in this PR? Should we update examples in the man pages or config to use symbolic names where possible?

Oh, sorry, I thought we had these documented already but it doesn't seem like it. Either is fine!

@Ferdi265
Copy link
Contributor Author

I haven't found any explanation of modifier names in the man pages except a few examples. Would you accept a separate PR adding such a section that explains all of the supported modifier names or would you like this to be done in this PR? Should we update examples in the man pages or config to use symbolic names where possible?

Oh, sorry, I thought we had these documented already but it doesn't seem like it. Either is fine!

I made a new PR documenting the existing modifiers (#8087) and rebased this one on top of that in addition to documenting the Super modifier here.

Intended merge order is #8087 followed by #8085 (this PR).

@rpigott
Copy link
Member

rpigott commented Mar 25, 2024

Super, Meta, etc. are virtual modifier names. They're at least present in the (standard US) keymap I can extract from xwayland, along with their real modifier associations. So, IIUC, it is possible by manual inspection of the keymap to map those names uniquely to real modifiers (Mod1, Mod4). I don't see any xkbcommon api related to virtual modifiers though, so maybe I haven't fully understood their purpose.

@emersion
Copy link
Member

@Ferdi265
Copy link
Contributor Author

Ferdi265 commented Mar 25, 2024

Yeah, I can see e.g. "Super" defined here:

* https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/022c3ca1db12e505cbd5ce8bf19c432d6a70c7e5/types/pc#L22

* https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/022c3ca1db12e505cbd5ce8bf19c432d6a70c7e5/compat/misc#L56

But yeah, I don't see any way to extract this string from the XKB API.

xkb_keymap_num_mods(keymap) returns the number of modifiers and with de and us I see the virtual modifier names from xkb_keymap_mod_get_name(keymap, index) starting at modifier index 8. I don't know how to get the mappings to real modifiers though.

@rpigott
Copy link
Member

rpigott commented Mar 25, 2024

Seems like XKB (OG X Keyboard Extension) had something like this [1][2]

[1] https://man.archlinux.org/man/XkbGetVirtualMods.3
[2] https://man.archlinux.org/man/XkbVirtualModsToReal.3

@Ferdi265
Copy link
Contributor Author

rebased since #8087 was merged

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Thanks!

@emersion emersion merged commit bc258a3 into swaywm:master Apr 5, 2024
3 checks passed
@Ferdi265 Ferdi265 deleted the feature-super-modifier branch April 6, 2024 22:48
@WhyNotHugo
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants