Skip to content
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

MacOS not sending ReceivedCharacter event #1267

Closed
chrisduerr opened this issue Nov 8, 2019 · 3 comments · Fixed by #1347
Closed

MacOS not sending ReceivedCharacter event #1267

chrisduerr opened this issue Nov 8, 2019 · 3 comments · Fixed by #1347
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos

Comments

@chrisduerr
Copy link
Contributor

It has been reported to Alacritty that on macOS, specific key combinations do not always emit ReceivedCharacter events on macOS.

The specific example was Ctrl+Q and it appears that while the first press does not emit an event, the second does.

This has been reported to Alacritty in alacritty/alacritty#1359 and here's an excerpt from the relevant event log (full log can be found in the issue):

[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 62, state: Pressed, virtual_keycode: Some(RControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 12, state: Pressed, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 12, state: Released, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 62, state: Released, virtual_keycode: Some(RControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 62, state: Pressed, virtual_keycode: Some(RControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 12, state: Pressed, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: ReceivedCharacter('\u{11}') }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 12, state: Released, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-11-08 10:53] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140382647460256)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 62, state: Released, virtual_keycode: Some(RControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
@goddessfreya goddessfreya added DS - macos C - needs investigation Issue must be confirmed and researched B - bug Dang, that shouldn't have happened labels Nov 9, 2019
@jayache80
Copy link
Contributor

I was just investigating alacritty/alacritty#2788 and I believe it's caused by this bug.

I built winit examples using cargo build --examples and ran target/debug/window and observed its debug output.

Here's the behavior that I observe:

  • press and hold "j" and get repeated KeyboardInput and ReceivedCharacter('j') events
  • while still holding "j", press and hold "k" and now get repeated KeyboardInput and ReceivedCharacter('k') (and no longer any ReceivedCharacter('j') events
  • release "j" (but continue holding "k") and notice the event of releasing "j" KeyboardInput { scancode: 38, state: Released, virtual_keycode: Some(J), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } but not longer getting the ReceivedCharacter('k') events (though still KeyboardInput events corresponding to "k" being held down)

Here's the examples/window output showing that observation with the repeated outputs truncated 3 and some comments interspersed:

### Hold down "j":

WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 38, state: Pressed, virtual_keycode: Some(J), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('j') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24391360193286 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 38, state: Pressed, virtual_keycode: Some(J), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('j') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24391600661713 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 38, state: Pressed, virtual_keycode: Some(J), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('j') }
EventsCleared

### While still holding down "j", begin holding down "k":

NewEvents(WaitCancelled { start: Instant { t: 24391872973697 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('k') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24391891868049 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('k') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24392142471924 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140368075138752)), event: ReceivedCharacter('k') }
EventsCleared

### Release "j":

NewEvents(WaitCancelled { start: Instant { t: 24392412497351 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 38, state: Released, virtual_keycode: Some(J), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

### ...but continue holding "k":

WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24392449916680 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { t: 24392483384856 }, requested_resume: None })
WindowEvent { window_id: WindowId(Id(140368075138752)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 40, state: Pressed, virtual_keycode: Some(K), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared

### Notice the lack of accompanying ReceivedCharacter('k') events for the last 3 Some(K) KeyboardInput events

hatoo added a commit to hatoo/winit that referenced this issue Dec 31, 2019
Osspial pushed a commit to hatoo/winit that referenced this issue Jan 5, 2020
vbogaevsky pushed a commit that referenced this issue Jan 14, 2020
…ation (#1347)

* MacOS FIX #1267

* Add CHANGELOG

* Remove unnecessary trace!
@Osspial Osspial reopened this Mar 9, 2020
@Osspial
Copy link
Contributor

Osspial commented Mar 9, 2020

Re-opening because #1501.

@kchibisov
Copy link
Member

There's no such event anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos
Development

Successfully merging a pull request may close this issue.

5 participants