rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.84k stars 903 forks source link

Missing focus event after spawning + exiting dmenu on X11 #1565

Open kchibisov opened 4 years ago

kchibisov commented 4 years ago

It was reported to alacritty that after opening dmenu we're not getting focus event from winit, and so rendering our different unfocused cursor. Log from winit

[2020-05-10 14:52:17.563849422] [INFO] Welcome to Alacritty
[2020-05-10 14:52:17.563886471] [INFO] Configuration loaded from "/home/deewiant/.config/alacritty/alacritty.yml"
[2020-05-10 14:52:17.637146123] [INFO] Device pixel ratio: 1.1666666666666667
[2020-05-10 14:52:17.640714989] [INFO] Initializing glyph cache...
[2020-05-10 14:52:17.698843053] [INFO] ... finished initializing glyph cache in 0.058108495s
[2020-05-10 14:52:17.698869212] [INFO] Cell Size: 10 x 20
[2020-05-10 14:52:17.698873862] [INFO] Padding: 0 x 0
[2020-05-10 14:52:17.698883172] [INFO] Width: 800, Height: 600
[2020-05-10 14:52:17.704596765] [INFO] PTY Dimensions: Line(30) x Column(80)
[2020-05-10 14:52:17.708734484] [INFO] Initialisation complete
[2020-05-10 14:52:17.708756004] [INFO] glutin event: NewEvents(Init)
[2020-05-10 14:52:17.709283708] [INFO] glutin event: DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Key(KeyboardInput { scancode: 28, state: Released, virtual_keycode: Some(Return), modifiers: (empty) }) }
[2020-05-10 14:52:17.709528441] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: Resized(PhysicalSize { width: 2556, height: 1202 }) }
[2020-05-10 14:52:17.709590219] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: CursorEntered { device_id: DeviceId(X(DeviceId(2))) } }
[2020-05-10 14:52:17.709606779] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: PhysicalPosition { x: 635.0, y: 433.0 }, modifiers: (empty) } }
[2020-05-10 14:52:17.709616059] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: Moved(PhysicalPosition { x: 0, y: 37 }) }
[2020-05-10 14:52:17.709656777] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: Focused(true) }
[2020-05-10 14:52:17.709662997] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: PhysicalPosition { x: 635.0, y: 433.0 }, modifiers: (empty) } }
[2020-05-10 14:52:17.709680527] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:17.709686397] [INFO] glutin event: RedrawRequested(WindowId(X(WindowId(100663300))))
[2020-05-10 14:52:17.709691046] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:17.710515272] [INFO] Width: 2556, Height: 1202
[2020-05-10 14:52:17.720180420] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14578, tv_nsec: 342211064 }, requested_resume: None })
[2020-05-10 14:52:17.720199350] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:17.720204519] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:17.724705368] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14578, tv_nsec: 345706491 }, requested_resume: None })
[2020-05-10 14:52:17.725011829] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: ModifiersChanged((empty)) }
[2020-05-10 14:52:17.725027699] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: Focused(false) }
[2020-05-10 14:52:17.725253852] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:17.725262942] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:17.726579624] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14578, tv_nsec: 351075545 }, requested_resume: None })
[2020-05-10 14:52:17.726743629] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:17.726751748] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:17.728486568] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14578, tv_nsec: 352254090 }, requested_resume: None })
[2020-05-10 14:52:17.728497237] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:17.728502107] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:18.746497442] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14578, tv_nsec: 354003809 }, requested_resume: None })
[2020-05-10 14:52:18.746549551] [INFO] glutin event: DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Key(KeyboardInput { scancode: 28, state: Pressed, virtual_keycode: Some(Return), modifiers: (empty) }) }
[2020-05-10 14:52:18.746560310] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:18.746563860] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:18.748478345] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14579, tv_nsec: 372065082 }, requested_resume: None })
[2020-05-10 14:52:18.748896833] [INFO] glutin event: UserEvent(Wakeup)
[2020-05-10 14:52:18.748908952] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:18.748913532] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:18.749260152] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14579, tv_nsec: 374756434 }, requested_resume: None })
[2020-05-10 14:52:18.749269482] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:18.749272252] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:18.754751352] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14579, tv_nsec: 374772314 }, requested_resume: None })
[2020-05-10 14:52:18.754769641] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:18.754774101] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:18.810399727] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14579, tv_nsec: 380274833 }, requested_resume: None })
[2020-05-10 14:52:18.810419607] [INFO] glutin event: DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Key(KeyboardInput { scancode: 28, state: Released, virtual_keycode: Some(Return), modifiers: (empty) }) }
[2020-05-10 14:52:18.810560823] [INFO] glutin event: WindowEvent { window_id: WindowId(X(WindowId(100663300))), event: KeyboardInput { device_id: DeviceId(X(DeviceId(3))), input: KeyboardInput { scancode: 28, state: Released, virtual_keycode: Some(Return), modifiers: (empty) }, is_synthetic: false } }
[2020-05-10 14:52:18.810571552] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:18.810574832] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:20.749886306] [INFO] glutin event: NewEvents(WaitCancelled { start: Instant { tv_sec: 14579, tv_nsec: 436075744 }, requested_resume: None })
[2020-05-10 14:52:20.749925235] [INFO] glutin event: UserEvent(Exit)
[2020-05-10 14:52:20.749929804] [INFO] glutin event: UserEvent(Wakeup)
[2020-05-10 14:52:20.749933064] [INFO] glutin event: MainEventsCleared
[2020-05-10 14:52:20.749936324] [INFO] glutin event: RedrawEventsCleared
[2020-05-10 14:52:20.750229026] [INFO] glutin event: LoopDestroyed
[2020-05-10 14:52:20.760732849] [INFO] Goodbye

As you can see we have KeyboardInput in unfocused window, which is wrong.

mahkoh commented 2 years ago

I believe this was caused by a bug in dmenu 4.9 and has been fixed for a long time now.