package version up
[platform/upstream/libXi.git] / src / XExtInt.c
index 27638bd..d3c6b7c 100644 (file)
@@ -73,40 +73,11 @@ SOFTWARE.
 #define DONT_ENQUEUE   False
 #define FP1616toDBL(x) ((x) * 1.0 / (1 << 16))
 
-extern void _xibaddevice(
-    Display *          /* dpy */,
-    int *              /* error */
-);
-
-extern void _xibadclass(
-    Display *          /* dpy */,
-    int *              /* error */
-);
-
-extern void _xibadevent(
-    Display *          /* dpy */,
-    int *              /* error */
-);
-
-extern void _xibadmode(
-    Display *          /* dpy */,
-    int *              /* error */
-);
-
-extern void _xidevicebusy(
-    Display *          /* dpy */,
-    int *              /* error */
-);
-
-extern int _XiGetDevicePresenceNotifyEvent(
-    Display *          /* dpy */
-);
-
 int copy_classes(XIDeviceInfo *to, xXIAnyInfo* from, int *nclasses);
 int size_classes(xXIAnyInfo* from, int nclasses);
 
 static XExtensionInfo *xinput_info;
-static /* const */ char *xinput_extension_name = INAME;
+static const char *xinput_extension_name = INAME;
 
 static int XInputClose(
     Display *          /* dpy */,
@@ -153,6 +124,9 @@ wireToPropertyEvent(xXIPropertyEvent *in, XGenericEventCookie *cookie);
 static int
 wireToTouchOwnershipEvent(xXITouchOwnershipEvent *in,
                           XGenericEventCookie *cookie);
+static int
+wireToBarrierEvent(xXIBarrierEvent *in,
+                   XGenericEventCookie *cookie);
 
 static /* const */ XEvent emptyevent;
 
@@ -172,7 +146,7 @@ static /* const */ XExtensionHooks xinput_extension_hooks = {
     XInputError,       /* error_string */
 };
 
-static char *XInputErrorList[] = {
+static const char *XInputErrorList[] = {
     "BadDevice, invalid or uninitialized input device",        /* BadDevice */
     "BadEvent, invalid event type",    /* BadEvent */
     "BadMode, invalid mode parameter", /* BadMode  */
@@ -496,7 +470,6 @@ XInputWireToEvent(
     xEvent     *event)
 {
     unsigned int type, reltype;
-    unsigned int i, j;
     XExtDisplayInfo *info = XInput_find_display(dpy);
     XEvent *save = (XEvent *) info->data;
 
@@ -621,6 +594,7 @@ XInputWireToEvent(
                 {
                     deviceValuator *xev = (deviceValuator *) event;
                     int save_type = save->type - info->codes->first_event;
+                    int i;
 
                     if (save_type == XI_DeviceKeyPress || save_type == XI_DeviceKeyRelease) {
                         XDeviceKeyEvent *kev = (XDeviceKeyEvent *) save;
@@ -716,6 +690,7 @@ XInputWireToEvent(
                                 pev->axis_data[0] = xev->valuator0;
                         }
                     } else if (save_type == XI_DeviceStateNotify) {
+                        int j;
                         XDeviceStateNotifyEvent *sev = (XDeviceStateNotifyEvent *) save;
                         XInputClass *any = (XInputClass *) & sev->data[0];
                         XValuatorStatus *v;
@@ -760,6 +735,7 @@ XInputWireToEvent(
                 break;
             case XI_DeviceStateNotify:
                 {
+                    int j;
                     XDeviceStateNotifyEvent *stev = (XDeviceStateNotifyEvent *) save;
                     deviceStateNotify *sev = (deviceStateNotify *) event;
                     char *data;
@@ -1049,6 +1025,16 @@ XInputWireToCookie(
                 break;
             }
             return ENQUEUE_EVENT;
+        case XI_BarrierHit:
+        case XI_BarrierLeave:
+            *cookie = *(XGenericEventCookie*)save;
+            if (!wireToBarrierEvent((xXIBarrierEvent*)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);
 
@@ -1430,7 +1416,21 @@ copyRawEvent(XGenericEventCookie *cookie_in,
     return True;
 }
 
+static Bool
+copyBarrierEvent(XGenericEventCookie *in_cookie,
+                 XGenericEventCookie *out_cookie)
+{
+    XIBarrierEvent *in, *out;
 
+    in = in_cookie->data;
+
+    out = out_cookie->data = calloc(1, sizeof(XIBarrierEvent));
+    if (!out)
+        return False;
+    *out = *in;
+
+    return True;
+}
 
 static Bool
 XInputCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
@@ -1484,8 +1484,15 @@ XInputCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out
         case XI_RawButtonPress:
         case XI_RawButtonRelease:
         case XI_RawMotion:
+        case XI_RawTouchBegin:
+        case XI_RawTouchUpdate:
+        case XI_RawTouchEnd:
             ret = copyRawEvent(in, out);
             break;
+        case XI_BarrierHit:
+        case XI_BarrierLeave:
+            ret = copyBarrierEvent(in, out);
+            break;
         default:
             printf("XInputCopyCookie: unknown evtype %d\n", in->evtype);
             ret = False;
@@ -1514,6 +1521,7 @@ wireToDeviceEvent(xXIDeviceEvent *in, XGenericEventCookie* cookie)
     out = next_block(&ptr_lib, sizeof(XIDeviceEvent));
     out->display = cookie->display;
     out->type = in->type;
+    out->serial = in->sequenceNumber;
     out->extension = in->extension;
     out->evtype = in->evtype;
     out->send_event = ((in->type & 0x80) != 0);
@@ -1786,6 +1794,7 @@ wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XGenericEventCookie *cookie)
     cookie->data = out = malloc(sizeof(XIDeviceChangedEvent) + len);
 
     out->type = in->type;
+    out->serial = in->sequenceNumber;
     out->display = cookie->display;
     out->extension = in->extension;
     out->evtype = in->evtype;
@@ -1818,6 +1827,7 @@ wireToHierarchyChangedEvent(xXIHierarchyEvent *in, XGenericEventCookie *cookie)
     out->info           = (XIHierarchyInfo*)&out[1];
     out->display        = cookie->display;
     out->type           = in->type;
+    out->serial         = in->sequenceNumber;
     out->extension      = in->extension;
     out->evtype         = in->evtype;
     out->send_event = ((in->type & 0x80) != 0);
@@ -1858,6 +1868,7 @@ wireToRawEvent(XExtDisplayInfo *info, xXIRawEvent *in, XGenericEventCookie *cook
 
     out = next_block(&ptr, sizeof(XIRawEvent));
     out->type           = in->type;
+    out->serial         = in->sequenceNumber;
     out->display        = cookie->display;
     out->extension      = in->extension;
     out->evtype         = in->evtype;
@@ -1908,6 +1919,7 @@ wireToEnterLeave(xXIEnterEvent *in, XGenericEventCookie *cookie)
     out->buttons.mask = (unsigned char*)&out[1];
 
     out->type           = in->type;
+    out->serial         = in->sequenceNumber;
     out->display        = cookie->display;
     out->extension      = in->extension;
     out->evtype         = in->evtype;
@@ -1950,6 +1962,7 @@ wireToPropertyEvent(xXIPropertyEvent *in, XGenericEventCookie *cookie)
     cookie->data = out;
 
     out->type           = in->type;
+    out->serial         = in->sequenceNumber;
     out->extension      = in->extension;
     out->evtype         = in->evtype;
     out->send_event = ((in->type & 0x80) != 0);
@@ -1970,6 +1983,7 @@ wireToTouchOwnershipEvent(xXITouchOwnershipEvent *in,
     cookie->data = out;
 
     out->type           = in->type;
+    out->serial         = in->sequenceNumber;
     out->display        = cookie->display;
     out->extension      = in->extension;
     out->evtype         = in->evtype;
@@ -1985,3 +1999,35 @@ wireToTouchOwnershipEvent(xXITouchOwnershipEvent *in,
 
     return 1;
 }
+
+#define FP3232_TO_DOUBLE(x) ((double) (x).integral + (x).frac / (1ULL << 32))
+
+static int
+wireToBarrierEvent(xXIBarrierEvent *in, XGenericEventCookie *cookie)
+{
+    XIBarrierEvent *out = malloc(sizeof(XIBarrierEvent));
+
+    cookie->data = out;
+
+    out->display    = cookie->display;
+    out->type       = in->type;
+    out->serial     = in->sequenceNumber;
+    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->event      = in->event;
+    out->root       = in->root;
+    out->root_x     = FP1616toDBL(in->root_x);
+    out->root_y     = FP1616toDBL(in->root_y);
+    out->dx         = FP3232_TO_DOUBLE (in->dx);
+    out->dy         = FP3232_TO_DOUBLE (in->dy);
+    out->dtime      = in->dtime;
+    out->flags      = in->flags;
+    out->barrier    = in->barrier;
+    out->eventid    = in->eventid;
+
+    return 1;
+}