diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-08-19 07:45:56 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-08-19 07:45:56 +0200 |
commit | a982c599d0956fde67b66b56a38b204dc422ae67 (patch) | |
tree | a0f3cd0ca8a5ed6e8b57e0e4b648955988b1cee5 /src/api/x11 | |
parent | a4e2f82ba77d22116eaee5601fb6ee5c6356c143 (diff) | |
parent | 93ce9c24f5308a77b1f13de1eacde13333d1d0ea (diff) | |
download | glutin-a982c599d0956fde67b66b56a38b204dc422ae67.tar.gz glutin-a982c599d0956fde67b66b56a38b204dc422ae67.zip |
Merge pull request #573 from mbrubeck/x11-touch
Handle touch events on X11
Diffstat (limited to 'src/api/x11')
-rw-r--r-- | src/api/x11/input.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/api/x11/input.rs b/src/api/x11/input.rs index 34ba33a..7387ab0 100644 --- a/src/api/x11/input.rs +++ b/src/api/x11/input.rs @@ -75,7 +75,7 @@ impl XInputEventHandler { // Button clicks and mouse events are handled via XInput // events. Key presses are still handled via plain core // X11 events. - let mut mask: [libc::c_uchar; 2] = [0, 0]; + let mut mask: [libc::c_uchar; 3] = [0; 3]; let mut input_event_mask = ffi::XIEventMask { deviceid: ffi::XIAllMasterDevices, mask_len: mask.len() as i32, @@ -88,7 +88,10 @@ impl XInputEventHandler { ffi::XI_Enter, ffi::XI_Leave, ffi::XI_FocusIn, - ffi::XI_FocusOut + ffi::XI_FocusOut, + ffi::XI_TouchBegin, + ffi::XI_TouchUpdate, + ffi::XI_TouchEnd, ]; for event in events { ffi::XISetMask(&mut mask, *event); @@ -165,6 +168,7 @@ impl XInputEventHandler { use events::ElementState::{Pressed, Released}; use events::MouseButton::{Left, Right, Middle}; use events::MouseScrollDelta::{PixelDelta, LineDelta}; + use events::{Touch, TouchPhase}; match cookie.evtype { ffi::XI_ButtonPress | ffi::XI_ButtonRelease => { @@ -240,6 +244,20 @@ impl XInputEventHandler { ffi::XI_Leave => None, ffi::XI_FocusIn => Some(Focused(true)), ffi::XI_FocusOut => Some(Focused(false)), + ffi::XI_TouchBegin | ffi::XI_TouchUpdate | ffi::XI_TouchEnd => { + let event_data: &ffi::XIDeviceEvent = unsafe{mem::transmute(cookie.data)}; + let phase = match cookie.evtype { + ffi::XI_TouchBegin => TouchPhase::Started, + ffi::XI_TouchUpdate => TouchPhase::Moved, + ffi::XI_TouchEnd => TouchPhase::Ended, + _ => unreachable!() + }; + Some(Event::Touch(Touch { + phase: phase, + location: (event_data.event_x, event_data.event_y), + id: event_data.detail as u64, + })) + } _ => None } } |