xi: Implement conversions from internal to Xi2 gesture event structs
This commit is contained in:
parent
f3462178ca
commit
227f601de3
80
Xi/extinit.c
80
Xi/extinit.c
|
@ -850,6 +850,74 @@ SBarrierEvent(xXIBarrierEvent * from,
|
|||
swapl(&to->eventid);
|
||||
}
|
||||
|
||||
static void
|
||||
SGesturePinchEvent(xXIGesturePinchEvent* from,
|
||||
xXIGesturePinchEvent* to)
|
||||
{
|
||||
*to = *from;
|
||||
|
||||
swaps(&to->sequenceNumber);
|
||||
swapl(&to->length);
|
||||
swaps(&to->evtype);
|
||||
swaps(&to->deviceid);
|
||||
swapl(&to->time);
|
||||
swapl(&to->detail);
|
||||
swapl(&to->root);
|
||||
swapl(&to->event);
|
||||
swapl(&to->child);
|
||||
swapl(&to->root_x);
|
||||
swapl(&to->root_y);
|
||||
swapl(&to->event_x);
|
||||
swapl(&to->event_y);
|
||||
|
||||
swapl(&to->delta_x);
|
||||
swapl(&to->delta_y);
|
||||
swapl(&to->delta_unaccel_x);
|
||||
swapl(&to->delta_unaccel_y);
|
||||
swapl(&to->scale);
|
||||
swapl(&to->delta_angle);
|
||||
swaps(&to->sourceid);
|
||||
|
||||
swapl(&to->mods.base_mods);
|
||||
swapl(&to->mods.latched_mods);
|
||||
swapl(&to->mods.locked_mods);
|
||||
swapl(&to->mods.effective_mods);
|
||||
swapl(&to->flags);
|
||||
}
|
||||
|
||||
static void
|
||||
SGestureSwipeEvent(xXIGestureSwipeEvent* from,
|
||||
xXIGestureSwipeEvent* to)
|
||||
{
|
||||
*to = *from;
|
||||
|
||||
swaps(&to->sequenceNumber);
|
||||
swapl(&to->length);
|
||||
swaps(&to->evtype);
|
||||
swaps(&to->deviceid);
|
||||
swapl(&to->time);
|
||||
swapl(&to->detail);
|
||||
swapl(&to->root);
|
||||
swapl(&to->event);
|
||||
swapl(&to->child);
|
||||
swapl(&to->root_x);
|
||||
swapl(&to->root_y);
|
||||
swapl(&to->event_x);
|
||||
swapl(&to->event_y);
|
||||
|
||||
swapl(&to->delta_x);
|
||||
swapl(&to->delta_y);
|
||||
swapl(&to->delta_unaccel_x);
|
||||
swapl(&to->delta_unaccel_y);
|
||||
swaps(&to->sourceid);
|
||||
|
||||
swapl(&to->mods.base_mods);
|
||||
swapl(&to->mods.latched_mods);
|
||||
swapl(&to->mods.locked_mods);
|
||||
swapl(&to->mods.effective_mods);
|
||||
swapl(&to->flags);
|
||||
}
|
||||
|
||||
/** Event swapping function for XI2 events. */
|
||||
void _X_COLD
|
||||
XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
|
||||
|
@ -901,6 +969,18 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
|
|||
SBarrierEvent((xXIBarrierEvent *) from,
|
||||
(xXIBarrierEvent *) to);
|
||||
break;
|
||||
case XI_GesturePinchBegin:
|
||||
case XI_GesturePinchUpdate:
|
||||
case XI_GesturePinchEnd:
|
||||
SGesturePinchEvent((xXIGesturePinchEvent*) from,
|
||||
(xXIGesturePinchEvent*) to);
|
||||
break;
|
||||
case XI_GestureSwipeBegin:
|
||||
case XI_GestureSwipeUpdate:
|
||||
case XI_GestureSwipeEnd:
|
||||
SGestureSwipeEvent((xXIGestureSwipeEvent*) from,
|
||||
(xXIGestureSwipeEvent*) to);
|
||||
break;
|
||||
default:
|
||||
ErrorF("[Xi] Unknown event type to swap. This is a bug.\n");
|
||||
break;
|
||||
|
|
|
@ -59,6 +59,8 @@ static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi);
|
|||
static int eventToRawEvent(RawDeviceEvent *ev, xEvent **xi);
|
||||
static int eventToBarrierEvent(BarrierEvent *ev, xEvent **xi);
|
||||
static int eventToTouchOwnershipEvent(TouchOwnershipEvent *ev, xEvent **xi);
|
||||
static int eventToGestureSwipeEvent(GestureEvent *ev, xEvent **xi);
|
||||
static int eventToGesturePinchEvent(GestureEvent *ev, xEvent **xi);
|
||||
|
||||
/* Do not use, read comments below */
|
||||
BOOL EventIsKeyRepeat(xEvent *event);
|
||||
|
@ -163,6 +165,12 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
|
|||
case ET_TouchOwnership:
|
||||
case ET_BarrierHit:
|
||||
case ET_BarrierLeave:
|
||||
case ET_GesturePinchBegin:
|
||||
case ET_GesturePinchUpdate:
|
||||
case ET_GesturePinchEnd:
|
||||
case ET_GestureSwipeBegin:
|
||||
case ET_GestureSwipeUpdate:
|
||||
case ET_GestureSwipeEnd:
|
||||
ret = BadMatch;
|
||||
break;
|
||||
default:
|
||||
|
@ -221,6 +229,12 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
|
|||
case ET_TouchOwnership:
|
||||
case ET_BarrierHit:
|
||||
case ET_BarrierLeave:
|
||||
case ET_GesturePinchBegin:
|
||||
case ET_GesturePinchUpdate:
|
||||
case ET_GesturePinchEnd:
|
||||
case ET_GestureSwipeBegin:
|
||||
case ET_GestureSwipeUpdate:
|
||||
case ET_GestureSwipeEnd:
|
||||
*count = 0;
|
||||
*xi = NULL;
|
||||
return BadMatch;
|
||||
|
@ -285,6 +299,14 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
|
|||
case ET_BarrierHit:
|
||||
case ET_BarrierLeave:
|
||||
return eventToBarrierEvent(&ev->barrier_event, xi);
|
||||
case ET_GesturePinchBegin:
|
||||
case ET_GesturePinchUpdate:
|
||||
case ET_GesturePinchEnd:
|
||||
return eventToGesturePinchEvent(&ev->gesture_event, xi);
|
||||
case ET_GestureSwipeBegin:
|
||||
case ET_GestureSwipeUpdate:
|
||||
case ET_GestureSwipeEnd:
|
||||
return eventToGestureSwipeEvent(&ev->gesture_event, xi);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -816,6 +838,88 @@ eventToBarrierEvent(BarrierEvent *ev, xEvent **xi)
|
|||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
eventToGesturePinchEvent(GestureEvent *ev, xEvent **xi)
|
||||
{
|
||||
int len = sizeof(xXIGesturePinchEvent);
|
||||
xXIGesturePinchEvent *xpe;
|
||||
|
||||
*xi = calloc(1, len);
|
||||
xpe = (xXIGesturePinchEvent *) * xi;
|
||||
xpe->type = GenericEvent;
|
||||
xpe->extension = IReqCode;
|
||||
xpe->evtype = GetXI2Type(ev->type);
|
||||
xpe->time = ev->time;
|
||||
xpe->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
xpe->detail = ev->num_touches;
|
||||
|
||||
xpe->root = ev->root;
|
||||
xpe->deviceid = ev->deviceid;
|
||||
xpe->sourceid = ev->sourceid;
|
||||
xpe->root_x = double_to_fp1616(ev->root_x);
|
||||
xpe->root_y = double_to_fp1616(ev->root_y);
|
||||
xpe->flags |= (ev->flags & GESTURE_CANCELLED) ? XIGesturePinchEventCancelled : 0;
|
||||
|
||||
xpe->delta_x = double_to_fp1616(ev->delta_x);
|
||||
xpe->delta_y = double_to_fp1616(ev->delta_y);
|
||||
xpe->delta_unaccel_x = double_to_fp1616(ev->delta_unaccel_x);
|
||||
xpe->delta_unaccel_y = double_to_fp1616(ev->delta_unaccel_y);
|
||||
xpe->scale = double_to_fp1616(ev->scale);
|
||||
xpe->delta_angle = double_to_fp1616(ev->delta_angle);
|
||||
|
||||
xpe->mods.base_mods = ev->mods.base;
|
||||
xpe->mods.latched_mods = ev->mods.latched;
|
||||
xpe->mods.locked_mods = ev->mods.locked;
|
||||
xpe->mods.effective_mods = ev->mods.effective;
|
||||
|
||||
xpe->group.base_group = ev->group.base;
|
||||
xpe->group.latched_group = ev->group.latched;
|
||||
xpe->group.locked_group = ev->group.locked;
|
||||
xpe->group.effective_group = ev->group.effective;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
eventToGestureSwipeEvent(GestureEvent *ev, xEvent **xi)
|
||||
{
|
||||
int len = sizeof(xXIGestureSwipeEvent);
|
||||
xXIGestureSwipeEvent *xde;
|
||||
|
||||
*xi = calloc(1, len);
|
||||
xde = (xXIGestureSwipeEvent *) * xi;
|
||||
xde->type = GenericEvent;
|
||||
xde->extension = IReqCode;
|
||||
xde->evtype = GetXI2Type(ev->type);
|
||||
xde->time = ev->time;
|
||||
xde->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
xde->detail = ev->num_touches;
|
||||
|
||||
xde->root = ev->root;
|
||||
xde->deviceid = ev->deviceid;
|
||||
xde->sourceid = ev->sourceid;
|
||||
xde->root_x = double_to_fp1616(ev->root_x);
|
||||
xde->root_y = double_to_fp1616(ev->root_y);
|
||||
xde->flags |= (ev->flags & GESTURE_CANCELLED) ? XIGestureSwipeEventCancelled : 0;
|
||||
|
||||
xde->delta_x = double_to_fp1616(ev->delta_x);
|
||||
xde->delta_y = double_to_fp1616(ev->delta_y);
|
||||
xde->delta_unaccel_x = double_to_fp1616(ev->delta_unaccel_x);
|
||||
xde->delta_unaccel_y = double_to_fp1616(ev->delta_unaccel_y);
|
||||
|
||||
xde->mods.base_mods = ev->mods.base;
|
||||
xde->mods.latched_mods = ev->mods.latched;
|
||||
xde->mods.locked_mods = ev->mods.locked;
|
||||
xde->mods.effective_mods = ev->mods.effective;
|
||||
|
||||
xde->group.base_group = ev->group.base;
|
||||
xde->group.latched_group = ev->group.latched;
|
||||
xde->group.locked_group = ev->group.locked;
|
||||
xde->group.effective_group = ev->group.effective;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the corresponding core type for the given event or 0 if no core
|
||||
* equivalent exists.
|
||||
|
|
|
@ -105,6 +105,9 @@ SOFTWARE.
|
|||
#define TOUCH_POINTER_EMULATED (1 << 5) /* touch event may be pointer emulated */
|
||||
#define TOUCH_END (1 << 6) /* really end this touch now */
|
||||
|
||||
/* GetGestureEvent flags */
|
||||
#define GESTURE_CANCELLED (1 << 0)
|
||||
|
||||
/*int constants for pointer acceleration schemes*/
|
||||
#define PtrAccelNoOp 0
|
||||
#define PtrAccelPredictable 1
|
||||
|
|
Loading…
Reference in New Issue