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 upHandle KeyboardEvent without virtual key code #15800
Conversation
highfive
commented
Mar 2, 2017
highfive
commented
Mar 2, 2017
| Some(VirtualKeyCode::LAlt) => self.toggle_modifier(LEFT_ALT), | ||
| Some(VirtualKeyCode::RAlt) => self.toggle_modifier(RIGHT_ALT), | ||
| Some(VirtualKeyCode::LWin) => self.toggle_modifier(LEFT_SUPER), | ||
| Some(VirtualKeyCode::RWin) => self.toggle_modifier(RIGHT_SUPER), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
charlesvdv
Mar 2, 2017
Author
Contributor
This is the improvements because now we are handling correctly the case where virtual key code is None.
| @@ -345,16 +345,16 @@ impl Window { | |||
| self.pending_key_event_char.set(Some(ch)); | |||
| } | |||
| } | |||
| Event::KeyboardInput(element_state, scan_code, Some(virtual_key_code)) => { | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Mar 2, 2017
Member
Removing the match arm you linked should just be fine, why did you need to remove this Some()?
This comment has been minimized.
This comment has been minimized.
KiChjang
Mar 2, 2017
Member
Oh I see, looks like you're rolling in functionality for handling Some and None into the same match arm. Would it not be ok to just make a separate match arm instead specifically for the None case?
This comment has been minimized.
This comment has been minimized.
charlesvdv
Mar 2, 2017
Author
Contributor
Because before we were just handling the case with Some(virtual_key) but now we handle the case None (which doesn't change much the code so I put both on the same case).
This comment has been minimized.
This comment has been minimized.
KiChjang
Mar 2, 2017
Member
I'm actually more of the opinion that we should split this up into different match arms. The common code between the two match arms should just be refactored into a separate function, since this arm is already pretty big as it is. What do you think?
This comment has been minimized.
This comment has been minimized.
| Event::KeyboardInput(_, _, None) => { | ||
| debug!("Keyboard input without virtual key."); | ||
| let key = match virtual_key_code { | ||
| Some(v) => Window::glutin_key_to_script_key(v).unwrap(), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
charlesvdv
Mar 2, 2017
Author
Contributor
Because I will remove the Result from here but before doing so I prefer to see if you are ok with the changes
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I found it pretty hard to review, so I tried to split up your the refactoring from the actual changes: https://github.com/servo/servo/tree/keyboard-virtual. Would you mind pushing that branch to your PR? That should help to evaluate it. |
| fn get_keyboard_input_char(&self, element_state: ElementState, scan_code: ScanCode) -> Option<char> { | ||
| match element_state { | ||
| ElementState::Pressed => { | ||
| // Retrieve any previosly stored ReceivedCharacter value. |
This comment has been minimized.
This comment has been minimized.
| // Store the association between the scan code and the actual | ||
| // character value, if there is one. | ||
| let ch = self.pending_key_event_char | ||
| .get(); |
This comment has been minimized.
This comment has been minimized.
|
That changes from your last fixup commit needs to be properly squashed into the commits where they belong. |
|
You don't need |
|
|
|
@jonathandturner Think you could take a look at this? It became hard to rebase thanks to #16198. |
jonathandturner
commented
Oct 9, 2017
|
@nox - apologies. Wish I could help, though unfortunately too busy/out-of-the-loop to help fix. |
|
I think this PR (as well as possibly the mentioned issue) are obsolete, it seems like Servo's keyboard event handling was made more spec-compliant by 0ccaa7e#diff-8dc9268416cd4f037d50206e76c73cf9 The linked issue also talks about Glutin limitations, I'm not sure if that is still relevant anymore either. |
|
It certainly could still be relevant, since glutin just exported a bunch of input-related types and APIs from winit. We still rely on winit, so we probably still have the same input-related problems. However, this PR is not receiving any attention so I'm going to go ahead and close it. |
charlesvdv commentedMar 2, 2017
•
edited by larsbergstrom
This PR allows to properly handling KeyboardEvent without a virtual key code.
These PR is not completed yet but I prefer start a discussion to see if my approach is correct to you. (For exemple I have to remove the
Resultover here)../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is