aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/wayland
diff options
context:
space:
mode:
authorVictor Berger <victor.berger@m4x.org>2015-05-15 12:20:25 +0200
committerVictor Berger <victor.berger@m4x.org>2015-05-15 12:20:25 +0200
commit178b7b133b5c36422e6e9ce137ef6dbaa4d066d2 (patch)
treed67878bc0d81770dd06a6f330ba7069f7af91f76 /src/api/wayland
parent02bd3758eefd87ac1a13068f8887afe392bc7823 (diff)
downloadglutin-178b7b133b5c36422e6e9ce137ef6dbaa4d066d2.tar.gz
glutin-178b7b133b5c36422e6e9ce137ef6dbaa4d066d2.zip
UTF8 keyboard events for wayland.
Diffstat (limited to 'src/api/wayland')
-rw-r--r--src/api/wayland/context.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/api/wayland/context.rs b/src/api/wayland/context.rs
index d69a254..3b6c0b8 100644
--- a/src/api/wayland/context.rs
+++ b/src/api/wayland/context.rs
@@ -137,17 +137,27 @@ impl WaylandContext {
KeyState::WL_KEYBOARD_KEY_STATE_RELEASED => ElementState::Released,
KeyState::WL_KEYBOARD_KEY_STATE_PRESSED => ElementState::Pressed
};
- let event = Event::KeyboardInput(
+ let mut events = Vec::new();
+ // key event
+ events.push(Event::KeyboardInput(
kstate,
(keycode & 0xff) as u8,
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
let sid = *current_surface.lock().unwrap();
if let Some(sid) = sid {
let map = event_queues.lock().unwrap();
if let Some(queue) = map.get(&sid) {
- queue.lock().unwrap().push_back(event);
+ queue.lock().unwrap().extend(events.into_iter());
}
}
});