diff options
author | Victor Berger <victor.berger@m4x.org> | 2015-12-13 15:13:23 +0100 |
---|---|---|
committer | Victor Berger <victor.berger@m4x.org> | 2015-12-22 14:36:41 +0100 |
commit | 84f1aef100c5f60cfb9086ca872cbf274092696c (patch) | |
tree | d286b3fca09bf9bef9d1872d942f7403a1edca70 /src/api/wayland/context.rs | |
parent | 0792557f4bc05125f0181729a6adbaf1aa52ec27 (diff) | |
download | glutin-84f1aef100c5f60cfb9086ca872cbf274092696c.tar.gz glutin-84f1aef100c5f60cfb9086ca872cbf274092696c.zip |
api/wayland: add keyboard support.
Diffstat (limited to 'src/api/wayland/context.rs')
-rw-r--r-- | src/api/wayland/context.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/api/wayland/context.rs b/src/api/wayland/context.rs index 4b39d85..285f50c 100644 --- a/src/api/wayland/context.rs +++ b/src/api/wayland/context.rs @@ -14,6 +14,7 @@ use wayland_client::wayland::shell::WlShell; use wayland_client::wayland::shm::WlShm; use wayland_client::wayland::subcompositor::WlSubcompositor; +use super::wayland_kbd::MappedKeyboard; use super::wayland_window::DecoratedSurface; lazy_static! { @@ -34,6 +35,7 @@ pub struct WaylandFocuses { pub pointer: Option<WlPointer>, pub pointer_on: Option<ProxyId>, pub pointer_at: Option<(f64, f64)>, + pub keyboard: Option<MappedKeyboard>, pub keyboard_on: Option<ProxyId> } @@ -72,6 +74,7 @@ impl WaylandContext { pointer: None, pointer_on: None, pointer_at: None, + keyboard: None, keyboard_on: None }) }) @@ -119,11 +122,19 @@ impl WaylandContext { self.inner.display.dispatch_pending().unwrap(); let mut iterator = self.iterator.lock().unwrap(); let mut focuses = self.focuses.lock().unwrap(); - let known_ids = self.known_surfaces.lock().unwrap(); + let known_surfaces = self.known_surfaces.lock().unwrap(); let queues = self.queues.lock().unwrap(); + // first, keyboard events + let kdb_evts = super::keyboard::translate_kbd_events(&mut *focuses, &known_surfaces); + for (evt, id) in kdb_evts { + if let Some(q) = queues.get(&id) { + q.lock().unwrap().push_back(evt); + } + } + // then, the rest for evt in &mut *iterator { if let Some((evt, id)) = super::events::translate_event( - evt, &mut *focuses, &known_ids, + evt, &mut *focuses, &known_surfaces, self.inner.seat.as_ref().map(|s| &s.0)) { if let Some(q) = queues.get(&id) { |