Hook up TouchBegin/Update/End events
The are the same as device events internally but require the touch ID separately from the detail.button field (the protocol uses the detail field for the touch id). For simpler integration of pointer emulation we need to set the detail.button field while keeping the touchid around. Add the three new touch event types to the various places in the server where they need to be handled. The actual handling of the events is somewhat more complicated in most places. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
92a5862d0c
commit
84db813b9d
|
@ -128,6 +128,21 @@ IsPointerEvent(InternalEvent* event)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
IsTouchEvent(InternalEvent* event)
|
||||
{
|
||||
switch(event->any.type)
|
||||
{
|
||||
case ET_TouchBegin:
|
||||
case ET_TouchUpdate:
|
||||
case ET_TouchEnd:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the device matching the deviceid of the device set in the event, or
|
||||
* NULL if the event is not an XInput event.
|
||||
|
|
|
@ -858,6 +858,9 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
|
|||
case XI_KeyRelease:
|
||||
case XI_ButtonPress:
|
||||
case XI_ButtonRelease:
|
||||
case XI_TouchBegin:
|
||||
case XI_TouchUpdate:
|
||||
case XI_TouchEnd:
|
||||
SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to);
|
||||
break;
|
||||
case XI_RawMotion:
|
||||
|
|
|
@ -158,6 +158,9 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
|
|||
case ET_RawButtonPress:
|
||||
case ET_RawButtonRelease:
|
||||
case ET_RawMotion:
|
||||
case ET_TouchBegin:
|
||||
case ET_TouchUpdate:
|
||||
case ET_TouchEnd:
|
||||
ret = BadMatch;
|
||||
break;
|
||||
default:
|
||||
|
@ -208,6 +211,9 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
|
|||
case ET_RawButtonPress:
|
||||
case ET_RawButtonRelease:
|
||||
case ET_RawMotion:
|
||||
case ET_TouchBegin:
|
||||
case ET_TouchUpdate:
|
||||
case ET_TouchEnd:
|
||||
*count = 0;
|
||||
*xi = NULL;
|
||||
return BadMatch;
|
||||
|
@ -249,6 +255,9 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
|
|||
case ET_ButtonRelease:
|
||||
case ET_KeyPress:
|
||||
case ET_KeyRelease:
|
||||
case ET_TouchBegin:
|
||||
case ET_TouchUpdate:
|
||||
case ET_TouchEnd:
|
||||
return eventToDeviceEvent(&ev->device_event, xi);
|
||||
case ET_ProximityIn:
|
||||
case ET_ProximityOut:
|
||||
|
@ -650,7 +659,11 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
|
|||
xde->evtype = GetXI2Type(ev->type);
|
||||
xde->time = ev->time;
|
||||
xde->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
if (IsTouchEvent((InternalEvent*)ev))
|
||||
xde->detail = ev->touchid;
|
||||
else
|
||||
xde->detail = ev->detail.button;
|
||||
|
||||
xde->root = ev->root;
|
||||
xde->buttons_len = btlen;
|
||||
xde->valuators_len = vallen;
|
||||
|
@ -659,7 +672,11 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
|
|||
xde->root_x = FP1616(ev->root_x, ev->root_x_frac);
|
||||
xde->root_y = FP1616(ev->root_y, ev->root_y_frac);
|
||||
|
||||
if (ev->type == ET_TouchUpdate)
|
||||
xde->flags |= (ev->flags & TOUCH_PENDING_END) ? XITouchPendingEnd : 0;
|
||||
else
|
||||
xde->flags = ev->flags;
|
||||
|
||||
if (ev->key_repeat)
|
||||
xde->flags |= XIKeyRepeat;
|
||||
|
||||
|
@ -812,6 +829,9 @@ GetXI2Type(enum EventType type)
|
|||
case ET_RawMotion: xi2type = XI_RawMotion; break;
|
||||
case ET_FocusIn: xi2type = XI_FocusIn; break;
|
||||
case ET_FocusOut: xi2type = XI_FocusOut; break;
|
||||
case ET_TouchBegin: xi2type = XI_TouchBegin; break;
|
||||
case ET_TouchEnd: xi2type = XI_TouchEnd; break;
|
||||
case ET_TouchUpdate: xi2type = XI_TouchUpdate; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2978,6 +2978,9 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
|
|||
case ET_ButtonPress:
|
||||
case ET_ButtonRelease:
|
||||
case ET_Motion:
|
||||
case ET_TouchBegin:
|
||||
case ET_TouchUpdate:
|
||||
case ET_TouchEnd:
|
||||
break;
|
||||
default:
|
||||
/* all other events return FALSE */
|
||||
|
|
|
@ -582,6 +582,7 @@ extern Bool DevHasCursor(DeviceIntPtr pDev);
|
|||
extern _X_EXPORT Bool IsPointerDevice(DeviceIntPtr dev);
|
||||
extern _X_EXPORT Bool IsKeyboardDevice(DeviceIntPtr dev);
|
||||
extern Bool IsPointerEvent(InternalEvent *event);
|
||||
extern Bool IsTouchEvent(InternalEvent *event);
|
||||
extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev);
|
||||
extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev);
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ enum EventType {
|
|||
ET_ButtonPress,
|
||||
ET_ButtonRelease,
|
||||
ET_Motion,
|
||||
ET_TouchBegin,
|
||||
ET_TouchUpdate,
|
||||
ET_TouchEnd,
|
||||
ET_Enter,
|
||||
ET_Leave,
|
||||
ET_FocusIn,
|
||||
|
@ -84,9 +87,11 @@ struct _DeviceEvent
|
|||
int deviceid; /**< Device to post this event for */
|
||||
int sourceid; /**< The physical source device */
|
||||
union {
|
||||
uint32_t button; /**< Button number */
|
||||
uint32_t button; /**< Button number (also used in pointer emulating
|
||||
touch events) */
|
||||
uint32_t key; /**< Key code */
|
||||
} detail;
|
||||
uint32_t touchid; /**< Touch ID (client_id) */
|
||||
int16_t root_x; /**< Pos relative to root window in integral data */
|
||||
float root_x_frac; /**< Pos relative to root window in frac part */
|
||||
int16_t root_y; /**< Pos relative to root window in integral part */
|
||||
|
|
Loading…
Reference in New Issue