--- lib-old/Xi/src/Makefile.am 2005-12-02 23:41:49.000000000 -0500 +++ lib/Xi/src/Makefile.am 2005-12-25 21:43:40.000000000 -0500 @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libXi.la libXi_la_SOURCES = \ + XAddDev.c \ XAllowDv.c \ XChgDCtl.c \ XChgFCtl.c \ @@ -29,6 +30,7 @@ XListDev.c \ XOpenDev.c \ XQueryDv.c \ + XRmDev.c \ XSelect.c \ XSetBMap.c \ XSetDVal.c \ --- lib-old/Xi/src/XAddDev.c 1969-12-31 19:00:00.000000000 -0500 +++ lib/Xi/src/XAddDev.c 2005-12-25 21:24:39.000000000 -0500 @@ -0,0 +1,77 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Kristian Høgsberg (krh@redhat.com) + */ + +#include +#include +#include +#include +#include +#include "XIint.h" + +int +_XiPutString(Display *dpy, _Xconst char *s) +{ + CARD16 length; + + length = strlen(s); + Data (dpy, (char *) &length, sizeof length); + Data (dpy, s, length); + + return 1 + ((length + 3) >> 2); +} + +int +XAddInputDevice(Display *dpy, _Xconst char *name, _Xconst char *driver, + XDeviceOption *options, int numOptions) +{ + xAddInputDeviceReq *req; + xAddInputDeviceReply rep; + CARD16 card16NumOptions; + int i; + XExtDisplayInfo *info = XInput_find_display (dpy); + + LockDisplay (dpy); + if (_XiCheckExtInit(dpy, XInput_Add_XAddInputDevice) == -1) + return NoSuchExtension; + + GetReq(AddInputDevice,req); + req->reqType = info->codes->major_opcode; + req->ReqType = X_AddInputDevice; + req->length += _XiPutString(dpy, name); + req->length += _XiPutString(dpy, driver); + + card16NumOptions = numOptions; + Data(dpy, (char *) &card16NumOptions, sizeof card16NumOptions); + req->length++; + + for (i = 0; i < numOptions; i++) { + req->length += _XiPutString(dpy, options[i].name); + req->length += _XiPutString(dpy, options[i].value); + } + + _XReply (dpy, (xReply *) &rep, 0, xFalse); + UnlockDisplay(dpy); + SyncHandle(); + + return rep.status; +} --- lib-old/Xi/src/XExtInt.c 2004-04-23 14:43:44.000000000 -0400 +++ lib/Xi/src/XExtInt.c 2005-12-25 21:24:39.000000000 -0500 @@ -122,7 +122,9 @@ {XI_Present, XI_Add_XSetDeviceValuators_Major, XI_Add_XSetDeviceValuators_Minor}, {XI_Present, XI_Add_XChangeDeviceControl_Major, - XI_Add_XChangeDeviceControl_Minor}}; + XI_Add_XChangeDeviceControl_Minor}, + {XI_Present, XI_Add_XAddInputDevice_Major, + XI_Add_XAddInputDevice_Minor}}; /*********************************************************************** * @@ -245,6 +247,14 @@ return (((y + (y >> 3)) & 030707070707) % 077); } +static int +_XiGetDevicePresenceNotifyEvent(Display *dpy) +{ + XExtDisplayInfo *info = XInput_find_display (dpy); + + return info->codes->first_event + XI_DevicePresenceNotify; +} + /*********************************************************************** * * Handle Input extension events. @@ -263,11 +273,10 @@ XExtDisplayInfo *info = XInput_find_display (dpy); XEvent *save = (XEvent *) info->data; + type = event->u.u.type & 0x7f; reltype = (type - info->codes->first_event); - - if (reltype != XI_DeviceValuator && reltype != XI_DeviceKeystateNotify && reltype != XI_DeviceButtonstateNotify) @@ -654,6 +663,23 @@ return (ENQUEUE_EVENT); } break; + + case XI_DevicePresenceNotify: + { + XDevicePresenceNotifyEvent *ev = + (XDevicePresenceNotifyEvent *) re; + devicePresenceNotify *ev2 = (devicePresenceNotify *) event; + + fprintf(stderr, "got DevicePresenceNotify event (reltype=%d)\n", + reltype); + + *ev = *(XDevicePresenceNotifyEvent *) save; + ev->window = 0; + ev->time = ev2->time; + return (ENQUEUE_EVENT); + } + break; + default: printf ("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",type); break; --- lib-old/Xi/src/XIint.h 2004-04-23 14:43:44.000000000 -0400 +++ lib/Xi/src/XIint.h 2005-12-25 21:24:39.000000000 -0500 @@ -22,4 +22,6 @@ _Xconst char* ); +extern int _XiPutString(Display *dpy, _Xconst char *s); + #endif --- lib-old/Xi/src/XRmDev.c 1969-12-31 19:00:00.000000000 -0500 +++ lib/Xi/src/XRmDev.c 2005-12-25 21:24:39.000000000 -0500 @@ -0,0 +1,53 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Kristian Høgsberg (krh@redhat.com) + */ + +#include +#include +#include +#include +#include +#include "XIint.h" + + +int +XRemoveInputDevice(Display *dpy, _Xconst char *name) +{ + xRemoveInputDeviceReq *req; + xRemoveInputDeviceReply rep; + XExtDisplayInfo *info = XInput_find_display (dpy); + + LockDisplay (dpy); + if (_XiCheckExtInit(dpy, XInput_Add_XAddInputDevice) == -1) + return NoSuchExtension; + + GetReq(RemoveInputDevice,req); + req->reqType = info->codes->major_opcode; + req->ReqType = X_RemoveInputDevice; + req->length += _XiPutString(dpy, name); + + _XReply (dpy, (xReply *) &rep, 0, xFalse); + UnlockDisplay(dpy); + SyncHandle(); + + return rep.status; +}