Skip to content

Commit 55656e0

Browse files
committed
Ignore synthetic key Pressed events
rust-windowing generates synthetic key press and release events to try and work around issues with keys being pressed and held while window focus is lost, see rust-windowing/winit#1296 However the Ubuntu workspace keyboard shortcut (and others) is causing synthetic Pressed events, without the corresponding Release event. Ignoring synthetic key pressed events, in addition to the existing behaviour of releasing all keys when window focus is lost (feenkcom/gtoolkit#423) resolves the issue. Fixes: feenkcom/gtoolkit#1178
1 parent f3d0d0c commit 55656e0

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/Glutin/GlutinEventsFetcher.class.st

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ GlutinEventsFetcher >> processGlutinEvent: aGlutinEvent [
173173
| mappedEvent |
174174

175175
mappedEvent := aGlutinEvent mapped.
176+
177+
"rust-windowing generates synthetic key press and release events to try and work around issues with keys being pressed and held while window focus is lost, see https://github.com/rust-windowing/winit/pull/1296
178+
However the Ubuntu workspace keyboard shortcut is causing synthetic Pressed events, without the corresponding Release event.
179+
Ignore synthetic key Pressed events"
180+
(mappedEvent isKeyboardInputEvent and:
181+
[ mappedEvent is_synthetic and:
182+
[ mappedEvent state = GlutinEventInputElementState Pressed ] ]) ifTrue:
183+
[ ^ self ].
184+
176185
self eventHandlers do: [ :eachHandler | eachHandler processGlutinEvent: mappedEvent ]
177186
]
178187

src/Glutin/GlutinKeyboardInputEvent.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ GlutinKeyboardInputEvent >> has_virtual_keycode: anObject [
6767
handle booleanAt: OFFSET_HAS_VIRTUAL_KEYCODE put: anObject
6868
]
6969

70+
{ #category : #testing }
71+
GlutinKeyboardInputEvent >> isKeyboardInputEvent [
72+
^ true
73+
]
74+
7075
{ #category : #'accessing structure variables' }
7176
GlutinKeyboardInputEvent >> is_synthetic [
7277
"This method was automatically generated"

src/Glutin/GlutinMappedEvent.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ GlutinMappedEvent >> isDeviceEvent [
2929
^ false
3030
]
3131

32+
{ #category : #testing }
33+
GlutinMappedEvent >> isKeyboardInputEvent [
34+
^ false
35+
]
36+
3237
{ #category : #testing }
3338
GlutinMappedEvent >> isWindowEvent [
3439
^ false

0 commit comments

Comments
 (0)