Skip to content

Conversation

@eugenesvk
Copy link
Contributor

@eugenesvk eugenesvk commented May 22, 2025

Removes the confusing and inconsistent state vs pressed keys for modifiers and consolidates all into a single struct. See a more detailed overview of the suggestions #4236

Also implemented Display for winit_core::keyboard::Modifiers to print ‹⇧⎇ modifier combos, including an :# alternate notation to preserve modifier symbol positioning (for vertically-aligned formatting).

Also added a Primary convenience modifier alias to Ctrl on PC/Linux and Cmd on Mac since these serve the same functionality of "primary control", e.g., Cmd+O to open a file and Ctrl+O to do the same; to simplify setting up x-platform keybinds

It's based on top of all other modifier-related changes (#4244 + #4251 doc updates), so looks bigger as a standalone PR

Open questions:

  • To make setting existing keybinds easier in the same side-agnostic way, I've added an extra duplicated common mods like Shift in addition to Left/Right, but there was a concern about the extra bits Add location awarness to ModifiersChanged event on Windows #3611 (comment), so not sure whether it's worth it. If it's kept, then the bitflag values should be in triplets (would also maintain old values even though the types would change)?

  • I'm also not completely clear on Winit's treating of AltGraph and whether due to the fact that Mac's Alts behave like AltGraphs Winit should have Left/Right AltGraphs as well to reflect this (on Windows you can only have one artifical AltGraph, so you'd also only have 1 modifier). Add *Locks as a separate modifiers #4244 (comment)

  • ±Only Windows+Mac tested. Tested on all platforms changed

  • Added an entry to the changelog module if knowledge of this change could be valuable to users

  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior

  • Application (fixed modifier matching bug) and kbd_ev_print examples Created or updated an example program if it would help users understand this functionality

Closes #4236

eugenesvk added 3 commits May 23, 2025 17:25
only consider common shortcut-related mods, ignore numlocks etc
eugenesvk added 3 commits May 23, 2025 21:03
including alternate `:#` notation to print modifiers in a "fixed" position within an all-mod string
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.

Simplify and consolidate modifiers API

1 participant