core: Add meta_input_event_get_source_device()

This function would return the slave device behind and
event, this is mostly needed for touch passive grabs,
as XIAllowTouchEvents() at the moment requires a slave
device, this has changed in the latest drafts of the
multitouch protocol.
This commit is contained in:
Carlos Garnacho 2011-09-02 21:15:41 +02:00 committed by Jasper St. Pierre
parent bbc69c4220
commit 704e2320c3
2 changed files with 43 additions and 1 deletions

View File

@ -759,3 +759,44 @@ meta_input_event_get_device (MetaDisplay *display,
return NULL;
}
MetaDevice *
meta_input_event_get_source_device (MetaDisplay *display,
XEvent *ev)
{
#ifdef HAVE_XINPUT2
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_Motion:
case XI_ButtonPress:
case XI_ButtonRelease:
case XI_KeyPress:
case XI_KeyRelease:
case XI_TouchBegin:
case XI_TouchEnd:
case XI_TouchUpdate:
return meta_device_map_lookup (display->device_map,
((XIDeviceEvent *) xev)->sourceid);
case XI_FocusIn:
case XI_FocusOut:
case XI_Enter:
case XI_Leave:
return meta_device_map_lookup (display->device_map,
((XIEnterEvent *) xev)->sourceid);
default:
break;
}
}
#endif
return NULL;
}

View File

@ -80,6 +80,7 @@ gboolean meta_input_event_get_crossing_details (MetaDisplay *display,
MetaDevice *meta_input_event_get_device (MetaDisplay *display,
XEvent *ev);
MetaDevice *meta_input_event_get_source_device (MetaDisplay *display,
XEvent *ev);
#endif /* META_EVENT_H */