mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
UTF8 keyboard events for wayland.
This commit is contained in:
parent
02bd3758ee
commit
178b7b133b
|
@ -137,17 +137,27 @@ impl WaylandContext {
|
||||||
KeyState::WL_KEYBOARD_KEY_STATE_RELEASED => ElementState::Released,
|
KeyState::WL_KEYBOARD_KEY_STATE_RELEASED => ElementState::Released,
|
||||||
KeyState::WL_KEYBOARD_KEY_STATE_PRESSED => ElementState::Pressed
|
KeyState::WL_KEYBOARD_KEY_STATE_PRESSED => ElementState::Pressed
|
||||||
};
|
};
|
||||||
let event = Event::KeyboardInput(
|
let mut events = Vec::new();
|
||||||
|
// key event
|
||||||
|
events.push(Event::KeyboardInput(
|
||||||
kstate,
|
kstate,
|
||||||
(keycode & 0xff) as u8,
|
(keycode & 0xff) as u8,
|
||||||
keycode_to_vkey(state, keycode)
|
keycode_to_vkey(state, keycode)
|
||||||
);
|
));
|
||||||
|
// utf8 events
|
||||||
|
if kstate == ElementState::Pressed {
|
||||||
|
if let Some(txt) = state.get_utf8(keycode) {
|
||||||
|
events.extend(
|
||||||
|
txt.chars().map(Event::ReceivedCharacter)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
// dispatch to the appropriate queue
|
// dispatch to the appropriate queue
|
||||||
let sid = *current_surface.lock().unwrap();
|
let sid = *current_surface.lock().unwrap();
|
||||||
if let Some(sid) = sid {
|
if let Some(sid) = sid {
|
||||||
let map = event_queues.lock().unwrap();
|
let map = event_queues.lock().unwrap();
|
||||||
if let Some(queue) = map.get(&sid) {
|
if let Some(queue) = map.get(&sid) {
|
||||||
queue.lock().unwrap().push_back(event);
|
queue.lock().unwrap().extend(events.into_iter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue