input-events: Add meta_input_event_get_touch_id()

This function returns the touch ID generating an input event,
if any.
This commit is contained in:
Carlos Garnacho 2011-08-02 19:20:43 +02:00 committed by Jasper St. Pierre
parent 6a03efe435
commit bbc69c4220
2 changed files with 33 additions and 0 deletions

View File

@ -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)

View File

@ -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,