summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/XExtInt.c184
-rw-r--r--src/XIPassiveGrab.c59
-rw-r--r--src/XIint.h1
3 files changed, 243 insertions, 1 deletions
diff --git a/src/XExtInt.c b/src/XExtInt.c
index d379876..f2b5a75 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -127,6 +127,12 @@ wireToTouchOwnershipEvent(xXITouchOwnershipEvent *in,
static int
wireToBarrierEvent(xXIBarrierEvent *in,
XGenericEventCookie *cookie);
+static int
+wireToPinchEvent(xXIGesturePinchEvent *in,
+ XGenericEventCookie *cookie);
+static int
+wireToSwipeEvent(xXIGestureSwipeEvent *in,
+ XGenericEventCookie *cookie);
static /* const */ XEvent emptyevent;
@@ -1035,6 +1041,28 @@ XInputWireToCookie(
break;
}
return ENQUEUE_EVENT;
+ case XI_GesturePinchBegin:
+ case XI_GesturePinchUpdate:
+ case XI_GesturePinchEnd:
+ *cookie = *(XGenericEventCookie*)save;
+ if (!wireToPinchEvent((xXIGesturePinchEndEvent*)event, cookie))
+ {
+ printf("XInputWireToCookie: CONVERSION FAILURE! evtype=%d\n",
+ ge->evtype);
+ break;
+ }
+ return ENQUEUE_EVENT;
+ case XI_GestureSwipeBegin:
+ case XI_GestureSwipeUpdate:
+ case XI_GestureSwipeEnd:
+ *cookie = *(XGenericEventCookie*)save;
+ if (!wireToSwipeEvent((xXIGestureSwipeEndEvent*)event, cookie))
+ {
+ printf("XInputWireToCookie: CONVERSION FAILURE! evtype=%d\n",
+ ge->evtype);
+ break;
+ }
+ return ENQUEUE_EVENT;
default:
printf("XInputWireToCookie: Unknown generic event. type %d\n", ge->evtype);
@@ -1065,7 +1093,7 @@ sizeDeviceEvent(int buttons_len, int valuators_len,
/* Return the size with added padding so next element would be
double-aligned unless the architecture is known to allow unaligned
data accesses. Not doing this can cause a bus error on
- MIPS N32. */
+ MIPS N32. */
static int
pad_to_double(int size)
{
@@ -1143,6 +1171,9 @@ sizeDeviceClassType(int type, int num_elements)
case XITouchClass:
l = pad_to_double(sizeof(XITouchClassInfo));
break;
+ case XIGestureClass:
+ l = pad_to_double(sizeof(XIGestureClassInfo));
+ break;
default:
printf("sizeDeviceClassType: unknown type %d\n", type);
break;
@@ -1432,6 +1463,41 @@ copyBarrierEvent(XGenericEventCookie *in_cookie,
return True;
}
+
+static Bool
+copyGesturePinchEvent(XGenericEventCookie *cookie_in,
+ XGenericEventCookie *cookie_out)
+{
+ XIGesturePinchEvent *in, *out;
+
+ in = cookie_in->data;
+
+ out = cookie_out->data = malloc(sizeof(XIGesturePinchEvent));
+ if (!out)
+ return False;
+
+ *out = *in;
+
+ return True;
+}
+
+static Bool
+copyGestureSwipeEvent(XGenericEventCookie *cookie_in,
+ XGenericEventCookie *cookie_out)
+{
+ XIGestureSwipeEvent *in, *out;
+
+ in = cookie_in->data;
+
+ out = cookie_out->data = malloc(sizeof(XIGestureSwipeEvent));
+ if (!out)
+ return False;
+
+ *out = *in;
+
+ return True;
+}
+
static Bool
XInputCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
{
@@ -1493,6 +1559,16 @@ XInputCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out
case XI_BarrierLeave:
ret = copyBarrierEvent(in, out);
break;
+ case XI_GesturePinchBegin:
+ case XI_GesturePinchUpdate:
+ case XI_GesturePinchEnd:
+ ret = copyGesturePinchEvent(in, out);
+ break;
+ case XI_GestureSwipeBegin:
+ case XI_GestureSwipeUpdate:
+ case XI_GestureSwipeEnd:
+ ret = copyGestureSwipeEvent(in, out);
+ break;
default:
printf("XInputCopyCookie: unknown evtype %d\n", in->evtype);
ret = False;
@@ -1607,6 +1683,9 @@ size_classes(xXIAnyInfo* from, int nclasses)
case XITouchClass:
l = sizeDeviceClassType(XITouchClass, 0);
break;
+ case XIGestureClass:
+ l = sizeDeviceClassType(XIGestureClass, 0);
+ break;
}
len += l;
@@ -1770,6 +1849,21 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int *nclasses)
to->classes[cls_idx++] = any_lib;
}
break;
+ case XIGestureClass:
+ {
+ XIGestureClassInfo *cls_lib;
+ xXIGestureInfo *cls_wire;
+
+ cls_wire = (xXIGestureInfo*)any_wire;
+ cls_lib = next_block(&ptr_lib, sizeof(XIGestureClassInfo));
+
+ cls_lib->type = cls_wire->type;
+ cls_lib->sourceid = cls_wire->sourceid;
+ cls_lib->num_touches = cls_wire->num_touches;
+
+ to->classes[cls_idx++] = any_lib;
+ }
+ break;
}
len += any_wire->length * 4;
ptr_wire += any_wire->length * 4;
@@ -2029,3 +2123,91 @@ wireToBarrierEvent(xXIBarrierEvent *in, XGenericEventCookie *cookie)
return 1;
}
+
+static int
+wireToPinchEvent(xXIGesturePinchEvent *in,
+ XGenericEventCookie *cookie)
+{
+ XIGesturePinchEvent *out;
+
+ cookie->data = out = malloc(sizeof(XIGesturePinchEvent));
+
+ out->display = cookie->display;
+ out->type = in->type;
+ out->serial = cookie->serial;
+ out->extension = in->extension;
+ out->evtype = in->evtype;
+ out->send_event = ((in->type & 0x80) != 0);
+ out->time = in->time;
+ out->deviceid = in->deviceid;
+ out->sourceid = in->sourceid;
+ out->detail = in->detail;
+ out->root = in->root;
+ out->event = in->event;
+ out->child = in->child;
+ out->root_x = FP1616toDBL(in->root_x);
+ out->root_y = FP1616toDBL(in->root_y);
+ out->event_x = FP1616toDBL(in->event_x);
+ out->event_y = FP1616toDBL(in->event_y);
+ out->delta_x = FP1616toDBL(in->delta_x);
+ out->delta_y = FP1616toDBL(in->delta_y);
+ out->delta_unaccel_x = FP1616toDBL(in->delta_unaccel_x);
+ out->delta_unaccel_y = FP1616toDBL(in->delta_unaccel_y);
+ out->scale = FP1616toDBL(in->scale);
+ out->delta_angle = FP1616toDBL(in->delta_angle);
+ out->flags = in->flags;
+
+ out->mods.base = in->mods.base_mods;
+ out->mods.locked = in->mods.locked_mods;
+ out->mods.latched = in->mods.latched_mods;
+ out->mods.effective = in->mods.effective_mods;
+ out->group.base = in->group.base_group;
+ out->group.locked = in->group.locked_group;
+ out->group.latched = in->group.latched_group;
+ out->group.effective = in->group.effective_group;
+
+ return 1;
+}
+
+static int
+wireToSwipeEvent(xXIGestureSwipeEvent *in,
+ XGenericEventCookie *cookie)
+{
+ XIGestureSwipeEvent *out;
+
+ cookie->data = out = malloc(sizeof(XIGestureSwipeEvent));
+
+ out->display = cookie->display;
+ out->type = in->type;
+ out->serial = cookie->serial;
+ out->extension = in->extension;
+ out->evtype = in->evtype;
+ out->send_event = ((in->type & 0x80) != 0);
+ out->time = in->time;
+ out->deviceid = in->deviceid;
+ out->sourceid = in->sourceid;
+ out->detail = in->detail;
+ out->root = in->root;
+ out->event = in->event;
+ out->child = in->child;
+ out->root_x = FP1616toDBL(in->root_x);
+ out->root_y = FP1616toDBL(in->root_y);
+ out->event_x = FP1616toDBL(in->event_x);
+ out->event_y = FP1616toDBL(in->event_y);
+ out->delta_x = FP1616toDBL(in->delta_x);
+ out->delta_y = FP1616toDBL(in->delta_y);
+ out->delta_unaccel_x = FP1616toDBL(in->delta_unaccel_x);
+ out->delta_unaccel_y = FP1616toDBL(in->delta_unaccel_y);
+ out->flags = in->flags;
+
+ out->mods.base = in->mods.base_mods;
+ out->mods.locked = in->mods.locked_mods;
+ out->mods.latched = in->mods.latched_mods;
+ out->mods.effective = in->mods.effective_mods;
+ out->group.base = in->group.base_group;
+ out->group.locked = in->group.locked_group;
+ out->group.latched = in->group.latched_group;
+ out->group.effective = in->group.effective_group;
+
+ return 1;
+}
diff --git a/src/XIPassiveGrab.c b/src/XIPassiveGrab.c
index 32b0ab3..310e523 100644
--- a/src/XIPassiveGrab.c
+++ b/src/XIPassiveGrab.c
@@ -177,6 +177,37 @@ XIGrabTouchBegin(Display *dpy, int deviceid, Window grab_window,
num_modifiers, modifiers_inout, CurrentTime);
}
+int XIGrabPinchGestureBegin(Display* dpy, int deviceid, Window grab_window, int grab_mode,
+ int paired_device_mode, int owner_events,
+ XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout)
+{
+ XExtDisplayInfo *extinfo = XInput_find_display(dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_2_4, extinfo) == -1)
+ return -1;
+ UnlockDisplay(dpy);
+
+ return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeGesturePinchBegin, 0,
+ grab_window, None, grab_mode, paired_device_mode,
+ owner_events, mask, num_modifiers, modifiers_inout, CurrentTime);
+}
+
+int XIGrabSwipeGestureBegin(Display* dpy, int deviceid, Window grab_window, int grab_mode,
+ int paired_device_mode, int owner_events,
+ XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout)
+{
+ XExtDisplayInfo *extinfo = XInput_find_display(dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_2_4, extinfo) == -1)
+ return -1;
+ UnlockDisplay(dpy);
+
+ return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeGestureSwipeBegin, 0,
+ grab_window, None, grab_mode, paired_device_mode,
+ owner_events, mask, num_modifiers, modifiers_inout, CurrentTime);
+}
static int
_XIPassiveUngrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
@@ -256,3 +287,31 @@ XIUngrabTouchBegin(Display* display, int deviceid, Window grab_window,
return _XIPassiveUngrabDevice(display, deviceid, XIGrabtypeTouchBegin, 0,
grab_window, num_modifiers, modifiers);
}
+
+int XIUngrabPinchGestureBegin(Display* display, int deviceid, Window grab_window,
+ int num_modifiers, XIGrabModifiers *modifiers)
+{
+ XExtDisplayInfo *extinfo = XInput_find_display(display);
+
+ LockDisplay(display);
+ if (_XiCheckExtInit(display, XInput_2_4, extinfo) == -1)
+ return -1;
+ UnlockDisplay(display);
+
+ return _XIPassiveUngrabDevice(display, deviceid, XIGrabtypeGesturePinchBegin, 0,
+ grab_window, num_modifiers, modifiers);
+}
+
+int XIUngrabSwipeGestureBegin(Display* display, int deviceid, Window grab_window,
+ int num_modifiers, XIGrabModifiers *modifiers)
+{
+ XExtDisplayInfo *extinfo = XInput_find_display(display);
+
+ LockDisplay(display);
+ if (_XiCheckExtInit(display, XInput_2_4, extinfo) == -1)
+ return -1;
+ UnlockDisplay(display);
+
+ return _XIPassiveUngrabDevice(display, deviceid, XIGrabtypeGestureSwipeBegin, 0,
+ grab_window, num_modifiers, modifiers);
+}
diff --git a/src/XIint.h b/src/XIint.h
index 9479a79..40dec0b 100644
--- a/src/XIint.h
+++ b/src/XIint.h
@@ -23,6 +23,7 @@
#define XInput_2_1 8
#define XInput_2_2 9
#define XInput_2_3 10
+#define XInput_2_4 11
extern XExtDisplayInfo *XInput_find_display(Display *);