-
Couldn't load subscription status.
- Fork 1.1k
Add *Locks as a separate modifiers #4244
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
base: master
Are you sure you want to change the base?
Conversation
|
Are there any other modifiers from the spec that are missing? If so, we should just add all of them at this point. Before we move further with those keyboard related PRs, @madsmtm what's the status of Though, I guess those won't conflict. |
|
Oh, I'd like to add everything and more (since the spec is limited), but I didn't since I had no way for immediately testing it. https://w3c.github.io/uievents-key/#keys-modifier It's missing 4 keys from the spec:
(and it seems those don't even have any VKs on Windows, so can't test anything here, you'd have to us scan codes for these keys if they existed, but that would be hardware-dependent?) Do you know of any Windows/Mac virtual keyboard app that can simulate those to check how Winit treats them? It's also missing 3 niche useful keys not in the spec (and these exist on some keyboards I think unlike the symbols key which per spec is on virtual keys):
If that's ok to just add those for completeness without platform impls, could do that. |
|
By the way, there is one big issue with My strong suggestion is instead of doubling down on this limited design to instead build a proper single side-aware foundation (and also add all the keys that aren't in the web spec) |
Whether those will have impl or not is a different matter, since we discuss the top-level API for those here. So I don't see a point in not adding those just a variants even though, they are never built by backends provided by winit for now. macOS does have
No one really stops to put it along the way, since modifiers are generally not side awere and e.g. on some backends you have no way to know that information at all, so the way web spec does it is reasonable. Some modifiers are not side aware as well, like |
|
Ok, will add all those extra without test impls
Well, fundamentally they always are since they're always driven by real/virtual keys that can be referenced with side-awareness, it's just that you're right, sometimes that information is lost when it comes to Winit, but...
This is not a blocker
It's not reasonable to destroy valuable info. This makes shortcuts wasteful. For example, you have two best key locations - thumb keys - 50% wasted since they're by default treated as a single side-agnostic mod Alt (Win) Cmd(Mac).
That's fine, I'm not suggesting we make up imaginary sides where none ever existed, so it will be a single CapsLock bitflag (and only 2 paired L/RShifts)
But that's a waste, this is artificial separation that makes the APIs more complicated/confusing
You're almost using one yourself :)! From another issue you mentioned that your right alt is a composable symbols key, that's almost side awareness! Only in your case you need to have a special OS feature / app. But in a better world you could have that encoded in your RAlt+X keyboard layout layer and than your RAlt+X would insert a symbol from your keyboard layout instead of activating Alt+X shortcut.
I'm using a few myself, but fundamentally this is a chicken&egg issue. Since almost everywhere the defaults are side-agnostically bad and either hard/impossible to fix, you don't see many uses. That's the benefit of having a simpler API so that it's not harder to do the right thing |
it's IME/compose it's a bit different beast, since you have input that you can cancel, I'm not typing like 1 char with those, more like those:
The point is that when this is a common modifier API that may suggest that those are generally should be present. However side aware information is generally very limited, like on Wayland I have no idea how you'd get it for example in a reliable way, like my keyboard for example has 2 left shifts(for reasons, but I still have shift + shift binding possible, because the way how modifiers are applied). Like having a separate location for extra info, because this information is generally limited to only some OS and shouldn't be relied on, sounds sane to me. |
|
Yeah, I know, we've discussed this difference between your compose and AltGr-like -modifier input, IMEs are built "on top" of regular layouts, I was just traslating how that extra layer could behave at the base with side-awareness. |
Sure, but we have a rather bad example of that is macOS if you want that sort of side awareness, where you don't have |
Maybe Winit could have a config to treat right alt as AltGr?
Sure, and that's the reason why on Windows some people change RAlt to ROya. But afaik Mac layout simply doesn't support it! So messy beats impossible... |
We have that just for macOS, yes. Messy compared to anything else. |
This is currently not true with Winit, lshift_state/rshift_state IS a common modifier API, it's right there in the core https://docs.rs/winit/latest/winit/event/struct.Modifiers.html and is MORE accessible than the side-agnostic state which requires separate
Well, how limited is it? On Windows it's present (including sticky) except for both keys pressed. On a Mac it's mostly present except for sticky mods.
Ok, so there you would continue to only use the side-agnostic API
But what's the logical layout like? Does your layout have 2 VK_LShifts (whatever is vk equivalent on Wayland)? If so, then from the logical modifier perspective these are identical, so this is not an issue for a side-aware modifiers API.
But this doesn't change, you can continue to have the same side-agnostic |
Is this the OptionAsAlt config (a bit of a misnomer since on some physical mac keyboars option IS labeled as Alt)? Maybe could use the new AltGr and become OptionAsAltGraph :)
But what is "anything else"? The different modifier is not supported in the layout, andif your keyboard can't replace RAlt with a different mod, and your app doesn't want to care about Alt sides, what else is there? |
On Wayland/X11 you don't have modifier event when you already have e.g.
It's
The point is that macOS is |
f5f9c21 to
eb7a4dd
Compare
|
Added all 7 extra mods and implemented in Windows whatever had VKs and could be mapped in a layout to test |
That's the same issue with Windows "except for both keys pressed".
This seems to be different since on Mac/Win you can (in common cases) reliably check for the state in a side-aware manner (on Win by checking mod key state, on Mac by checking event flags)
I understand that Option=Alt acts like AltGr, but API-wise it's still set as Alt modifierstate/modifierkey, right? I mean, there is currently simply no AltGr modifier in the types. And I've added only one without side separation. But if you realy meant that mac's Alts by default should be treated as AltGrs unless you set some special config (default Maybe this illustration would help: let's say in your app you've defined
That's a great Mac part! On Win laptops that's usually a wasted key |
e5d836d to
f080cf8
Compare
f080cf8 to
37224d2
Compare
Added support for using CapsLock,NumLock, ScrollLock, Fn, FnLock, KanaLock, Loya, Roya, Symbol, SymbolLock as separate modifiers.
Implemented state update on Windows for CapsLock,NumLock, ScrollLock, KanaLock, Loya, Roya. Don't know how to add the others as they don't even have VKs
(while l/roya seem idential to L/Rshift, there is no Oya state unlike with Shift, so each is added separately to the supposedly side-agnostic "state") src
changelogmodule if knowledge of this change could be valuable to usersOn top of previous modifiers changes #4237 to have fewer conflicts and use existing example app
Partially addresses #1426