From 3425b16d521b8846b95df2b7d32a548d93341f3b Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 14 Nov 2010 21:29:32 +0000 Subject: xserver pixman libX11 libXext 14/11/2010 --- xorg-server/Xi/closedev.c | 1 - xorg-server/Xi/exevents.c | 21 +- xorg-server/Xi/extinit.c | 4 +- xorg-server/Xi/listdev.c | 10 +- xorg-server/Xi/opendev.c | 1 - xorg-server/Xi/queryst.c | 3 +- xorg-server/Xi/setmode.c | 292 ++++++++++----------- xorg-server/Xi/stubs.c | 90 ------- xorg-server/Xi/xichangehierarchy.c | 522 ++++++++++++++++++++----------------- xorg-server/Xi/xiquerydevice.c | 2 +- 10 files changed, 443 insertions(+), 503 deletions(-) (limited to 'xorg-server/Xi') diff --git a/xorg-server/Xi/closedev.c b/xorg-server/Xi/closedev.c index fcd0ed832..60f5aebe5 100644 --- a/xorg-server/Xi/closedev.c +++ b/xorg-server/Xi/closedev.c @@ -162,6 +162,5 @@ ProcXCloseDevice(ClientPtr client) DeleteEventsFromChildren(d, p1, client); } - CloseInputDevice(d, client); return Success; } diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c index fcb7e584b..6cb9c0dac 100644 --- a/xorg-server/Xi/exevents.c +++ b/xorg-server/Xi/exevents.c @@ -111,13 +111,6 @@ XIShouldNotify(ClientPtr client, DeviceIntPtr dev) return 0; } -void -RegisterOtherDevice(DeviceIntPtr device) -{ - device->public.processInputProc = ProcessOtherEvent; - device->public.realInputProc = ProcessOtherEvent; -} - Bool IsPointerEvent(InternalEvent* event) { @@ -563,7 +556,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) v->axisVal = (double*)(v->axes + from->valuator->numAxes); v->sourceid = from->id; - v->mode = from->valuator->mode; } else if (to->valuator && !from->valuator) { ClassesPtr classes; @@ -898,9 +890,9 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) mask = PointerMotionMask | b->state | b->motionMask; SetMaskForEvent(device->id, mask, MotionNotify); } else if (event->type == ET_ProximityIn) - device->valuator->mode &= ~OutOfProximity; + device->proximity->in_proximity = TRUE; else if (event->type == ET_ProximityOut) - device->valuator->mode |= OutOfProximity; + device->proximity->in_proximity = FALSE; return DEFAULT; } @@ -1119,6 +1111,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) if (!proxc) return FALSE; proxc->sourceid = dev->id; + proxc->in_proximity = TRUE; dev->proximity = proxc; return TRUE; } @@ -1134,7 +1127,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) */ void InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval, - int resolution, int min_res, int max_res) + int resolution, int min_res, int max_res, int mode) { AxisInfoPtr ax; @@ -1151,6 +1144,10 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int ax->min_resolution = min_res; ax->max_resolution = max_res; ax->label = label; + ax->mode = mode; + + if (mode & OutOfProximity) + dev->proximity->in_proximity = FALSE; } static void @@ -1179,7 +1176,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, int nval = v->numAxes - first; ev->classes_reported |= (1 << ValuatorClass); - ev->classes_reported |= (dev->valuator->mode << ModeBitsShift); + ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift; ev->num_valuators = nval < 3 ? nval : 3; switch (ev->num_valuators) { case 3: diff --git a/xorg-server/Xi/extinit.c b/xorg-server/Xi/extinit.c index dd72ee2b0..a6408fbb3 100644 --- a/xorg-server/Xi/extinit.c +++ b/xorg-server/Xi/extinit.c @@ -1120,8 +1120,6 @@ RestoreExtensionEvents(void) static void IResetProc(ExtensionEntry * unused) { - XIResetProperties(); - ReplySwapVector[IReqCode] = ReplyNotSwappd; EventSwapVector[DeviceValuator] = NotImplemented; EventSwapVector[DeviceKeyPress] = NotImplemented; @@ -1301,6 +1299,8 @@ XInputExtensionInit(void) inputInfo.all_devices = &xi_all_devices; inputInfo.all_master_devices = &xi_all_master_devices; + + XIResetProperties(); } else { FatalError("IExtensionInit: AddExtensions failed\n"); } diff --git a/xorg-server/Xi/listdev.c b/xorg-server/Xi/listdev.c index d84dcd8d9..da7529f1e 100644 --- a/xorg-server/Xi/listdev.c +++ b/xorg-server/Xi/listdev.c @@ -230,10 +230,11 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf) */ static int -CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf) +CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf) { int i, j, axes, t_axes; char n; + ValuatorClassPtr v = dev->valuator; xValuatorInfoPtr v2; AxisInfo *a; xAxisInfoPtr a2; @@ -247,7 +248,7 @@ CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf) v2->class = ValuatorClass; v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo); v2->num_axes = t_axes; - v2->mode = v->mode & DeviceMode; + v2->mode = valuator_get_mode(dev, 0); v2->motion_buffer_size = v->numMotionEvents; if (client && client->swapped) { swapl(&v2->motion_buffer_size, n); @@ -286,7 +287,7 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes, } if (dev->valuator != NULL) { (*num_classes) += - CopySwapValuatorClass(client, dev->valuator, classbuf); + CopySwapValuatorClass(client, dev, classbuf); } } @@ -356,9 +357,6 @@ ProcXListInputDevices(ClientPtr client) rep.length = 0; rep.sequenceNumber = client->sequence; - - AddOtherInputDevices(); - /* allocate space for saving skip value */ skip = calloc(sizeof(Bool), inputInfo.numDevices); if (!skip) diff --git a/xorg-server/Xi/opendev.c b/xorg-server/Xi/opendev.c index 092b464ee..273cb2404 100644 --- a/xorg-server/Xi/opendev.c +++ b/xorg-server/Xi/opendev.c @@ -115,7 +115,6 @@ ProcXOpenDevice(ClientPtr client) if (IsMaster(dev)) return BadDevice; - OpenInputDevice(dev, client, &status); if (status != Success) return status; diff --git a/xorg-server/Xi/queryst.c b/xorg-server/Xi/queryst.c index 15d44592e..4810ed7f1 100644 --- a/xorg-server/Xi/queryst.c +++ b/xorg-server/Xi/queryst.c @@ -151,7 +151,8 @@ ProcXQueryDeviceState(ClientPtr client) tv->class = ValuatorClass; tv->length = sizeof(xValuatorState) + v->numAxes * 4; tv->num_valuators = v->numAxes; - tv->mode = v->mode; + tv->mode = valuator_get_mode(dev, 0); + tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0; buf += sizeof(xValuatorState); for (i = 0, values = v->axisVal; i < v->numAxes; i++) { if (rc != BadAccess) diff --git a/xorg-server/Xi/setmode.c b/xorg-server/Xi/setmode.c index ce2ad47c7..9f88eacf6 100644 --- a/xorg-server/Xi/setmode.c +++ b/xorg-server/Xi/setmode.c @@ -1,146 +1,146 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -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 Hewlett-Packard not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -HEWLETT-PACKARD 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. - -********************************************************/ - -/*********************************************************************** - * - * Request to change the mode of an extension input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "inputstr.h" /* DeviceIntPtr */ -#include -#include -#include "XIstubs.h" -#include "exglobals.h" - -#include "setmode.h" - -/*********************************************************************** - * - * Handle a request from a client with a different byte order. - * - */ - -int -SProcXSetDeviceMode(ClientPtr client) -{ - char n; - - REQUEST(xSetDeviceModeReq); - swaps(&stuff->length, n); - return (ProcXSetDeviceMode(client)); -} - -/*********************************************************************** - * - * This procedure sets the mode of a device. - * - */ - -int -ProcXSetDeviceMode(ClientPtr client) -{ - DeviceIntPtr dev; - xSetDeviceModeReply rep; - int rc; - - REQUEST(xSetDeviceModeReq); - REQUEST_SIZE_MATCH(xSetDeviceModeReq); - - rep.repType = X_Reply; - rep.RepType = X_SetDeviceMode; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess); - if (rc != Success) - return rc; - if (dev->valuator == NULL) - return BadMatch; - if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) - rep.status = AlreadyGrabbed; - else - rep.status = SetDeviceMode(client, dev, stuff->mode); - - if (rep.status == Success) - dev->valuator->mode = stuff->mode; - else if (rep.status != AlreadyGrabbed) - { - switch(rep.status) { - case BadMatch: - case BadImplementation: - case BadAlloc: - break; - default: - rep.status = BadMode; - } - return rep.status; - } - - WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep); - return Success; -} - -/*********************************************************************** - * - * This procedure writes the reply for the XSetDeviceMode function, - * if the client and server have a different byte ordering. - * - */ - -void -SRepXSetDeviceMode(ClientPtr client, int size, xSetDeviceModeReply * rep) -{ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} +/************************************************************ + +Copyright 1989, 1998 The Open Group + +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. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Hewlett-Packard not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +HEWLETT-PACKARD 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. + +********************************************************/ + +/*********************************************************************** + * + * Request to change the mode of an extension input device. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#include "XIstubs.h" +#include "exglobals.h" + +#include "setmode.h" + +/*********************************************************************** + * + * Handle a request from a client with a different byte order. + * + */ + +int +SProcXSetDeviceMode(ClientPtr client) +{ + char n; + + REQUEST(xSetDeviceModeReq); + swaps(&stuff->length, n); + return (ProcXSetDeviceMode(client)); +} + +/*********************************************************************** + * + * This procedure sets the mode of a device. + * + */ + +int +ProcXSetDeviceMode(ClientPtr client) +{ + DeviceIntPtr dev; + xSetDeviceModeReply rep; + int rc; + + REQUEST(xSetDeviceModeReq); + REQUEST_SIZE_MATCH(xSetDeviceModeReq); + + rep.repType = X_Reply; + rep.RepType = X_SetDeviceMode; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess); + if (rc != Success) + return rc; + if (dev->valuator == NULL) + return BadMatch; + if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) + rep.status = AlreadyGrabbed; + else + rep.status = SetDeviceMode(client, dev, stuff->mode); + + if (rep.status == Success) + valuator_set_mode(dev, VALUATOR_MODE_ALL_AXES, stuff->mode); + else if (rep.status != AlreadyGrabbed) + { + switch(rep.status) { + case BadMatch: + case BadImplementation: + case BadAlloc: + break; + default: + rep.status = BadMode; + } + return rep.status; + } + + WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep); + return Success; +} + +/*********************************************************************** + * + * This procedure writes the reply for the XSetDeviceMode function, + * if the client and server have a different byte ordering. + * + */ + +void +SRepXSetDeviceMode(ClientPtr client, int size, xSetDeviceModeReply * rep) +{ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + WriteToClient(client, size, (char *)rep); +} diff --git a/xorg-server/Xi/stubs.c b/xorg-server/Xi/stubs.c index 4921b36f9..f69b34b2e 100644 --- a/xorg-server/Xi/stubs.c +++ b/xorg-server/Xi/stubs.c @@ -66,96 +66,6 @@ SOFTWARE. #include "XIstubs.h" #include "xace.h" -/*********************************************************************** - * - * Caller: ProcXCloseDevice - * - * Take care of implementation-dependent details of closing a device. - * Some implementations may actually close the device, others may just - * remove this clients interest in that device. - * - * The default implementation is to do nothing (assume all input devices - * are initialized during X server initialization and kept open). - * - */ - -void -CloseInputDevice(DeviceIntPtr d, ClientPtr client) -{ -} - -/*********************************************************************** - * - * Caller: ProcXListInputDevices - * - * This is the implementation-dependent routine to initialize an input - * device to the point that information about it can be listed. - * Some implementations open all input devices when the server is first - * initialized, and never close them. Other implementations open only - * the X pointer and keyboard devices during server initialization, - * and only open other input devices when some client makes an - * XOpenDevice request. If some other process has the device open, the - * server may not be able to get information about the device to list it. - * - * This procedure should be used by implementations that do not initialize - * all input devices at server startup. It should do device-dependent - * initialization for any devices not previously initialized, and call - * AddInputDevice for each of those devices so that a DeviceIntRec will be - * created for them. - * - * The default implementation is to do nothing (assume all input devices - * are initialized during X server initialization and kept open). - * The commented-out sample code shows what you might do if you don't want - * the default. - * - */ - -void -AddOtherInputDevices(void) -{ - /********************************************************************** - for each uninitialized device, do something like: - - DeviceIntPtr dev; - DeviceProc deviceProc; - pointer private; - - dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE); - dev->public.devicePrivate = private; - RegisterOtherDevice(dev); - dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success); - ************************************************************************/ - -} - -/*********************************************************************** - * - * Caller: ProcXOpenDevice - * - * This is the implementation-dependent routine to open an input device. - * Some implementations open all input devices when the server is first - * initialized, and never close them. Other implementations open only - * the X pointer and keyboard devices during server initialization, - * and only open other input devices when some client makes an - * XOpenDevice request. This entry point is for the latter type of - * implementation. - * - * If the physical device is not already open, do it here. In this case, - * you need to keep track of the fact that one or more clients has the - * device open, and physically close it when the last client that has - * it open does an XCloseDevice. - * - * The default implementation is to do nothing (assume all input devices - * are opened during X server initialization and kept open). - * - */ - -void -OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status) -{ - *status = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixUseAccess); -} - /**************************************************************************** * * Caller: ProcXSetDeviceMode diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c index 5deb52eac..6b0288c88 100644 --- a/xorg-server/Xi/xichangehierarchy.c +++ b/xorg-server/Xi/xichangehierarchy.c @@ -136,12 +136,286 @@ int SProcXIChangeHierarchy(ClientPtr client) return (ProcXIChangeHierarchy(client)); } +static int +add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) +{ + DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; + char* name; + int rc; + + name = calloc(c->name_len + 1, sizeof(char)); + strncpy(name, (char*)&c[1], c->name_len); + + rc = AllocDevicePair(client, name, &ptr, &keybd, + CorePointerProc, CoreKeyboardProc, TRUE); + if (rc != Success) + goto unwind; + + if (!c->send_core) + ptr->coreEvents = keybd->coreEvents = FALSE; + + /* Allocate virtual slave devices for xtest events */ + rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd); + if (rc != Success) + { + DeleteInputDeviceRequest(ptr); + DeleteInputDeviceRequest(keybd); + goto unwind; + } + + ActivateDevice(ptr, FALSE); + ActivateDevice(keybd, FALSE); + flags[ptr->id] |= XIMasterAdded; + flags[keybd->id] |= XIMasterAdded; + + ActivateDevice(XTestptr, FALSE); + ActivateDevice(XTestkeybd, FALSE); + flags[XTestptr->id] |= XISlaveAdded; + flags[XTestkeybd->id] |= XISlaveAdded; + + if (c->enable) + { + EnableDevice(ptr, FALSE); + EnableDevice(keybd, FALSE); + flags[ptr->id] |= XIDeviceEnabled; + flags[keybd->id] |= XIDeviceEnabled; + + EnableDevice(XTestptr, FALSE); + EnableDevice(XTestkeybd, FALSE); + flags[XTestptr->id] |= XIDeviceEnabled; + flags[XTestkeybd->id] |= XIDeviceEnabled; + } + + /* Attach the XTest virtual devices to the newly + created master device */ + AttachDevice(NULL, XTestptr, ptr); + AttachDevice(NULL, XTestkeybd, keybd); + flags[XTestptr->id] |= XISlaveAttached; + flags[XTestkeybd->id] |= XISlaveAttached; + +unwind: + free(name); + return rc; +} + +static int +remove_master(ClientPtr client, xXIRemoveMasterInfo *r, + int flags[MAXDEVICES]) +{ + DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; + int rc = Success; + + if (r->return_mode != XIAttachToMaster && + r->return_mode != XIFloating) + return BadValue; + + rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess); + if (rc != Success) + goto unwind; + + if (!IsMaster(ptr)) + { + client->errorValue = r->deviceid; + rc = BadDevice; + goto unwind; + } + + /* XXX: For now, don't allow removal of VCP, VCK */ + if (ptr == inputInfo.pointer || ptr == inputInfo.keyboard) + { + rc = BadDevice; + goto unwind; + } + + + ptr = GetMaster(ptr, MASTER_POINTER); + rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess); + if (rc != Success) + goto unwind; + keybd = GetMaster(ptr, MASTER_KEYBOARD); + rc = dixLookupDevice(&keybd, keybd->id, client, DixDestroyAccess); + if (rc != Success) + goto unwind; + + XTestptr = GetXTestDevice(ptr); + rc = dixLookupDevice(&XTestptr, XTestptr->id, client, DixDestroyAccess); + if (rc != Success) + goto unwind; + + XTestkeybd = GetXTestDevice(keybd); + rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, + DixDestroyAccess); + if (rc != Success) + goto unwind; + + /* Disabling sends the devices floating, reattach them if + * desired. */ + if (r->return_mode == XIAttachToMaster) + { + DeviceIntPtr attached, + newptr, + newkeybd; + + rc = dixLookupDevice(&newptr, r->return_pointer, client, DixAddAccess); + if (rc != Success) + goto unwind; + + if (!IsMaster(newptr)) + { + client->errorValue = r->return_pointer; + rc = BadDevice; + goto unwind; + } + + rc = dixLookupDevice(&newkeybd, r->return_keyboard, + client, DixAddAccess); + if (rc != Success) + goto unwind; + + if (!IsMaster(newkeybd)) + { + client->errorValue = r->return_keyboard; + rc = BadDevice; + goto unwind; + } + + for (attached = inputInfo.devices; attached; attached = attached->next) + { + if (!IsMaster(attached)) { + if (attached->u.master == ptr) + { + AttachDevice(client, attached, newptr); + flags[attached->id] |= XISlaveAttached; + } + if (attached->u.master == keybd) + { + AttachDevice(client, attached, newkeybd); + flags[attached->id] |= XISlaveAttached; + } + } + } + } + + /* can't disable until we removed pairing */ + keybd->spriteInfo->paired = NULL; + ptr->spriteInfo->paired = NULL; + XTestptr->spriteInfo->paired = NULL; + XTestkeybd->spriteInfo->paired = NULL; + + /* disable the remove the devices, XTest devices must be done first + else the sprites they rely on will be destroyed */ + DisableDevice(XTestptr, FALSE); + DisableDevice(XTestkeybd, FALSE); + DisableDevice(keybd, FALSE); + DisableDevice(ptr, FALSE); + flags[XTestptr->id] |= XIDeviceDisabled | XISlaveDetached; + flags[XTestkeybd->id] |= XIDeviceDisabled | XISlaveDetached; + flags[keybd->id] |= XIDeviceDisabled; + flags[ptr->id] |= XIDeviceDisabled; + + RemoveDevice(XTestptr, FALSE); + RemoveDevice(XTestkeybd, FALSE); + RemoveDevice(keybd, FALSE); + RemoveDevice(ptr, FALSE); + flags[XTestptr->id] |= XISlaveRemoved; + flags[XTestkeybd->id] |= XISlaveRemoved; + flags[keybd->id] |= XIMasterRemoved; + flags[ptr->id] |= XIMasterRemoved; + +unwind: + return rc; +} + +static int +detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES]) +{ + DeviceIntPtr dev; + int rc; + + rc = dixLookupDevice(&dev, c->deviceid, client, DixManageAccess); + if (rc != Success) + goto unwind; + + if (IsMaster(dev)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + /* Don't allow changes to XTest Devices, these are fixed */ + if (IsXTestDevice(dev, NULL)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + AttachDevice(client, dev, NULL); + flags[dev->id] |= XISlaveDetached; + +unwind: + return rc; +} + +static int +attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, + int flags[MAXDEVICES]) +{ + DeviceIntPtr dev; + DeviceIntPtr newmaster; + int rc; + + rc = dixLookupDevice(&dev, c->deviceid, client, DixManageAccess); + if (rc != Success) + goto unwind; + + if (IsMaster(dev)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + /* Don't allow changes to XTest Devices, these are fixed */ + if (IsXTestDevice(dev, NULL)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + rc = dixLookupDevice(&newmaster, c->new_master, client, DixAddAccess); + if (rc != Success) + goto unwind; + if (!IsMaster(newmaster)) + { + client->errorValue = c->new_master; + rc = BadDevice; + goto unwind; + } + + if (!((IsPointerDevice(newmaster) && IsPointerDevice(dev)) || + (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) + { + rc = BadDevice; + goto unwind; + } + + AttachDevice(client, dev, newmaster); + flags[dev->id] |= XISlaveAttached; + +unwind: + return rc; +} + + + #define SWAPIF(cmd) if (client->swapped) { cmd; } int ProcXIChangeHierarchy(ClientPtr client) { - DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; xXIAnyHierarchyChangeInfo *any; int required_len = sizeof(xXIChangeHierarchyReq); char n; @@ -169,276 +443,38 @@ ProcXIChangeHierarchy(ClientPtr client) case XIAddMaster: { xXIAddMasterInfo* c = (xXIAddMasterInfo*)any; - char* name; - SWAPIF(swaps(&c->name_len, n)); - name = calloc(c->name_len + 1, sizeof(char)); - strncpy(name, (char*)&c[1], c->name_len); - - - rc = AllocDevicePair(client, name, &ptr, &keybd, - CorePointerProc, CoreKeyboardProc, - TRUE); - if (rc != Success) - { - free(name); - goto unwind; - } - - if (!c->send_core) - ptr->coreEvents = keybd->coreEvents = FALSE; - /* Allocate virtual slave devices for xtest events */ - rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, - ptr, keybd); + rc = add_master(client, c, flags); if (rc != Success) - { - - free(name); goto unwind; - } - - ActivateDevice(ptr, FALSE); - ActivateDevice(keybd, FALSE); - flags[ptr->id] |= XIMasterAdded; - flags[keybd->id] |= XIMasterAdded; - - ActivateDevice(XTestptr, FALSE); - ActivateDevice(XTestkeybd, FALSE); - flags[XTestptr->id] |= XISlaveAdded; - flags[XTestkeybd->id] |= XISlaveAdded; - - if (c->enable) - { - EnableDevice(ptr, FALSE); - EnableDevice(keybd, FALSE); - flags[ptr->id] |= XIDeviceEnabled; - flags[keybd->id] |= XIDeviceEnabled; - - EnableDevice(XTestptr, FALSE); - EnableDevice(XTestkeybd, FALSE); - flags[XTestptr->id] |= XIDeviceEnabled; - flags[XTestkeybd->id] |= XIDeviceEnabled; - } - - /* Attach the XTest virtual devices to the newly - created master device */ - AttachDevice(NULL, XTestptr, ptr); - AttachDevice(NULL, XTestkeybd, keybd); - flags[XTestptr->id] |= XISlaveAttached; - flags[XTestkeybd->id] |= XISlaveAttached; - - free(name); } break; case XIRemoveMaster: { xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; - if (r->return_mode != XIAttachToMaster && - r->return_mode != XIFloating) - return BadValue; - - rc = dixLookupDevice(&ptr, r->deviceid, client, - DixDestroyAccess); + rc = remove_master(client, r, flags); if (rc != Success) goto unwind; - - if (!IsMaster(ptr)) - { - client->errorValue = r->deviceid; - rc = BadDevice; - goto unwind; - } - - /* XXX: For now, don't allow removal of VCP, VCK */ - if (ptr == inputInfo.pointer || - ptr == inputInfo.keyboard) - { - rc = BadDevice; - goto unwind; - } - - - ptr = GetMaster(ptr, MASTER_POINTER); - rc = dixLookupDevice(&ptr, - ptr->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - keybd = GetMaster(ptr, MASTER_KEYBOARD); - rc = dixLookupDevice(&keybd, - keybd->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - XTestptr = GetXTestDevice(ptr); - rc = dixLookupDevice(&XTestptr, XTestptr->id, client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - XTestkeybd = GetXTestDevice(keybd); - rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - /* Disabling sends the devices floating, reattach them if - * desired. */ - if (r->return_mode == XIAttachToMaster) - { - DeviceIntPtr attached, - newptr, - newkeybd; - - rc = dixLookupDevice(&newptr, r->return_pointer, - client, DixAddAccess); - if (rc != Success) - goto unwind; - - if (!IsMaster(newptr)) - { - client->errorValue = r->return_pointer; - rc = BadDevice; - goto unwind; - } - - rc = dixLookupDevice(&newkeybd, r->return_keyboard, - client, DixAddAccess); - if (rc != Success) - goto unwind; - - if (!IsMaster(newkeybd)) - { - client->errorValue = r->return_keyboard; - rc = BadDevice; - goto unwind; - } - - for (attached = inputInfo.devices; - attached; - attached = attached->next) - { - if (!IsMaster(attached)) { - if (attached->u.master == ptr) - { - AttachDevice(client, attached, newptr); - flags[attached->id] |= XISlaveAttached; - } - if (attached->u.master == keybd) - { - AttachDevice(client, attached, newkeybd); - flags[attached->id] |= XISlaveAttached; - } - } - } - } - - /* can't disable until we removed pairing */ - keybd->spriteInfo->paired = NULL; - ptr->spriteInfo->paired = NULL; - XTestptr->spriteInfo->paired = NULL; - XTestkeybd->spriteInfo->paired = NULL; - - /* disable the remove the devices, XTest devices must be done first - else the sprites they rely on will be destroyed */ - DisableDevice(XTestptr, FALSE); - DisableDevice(XTestkeybd, FALSE); - DisableDevice(keybd, FALSE); - DisableDevice(ptr, FALSE); - flags[XTestptr->id] |= XIDeviceDisabled | XISlaveDetached; - flags[XTestkeybd->id] |= XIDeviceDisabled | XISlaveDetached; - flags[keybd->id] |= XIDeviceDisabled; - flags[ptr->id] |= XIDeviceDisabled; - - RemoveDevice(XTestptr, FALSE); - RemoveDevice(XTestkeybd, FALSE); - RemoveDevice(keybd, FALSE); - RemoveDevice(ptr, FALSE); - flags[XTestptr->id] |= XISlaveRemoved; - flags[XTestkeybd->id] |= XISlaveRemoved; - flags[keybd->id] |= XIMasterRemoved; - flags[ptr->id] |= XIMasterRemoved; } break; case XIDetachSlave: { xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; - rc = dixLookupDevice(&ptr, c->deviceid, client, - DixManageAccess); + rc = detach_slave(client, c, flags); if (rc != Success) goto unwind; - - if (IsMaster(ptr)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - /* Don't allow changes to XTest Devices, these are fixed */ - if (IsXTestDevice(ptr, NULL)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - AttachDevice(client, ptr, NULL); - flags[ptr->id] |= XISlaveDetached; } break; case XIAttachSlave: { xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any; - DeviceIntPtr newmaster; - rc = dixLookupDevice(&ptr, c->deviceid, client, - DixManageAccess); + rc = attach_slave(client, c, flags); if (rc != Success) goto unwind; - - if (IsMaster(ptr)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - /* Don't allow changes to XTest Devices, these are fixed */ - if (IsXTestDevice(ptr, NULL)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - rc = dixLookupDevice(&newmaster, c->new_master, - client, DixAddAccess); - if (rc != Success) - goto unwind; - if (!IsMaster(newmaster)) - { - client->errorValue = c->new_master; - rc = BadDevice; - goto unwind; - } - - if (!((IsPointerDevice(newmaster) && - IsPointerDevice(ptr)) || - (IsKeyboardDevice(newmaster) && - IsKeyboardDevice(ptr)))) - { - rc = BadDevice; - goto unwind; - } - AttachDevice(client, ptr, newmaster); - flags[ptr->id] |= XISlaveAttached; } break; } diff --git a/xorg-server/Xi/xiquerydevice.c b/xorg-server/Xi/xiquerydevice.c index c24f8a894..4e1cae406 100644 --- a/xorg-server/Xi/xiquerydevice.c +++ b/xorg-server/Xi/xiquerydevice.c @@ -349,7 +349,7 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, info->value.frac = (int)(v->axisVal[axisnumber] * (1 << 16) * (1 << 16)); info->resolution = v->axes[axisnumber].resolution; info->number = axisnumber; - info->mode = v->mode; /* Server doesn't have per-axis mode yet */ + info->mode = valuator_get_mode(dev, axisnumber); info->sourceid = v->sourceid; if (!reportState) -- cgit v1.2.3