diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index 0266a8d30..edcb8a0d3 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -226,8 +226,41 @@ ProcXISelectEvents(ClientPtr client) return BadValue; } - /* Only one client per window may select for touch events on the - * same devices, including master devices. + /* All three pinch gesture events must be selected at once */ + if ((BitIsOn(bits, XI_GesturePinchBegin) || + BitIsOn(bits, XI_GesturePinchUpdate) || + BitIsOn(bits, XI_GesturePinchEnd)) && + (!BitIsOn(bits, XI_GesturePinchBegin) || + !BitIsOn(bits, XI_GesturePinchUpdate) || + !BitIsOn(bits, XI_GesturePinchEnd))) { + client->errorValue = XI_GesturePinchBegin; + return BadValue; + } + + /* All three swipe gesture events must be selected at once. Note + that the XI_GestureSwipeEnd is at index 32 which is on the next + 4-byte mask element */ + if (evmask->mask_len == 1 && + (BitIsOn(bits, XI_GestureSwipeBegin) || + BitIsOn(bits, XI_GestureSwipeUpdate))) + { + client->errorValue = XI_GestureSwipeBegin; + return BadValue; + } + + if (evmask->mask_len >= 2 && + (BitIsOn(bits, XI_GestureSwipeBegin) || + BitIsOn(bits, XI_GestureSwipeUpdate) || + BitIsOn(bits, XI_GestureSwipeEnd)) && + (!BitIsOn(bits, XI_GestureSwipeBegin) || + !BitIsOn(bits, XI_GestureSwipeUpdate) || + !BitIsOn(bits, XI_GestureSwipeEnd))) { + client->errorValue = XI_GestureSwipeBegin; + return BadValue; + } + + /* Only one client per window may select for touch or gesture events + * on the same devices, including master devices. * XXX: This breaks if a device goes from floating to attached. */ if (BitIsOn(bits, XI_TouchBegin)) { rc = check_for_touch_selection_conflicts(client, @@ -237,6 +270,22 @@ ProcXISelectEvents(ClientPtr client) if (rc != Success) return rc; } + if (BitIsOn(bits, XI_GesturePinchBegin)) { + rc = check_for_touch_selection_conflicts(client, + win, + evmask->deviceid, + XI_GesturePinchBegin); + if (rc != Success) + return rc; + } + if (BitIsOn(bits, XI_GestureSwipeBegin)) { + rc = check_for_touch_selection_conflicts(client, + win, + evmask->deviceid, + XI_GestureSwipeBegin); + if (rc != Success) + return rc; + } } if (XICheckInvalidMaskBits(client, (unsigned char *) &evmask[1],