aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-08-19 07:45:56 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-08-19 07:45:56 +0200
commita982c599d0956fde67b66b56a38b204dc422ae67 (patch)
treea0f3cd0ca8a5ed6e8b57e0e4b648955988b1cee5 /src/api/x11
parenta4e2f82ba77d22116eaee5601fb6ee5c6356c143 (diff)
parent93ce9c24f5308a77b1f13de1eacde13333d1d0ea (diff)
downloadglutin-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.rs22
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
}
}