Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upText input is hard-wired to QWERTY #4144
Comments
|
With GLFW, we’re currently using glutin similarly has both |
|
Yes, moving to CharEvent is generally desirable, but IIRC there were some downsides (like the lack of separate press and release events, I believe). |
|
Is press/release relevant to text input? Repeating a character on long press is also up to the OS, I believe. And this is only forming the text of text input, I don’t mean that all |
|
Right, I spent a while looking into this back after I first wrote the text input code. The current implementation uses the keypress DOM event to trigger text input actions (as dictated by the spec). However, this event comes between the keydown and keyup events, all of which must share the same key code values. It made sense to base all of this off of GLFW's |
|
Ok, I just spent some time looking at https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys and yeah, it’s complicated. I think that the So maybe we need the windowing toolkit to give both pieces of information together rather than as separate events? |
|
That would be ideal, yes. |
|
Once glutin is default on all platforms, and we remove GLFW, I'll revisit this and made modifications to glutin as required to support what we need. |
|
@glennw Now that glutin is default, perhaps the time has come to at least document here what we should be doing. |
|
This also applies to for example zooming. With a German keyboard layout, I cannot zoom out, since my |
|
Can someone explain what needs to be done here? |
|
@paulrouget I think we want to handle @glennw You said you wanted to do this? :) |
|
@SimonSapin can we save the character received in We could probably reuse servo/components/script/dom/keyboardevent.rs Line 325 in fb3fe3d |
|
@paulrouget I think this would only work for ASCII at best. Most Unicode characters don’t have a corresponding key code. |
|
Right.
Then, the Then the input can be fed with the charcode. |
|
I was just speculating about |
|
@paul, it sounds like you’re hitting glutin bugs. Could you file steps to reproduce on https://github.com/tomaka/glutin/issues ? |
|
So we need to bring the character down to textinput.rs. It should be enough to initialize the keyboard event with this character + virtual keycode. Keyboard events are initialized with the help of the servo/components/script/dom/keyboardevent.rs Line 114 in 4c4df37 Here, relevant properties are set. From what I understand:
I managed to bring the character value to this function (see https://gist.github.com/paulrouget/668c3dcdb7dbfed7909a). But then I'm having troubles with strings.
What is the appropriate type? Can someone tell me if all of that makes sense? |
How would this be done? Shouldn’t we rather bring both kinds of events separately to |
|
@paul I don't understand your questions about |
|
Erf, I meant |
We could. I am assuming that there's always a
I'm not sure glutin supports that. ReceivedCharacter is only one char. If we want to support complex input methods (IME), we need to support composition events. My approach is just a quick-and-dirty way to support azerty layout (we have developers who use this layout, and the hardcoded qwerty-layout is a bit annoying for them :) ). IME and composition events support is a lot of work I imagine. Is that a thing we are willing to work on soon? If not, is it ok to implement my suggested approach of forwarding the character to |
|
Apparently, this is not an issue on Linux. |
|
It was for me on January, 2nd. |
Oh, I thought @mbrubeck could type with dvorak on Linux. |
|
Yes, everything seems fine on my Linux laptop using X11 with a Dvorak keymap. |
|
On Windows, quite a few ASCII key events (e.g. :~@;'# ) aren't assigned virtual key codes in glutin (See rust-windowing/glutin#744 ). Servo currently ignores all key events which don't have a virtual key code: Line 199 in 84d3ba0 Should I file a separate bug for this problem, or will the work here address this? |
|
Also, from glancing at the glutin code, X11 virtual key codes are much more specific than Windows / OS X / Wayland(?) - which might explain why some keymaps are OK and some aren't. X11: https://github.com/tomaka/glutin/blob/master/src/api/x11/events.rs#L5 |
|
Yes, X11 and Wayland both use libxcbcommon now, which has "keycodes" which are independent of the labels on the keyboard, and "keysyms" that take the layout into account. The glutin code uses keysyms for its key events. This is still not sufficient for a fully featured text field though - IME's currently don't work at all, meaning no CJK text input. |
|
@SimonSapin mentioned he might have a look at this. |
|
If we ever want to release a developer review of servo+bhtml, we need to do something about this issue. But there's probably a way to improve the situation, like using P3 -> P1 |
Support non-QWERTY keyboards Using the ReceivedCharacter event from glutin, we can obtain the actual key characters that the user is pressing and releasing. This gets passed to the script thread along with the physical key data, since KeyboardEvent needs both pieces of information, where they get merged into a single logical key that gets processed by clients like TextInput without any special changes. Tested by switching my macbook keyboard to dvorak and looking at the output of keypress/keyup/keydown event listeners, as well as playing with tests/html/textarea.html. Non-content keybindings like reload work as expected, too - the remapped keybinding triggers the reload action. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #4144 - [X] These changes do not require tests because I can't think of a way to test remapped keyboard input Fixes #11991. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11950) <!-- Reviewable:end -->
Support non-QWERTY keyboards Using the ReceivedCharacter event from glutin, we can obtain the actual key characters that the user is pressing and releasing. This gets passed to the script thread along with the physical key data, since KeyboardEvent needs both pieces of information, where they get merged into a single logical key that gets processed by clients like TextInput without any special changes. Tested by switching my macbook keyboard to dvorak and looking at the output of keypress/keyup/keydown event listeners, as well as playing with tests/html/textarea.html. Non-content keybindings like reload work as expected, too - the remapped keybinding triggers the reload action. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #4144 - [X] These changes do not require tests because I can't think of a way to test remapped keyboard input Fixes #11991. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11950) <!-- Reviewable:end -->
Support non-QWERTY keyboards Using the ReceivedCharacter event from glutin, we can obtain the actual key characters that the user is pressing and releasing. This gets passed to the script thread along with the physical key data, since KeyboardEvent needs both pieces of information, where they get merged into a single logical key that gets processed by clients like TextInput without any special changes. Tested by switching my macbook keyboard to dvorak and looking at the output of keypress/keyup/keydown event listeners, as well as playing with tests/html/textarea.html. Non-content keybindings like reload work as expected, too - the remapped keybinding triggers the reload action. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #4144 - [X] These changes do not require tests because I can't think of a way to test remapped keyboard input Fixes #11991. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11950) <!-- Reviewable:end -->
It seems that Servo receives keyboard event based on physical keys, and has its own interpretation of how to map they to text which assumes a QWERTY keyboard.
The fix is not to add support for more keyboard layouts. Servo should not be in the business of maintaining a repository of all keyboard layouts in the world, this is the job of the operating system. Servo should have the operating system give it Unicode text in a way that supports whatever input method (a.k.a. IME) the operating system may or may not have.
CC @jdm