diff --git a/src/core/input-events.c b/src/core/input-events.c index 5ef5d9c3c..96fee05b5 100644 --- a/src/core/input-events.c +++ b/src/core/input-events.c @@ -174,6 +174,35 @@ meta_input_event_ignore (MetaDisplay *display, return FALSE; } +gboolean +meta_input_event_get_touch_id (MetaDisplay *display, + XEvent *ev, + guint *touch_id) +{ + if (ev->type == GenericEvent && + ev->xcookie.extension == display->xinput2_opcode) + { + XIEvent *xev; + + g_assert (display->have_xinput2 == TRUE); + xev = (XIEvent *) ev->xcookie.data; + + switch (xev->evtype) + { + case XI_TouchBegin: + case XI_TouchEnd: + case XI_TouchUpdate: + if (touch_id) + *touch_id = ((XIDeviceEvent *) xev)->detail; + return TRUE; + default: + return FALSE; + } + } + + return FALSE; +} + Window meta_input_event_get_window (MetaDisplay *display, XEvent *ev) diff --git a/src/core/input-events.h b/src/core/input-events.h index d0e5af0b3..939764d55 100644 --- a/src/core/input-events.h +++ b/src/core/input-events.h @@ -45,6 +45,10 @@ gboolean meta_input_event_is_type (MetaDisplay *display, gboolean meta_input_event_ignore (MetaDisplay *display, XEvent *ev); +gboolean meta_input_event_get_touch_id (MetaDisplay *display, + XEvent *ev, + guint *touch_id); + Window meta_input_event_get_window (MetaDisplay *display, XEvent *ev); Window meta_input_event_get_root_window (MetaDisplay *display,