You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a way to handle VirtualKeyCode or Utf8 string #115
Alacritty is currently using a fork of glutin which includes the decoded UTF-8 String with the glutin::Event::KeyboardInput. This was added to support either handling the VirtualKeyCode and active modifiers as a key binding or just printing the decoded UTF-8. For example:
Without including the String in this event, it was very difficult to have this logic where we check for keybindings or else fall back to printing. The string was delivered in potentially several Event::ReceivedChar events and followed by the KeyboardInput event. There is currently no way to know which ReceivedChar events go with which KeyboardInput.
I realize passing a string with this event may not be ideal since String allocates, and I am open to other solutions. Even so, events are already buffered on the heap, and it seems like adding an allocation for the string versus a series of ReceivedChar events is a reasonable trade.
A couple of questions:
What do you think about supporting this use case in winit/glutin?
What are your thoughts on including a String in the KeyboardInput event?
What are your thoughts on including a String in the KeyboardInput event?
I don't have any thoughts. Winit aims to be the lowest common denominator of all windowing systems.
If windowing systems provide a way to associate characters with the keyboard input, then winit should provide a way too.
If windowing systems provide a way to associate characters with the keyboard input, then winit should provide a way too.
winit already provides this information through winit::Event::ReceivedCharacter. The problem is that with the events iterator, there's no way to know which ReceivedCharacter events are associated with some KeyboardInput event. This issue suggests to address that by including a String with the KeyboardInput instead of a series of ReceivedCharacter.
winit already provides this information through winit::Event::ReceivedCharacter. The problem is that with the events iterator, there's no way to know which ReceivedCharacter events are associated with some KeyboardInput event.
I'm saying that if Windows, X11, Wayland and Cocoa all provide a way to associate a keyboard input with a character, then we should go ahead and expose this in winit.
Activity
tomaka commentedon Jan 20, 2017
I don't have any thoughts. Winit aims to be the lowest common denominator of all windowing systems.
If windowing systems provide a way to associate characters with the keyboard input, then winit should provide a way too.
jwilm commentedon Jan 20, 2017
winit already provides this information through
winit::Event::ReceivedCharacter. The problem is that with the events iterator, there's no way to know whichReceivedCharacterevents are associated with someKeyboardInputevent. This issue suggests to address that by including aStringwith theKeyboardInputinstead of a series ofReceivedCharacter.rigtorp commentedon Jan 21, 2017
I seems pretty silly to worry about heap allocations that would occur at a rate less then 10 times per second.
GLFW has a similar ReceivedCharacter event and I suspect it is based on the WM_CHAR win32 event: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646276(v=vs.85).aspx
Maybe there are issues implementing this unified keyboard event on windows with non-ascii input?
tomaka commentedon Jan 21, 2017
I'm saying that if Windows, X11, Wayland and Cocoa all provide a way to associate a keyboard input with a character, then we should go ahead and expose this in winit.
Auto merge of rust-windowing#115 - mbrubeck:servo-no-wayland, r=glennw
jwilm commentedon May 8, 2017
Seems like there's nothing to be done here since win32 can't support this. Thanks for the info @rigtorp.