From d230742ea820a21a3f1ed0c58b5e6d8680b2f2aa Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 16 Jun 2009 12:13:16 +1000 Subject: Xi: namespace XI2 files. Some files (notably those merged with MPX before XI2 came along) didn't use a 'xi' prefix. This patch changes all of them to meaningful names. Signed-off-by: Peter Hutterer --- Xi/Makefile.am | 34 +-- Xi/chdevcur.c | 113 ---------- Xi/chdevcur.h | 36 ---- Xi/chdevhier.c | 540 ------------------------------------------------ Xi/chdevhier.h | 44 ---- Xi/exevents.c | 2 +- Xi/extinit.c | 16 +- Xi/getcptr.c | 106 ---------- Xi/getcptr.h | 38 ---- Xi/querydev.c | 451 ---------------------------------------- Xi/querydev.h | 45 ---- Xi/querydp.c | 210 ------------------- Xi/querydp.h | 39 ---- Xi/queryversion.c | 128 ------------ Xi/queryversion.h | 40 ---- Xi/setcptr.c | 113 ---------- Xi/setcptr.h | 36 ---- Xi/warpdevp.c | 179 ---------------- Xi/warpdevp.h | 36 ---- Xi/xichangecursor.c | 113 ++++++++++ Xi/xichangecursor.h | 36 ++++ Xi/xichangehierarchy.c | 540 ++++++++++++++++++++++++++++++++++++++++++++++++ Xi/xichangehierarchy.h | 44 ++++ Xi/xigetclientpointer.c | 106 ++++++++++ Xi/xigetclientpointer.h | 38 ++++ Xi/xiquerydevice.c | 451 ++++++++++++++++++++++++++++++++++++++++ Xi/xiquerydevice.h | 45 ++++ Xi/xiquerypointer.c | 210 +++++++++++++++++++ Xi/xiquerypointer.h | 39 ++++ Xi/xiqueryversion.c | 128 ++++++++++++ Xi/xiqueryversion.h | 40 ++++ Xi/xisetclientpointer.c | 113 ++++++++++ Xi/xisetclientpointer.h | 36 ++++ Xi/xiwarppointer.c | 179 ++++++++++++++++ Xi/xiwarppointer.h | 36 ++++ dix/devices.c | 4 +- dix/eventconvert.c | 2 +- 37 files changed, 2183 insertions(+), 2183 deletions(-) delete mode 100644 Xi/chdevcur.c delete mode 100644 Xi/chdevcur.h delete mode 100644 Xi/chdevhier.c delete mode 100644 Xi/chdevhier.h delete mode 100644 Xi/getcptr.c delete mode 100644 Xi/getcptr.h delete mode 100644 Xi/querydev.c delete mode 100644 Xi/querydev.h delete mode 100644 Xi/querydp.c delete mode 100644 Xi/querydp.h delete mode 100644 Xi/queryversion.c delete mode 100644 Xi/queryversion.h delete mode 100644 Xi/setcptr.c delete mode 100644 Xi/setcptr.h delete mode 100644 Xi/warpdevp.c delete mode 100644 Xi/warpdevp.h create mode 100644 Xi/xichangecursor.c create mode 100644 Xi/xichangecursor.h create mode 100644 Xi/xichangehierarchy.c create mode 100644 Xi/xichangehierarchy.h create mode 100644 Xi/xigetclientpointer.c create mode 100644 Xi/xigetclientpointer.h create mode 100644 Xi/xiquerydevice.c create mode 100644 Xi/xiquerydevice.h create mode 100644 Xi/xiquerypointer.c create mode 100644 Xi/xiquerypointer.h create mode 100644 Xi/xiqueryversion.c create mode 100644 Xi/xiqueryversion.h create mode 100644 Xi/xisetclientpointer.c create mode 100644 Xi/xisetclientpointer.h create mode 100644 Xi/xiwarppointer.c create mode 100644 Xi/xiwarppointer.h diff --git a/Xi/Makefile.am b/Xi/Makefile.am index 56404b6eb..69c7886b9 100644 --- a/Xi/Makefile.am +++ b/Xi/Makefile.am @@ -5,12 +5,8 @@ AM_CFLAGS = $(DIX_CFLAGS) libXi_la_SOURCES = \ allowev.c \ allowev.h \ - chdevcur.c \ - chdevcur.h \ chgdctl.c \ chgdctl.h \ - chdevhier.c \ - chdevhier.h \ chgfctl.c \ chgfctl.h \ chgkbd.c \ @@ -30,8 +26,6 @@ libXi_la_SOURCES = \ extinit.c \ getbmap.c \ getbmap.h \ - getcptr.c \ - getcptr.h \ getdctl.c \ getdctl.h \ getfctl.c \ @@ -60,12 +54,6 @@ libXi_la_SOURCES = \ listdev.h \ opendev.c \ opendev.h \ - querydev.c \ - querydev.h \ - queryversion.h \ - queryversion.c \ - querydp.c \ - querydp.h \ queryst.c \ queryst.h \ selectev.c \ @@ -74,8 +62,6 @@ libXi_la_SOURCES = \ sendexev.h \ setbmap.c \ setbmap.h \ - setcptr.c \ - setcptr.h \ setdval.c \ setdval.h \ setfocus.c \ @@ -90,19 +76,33 @@ libXi_la_SOURCES = \ ungrdevb.h \ ungrdevk.c \ ungrdevk.h \ - warpdevp.c \ - warpdevp.h \ xiallowev.c \ xiallowev.h \ + xichangecursor.c \ + xichangecursor.h \ + xichangehierarchy.c \ + xichangehierarchy.h \ + xigetclientpointer.c \ + xigetclientpointer.h \ xigrabdev.c \ xigrabdev.h \ xipassivegrab.h \ xipassivegrab.c \ xiproperty.c \ xiproperty.h \ + xiquerydevice.c \ + xiquerydevice.h \ + xiquerypointer.c \ + xiquerypointer.h \ + xiqueryversion.c \ + xiqueryversion.h \ xiselectev.c \ xiselectev.h \ + xisetclientpointer.c \ + xisetclientpointer.h \ xisetdevfocus.c \ - xisetdevfocus.h + xisetdevfocus.h \ + xiwarppointer.c \ + xiwarppointer.h EXTRA_DIST = stubs.c diff --git a/Xi/chdevcur.c b/Xi/chdevcur.c deleted file mode 100644 index 9dba78b36..000000000 --- a/Xi/chdevcur.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request to change a given device pointer's cursor. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include -#include -#include "extnsionst.h" -#include "exevents.h" -#include "exglobals.h" -#include "input.h" - -#include "chdevcur.h" - -/*********************************************************************** - * - * This procedure allows a client to set one pointer's cursor. - * - */ - -int -SProcXIChangeCursor(ClientPtr client) -{ - char n; - - REQUEST(xXIChangeCursorReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xXIChangeCursorReq); - return (ProcXIChangeCursor(client)); -} - -int ProcXIChangeCursor(ClientPtr client) -{ - int rc; - WindowPtr pWin = NULL; - DeviceIntPtr pDev = NULL; - CursorPtr pCursor = NULL; - - REQUEST(xXIChangeCursorReq); - REQUEST_SIZE_MATCH(xXIChangeCursorReq); - - if (stuff->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = stuff->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess); - if (rc != Success) - return rc; - - if (stuff->win != None) - { - rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess); - if (rc != Success) - return rc; - } - - if (stuff->cursor == None) - { - if (pWin == WindowTable[pWin->drawable.pScreen->myNum]) - pCursor = rootCursor; - else - pCursor = (CursorPtr)None; - } - else - { - rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, - RT_CURSOR, client, DixReadAccess); - if (rc != Success) - return (rc == BadValue) ? BadCursor : rc; - } - - ChangeWindowDeviceCursor(pWin, pDev, pCursor); - - return Success; -} - diff --git a/Xi/chdevcur.h b/Xi/chdevcur.h deleted file mode 100644 index dc6ccb1af..000000000 --- a/Xi/chdevcur.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef CHDEVCUR_H -#define CHDEVCUR_H 1 - -int SProcXIChangeCursor(ClientPtr /* client */); -int ProcXIChangeCursor(ClientPtr /* client */); - -#endif /* CHDEVCUR_H */ diff --git a/Xi/chdevhier.c b/Xi/chdevhier.c deleted file mode 100644 index 3f2bb9377..000000000 --- a/Xi/chdevhier.c +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * Copyright 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request change in the device hierarchy. - * - */ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include -#include -#include -#include "extnsionst.h" -#include "exevents.h" -#include "exglobals.h" -#include "geext.h" -#include "xace.h" -#include "querydev.h" /* for GetDeviceUse */ - -#include "xkbsrv.h" - -#include "chdevhier.h" - -extern DevPrivateKey XTstDevicePrivateKey; - -/** - * Send the current state of the device hierarchy to all clients. - */ -void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) -{ - xXIHierarchyEvent *ev; - xXIHierarchyInfo *info; - DeviceIntRec dummyDev; - DeviceIntPtr dev; - int i; - - if (!flags) - return; - - ev = xcalloc(1, sizeof(xXIHierarchyEvent) + - MAXDEVICES * sizeof(xXIHierarchyInfo)); - ev->type = GenericEvent; - ev->extension = IReqCode; - ev->evtype = XI_HierarchyChanged; - ev->time = GetTimeInMillis(); - ev->flags = 0; - ev->num_info = inputInfo.numDevices; - - info = (xXIHierarchyInfo*)&ev[1]; - for (dev = inputInfo.devices; dev; dev = dev->next) - { - info->deviceid = dev->id; - info->enabled = dev->enabled; - info->use = GetDeviceUse(dev, &info->attachment); - info->flags = flags[dev->id]; - ev->flags |= info->flags; - info++; - } - for (dev = inputInfo.off_devices; dev; dev = dev->next) - { - info->deviceid = dev->id; - info->enabled = dev->enabled; - info->use = GetDeviceUse(dev, &info->attachment); - info->flags = flags[dev->id]; - ev->flags |= info->flags; - info++; - } - - - for (i = 0; i < MAXDEVICES; i++) - { - if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) - { - info->deviceid = i; - info->enabled = FALSE; - info->flags = flags[i]; - info->use = 0; - ev->flags |= info->flags; - ev->num_info++; - info++; - } - } - - ev->length = (ev->num_info * sizeof(xXIHierarchyInfo))/4; - - dummyDev.id = XIAllDevices; - SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1); -} - - -/*********************************************************************** - * - * This procedure allows a client to change the device hierarchy through - * adding new master devices, removing them, etc. - * - */ - -int SProcXIChangeHierarchy(ClientPtr client) -{ - char n; - - REQUEST(xXIChangeHierarchyReq); - swaps(&stuff->length, n); - return (ProcXIChangeHierarchy(client)); -} - -#define SWAPIF(cmd) if (client->swapped) { cmd; } - -int -ProcXIChangeHierarchy(ClientPtr client) -{ - DeviceIntPtr ptr, keybd, xtstptr, xtstkeybd; - xXIAnyHierarchyChangeInfo *any; - int required_len = sizeof(xXIChangeHierarchyReq); - char n; - int rc = Success; - int flags[MAXDEVICES] = {0}; - - REQUEST(xXIChangeHierarchyReq); - REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq); - - if (!stuff->num_changes) - return rc; - - any = (xXIAnyHierarchyChangeInfo*)&stuff[1]; - while(stuff->num_changes--) - { - SWAPIF(swapl(&any->type, n)); - SWAPIF(swaps(&any->length, n)); - - required_len += any->length; - if ((stuff->length * 4) < required_len) - return BadLength; - - switch(any->type) - { - case XIAddMaster: - { - xXIAddMasterInfo* c = (xXIAddMasterInfo*)any; - char* name; - - SWAPIF(swaps(&c->name_len, n)); - name = xcalloc(c->name_len + 1, sizeof(char)); - strncpy(name, (char*)&c[1], c->name_len); - - - rc = AllocDevicePair(client, name, &ptr, &keybd, TRUE); - if (rc != Success) - { - xfree(name); - goto unwind; - } - - if (!c->send_core) - ptr->coreEvents = keybd->coreEvents = FALSE; - - /* Allocate virtual slave devices for xtest events */ - rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd); - if (rc != Success) - { - - xfree(name); - goto unwind; - } - - ActivateDevice(ptr, FALSE); - ActivateDevice(keybd, FALSE); - flags[ptr->id] |= XIMasterAdded; - flags[keybd->id] |= XIMasterAdded; - - ActivateDevice(xtstptr, FALSE); - ActivateDevice(xtstkeybd, FALSE); - flags[xtstptr->id] |= XISlaveAdded; - flags[xtstkeybd->id] |= XISlaveAdded; - - if (c->enable) - { - EnableDevice(ptr, FALSE); - EnableDevice(keybd, FALSE); - flags[ptr->id] |= XIDeviceEnabled; - flags[keybd->id] |= XIDeviceEnabled; - - EnableDevice(xtstptr, FALSE); - EnableDevice(xtstkeybd, FALSE); - flags[xtstptr->id] |= XIDeviceEnabled; - flags[xtstkeybd->id] |= XIDeviceEnabled; - } - - /* Attach the XTest virtual devices to the newly - created master device */ - AttachDevice(NULL, xtstptr, ptr); - AttachDevice(NULL, xtstkeybd, keybd); - flags[xtstptr->id] |= XISlaveAttached; - flags[xtstkeybd->id] |= XISlaveAttached; - - xfree(name); - } - break; - case XIRemoveMaster: - { - xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; - DeviceIntPtr xtstdevice; - - if (r->return_mode != XIAttachToMaster && - r->return_mode != XIFloating) - return BadValue; - - if (r->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = r->deviceid; - return BadImplementation; - } - - 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; - } - - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && xtstdevice->u.master == ptr && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) - break; - - rc = dixLookupDevice(&xtstptr, xtstdevice->id, client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - /* find keyboards to destroy */ - if (IsPointerDevice(ptr)) - { - rc = dixLookupDevice(&keybd, - ptr->spriteInfo->paired->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - } - else - { - keybd = ptr; - rc = dixLookupDevice(&ptr, - keybd->spriteInfo->paired->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - } - - /* handle xtst pointer / keyboard slave devices */ - if ( IsPointerDevice(xtstptr)) - { - /* Search the matching keyboard */ - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && - xtstdevice->u.master == keybd && - IsKeyboardDevice(xtstdevice) && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) - break; - - rc = dixLookupDevice(&xtstkeybd, - xtstdevice->id, - client, - DixDestroyAccess); - - if (rc != Success) - goto unwind; - } - else - { - xtstkeybd = xtstptr; - /* Search the matching pointer */ - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && - xtstdevice->u.master == ptr && - IsPointerDevice(xtstdevice) && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey ) - ) - break; - rc = dixLookupDevice(&xtstptr, - xtstdevice->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; - - if (r->return_pointer > 0xFF) /* FIXME */ - { - client->errorValue = r->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&newptr, r->return_pointer, - client, DixWriteAccess); - if (rc != Success) - goto unwind; - - if (!IsMaster(newptr)) - { - client->errorValue = r->return_pointer; - rc = BadDevice; - goto unwind; - } - - if (r->return_keyboard > 0xFF) /* FIXME */ - { - client->errorValue = r->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&newkeybd, r->return_keyboard, - client, DixWriteAccess); - 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; - xtstptr->spriteInfo->paired = NULL; - xtstkeybd->spriteInfo->paired = NULL; - - /* disable the remove the devices, xtst devices must be done first - else the sprites they rely on will be destroyed */ - DisableDevice(xtstptr, FALSE); - DisableDevice(xtstkeybd, FALSE); - DisableDevice(keybd, FALSE); - DisableDevice(ptr, FALSE); - flags[xtstptr->id] |= XIDeviceDisabled | XISlaveDetached; - flags[xtstkeybd->id] |= XIDeviceDisabled | XISlaveDetached; - flags[keybd->id] |= XIDeviceDisabled; - flags[ptr->id] |= XIDeviceDisabled; - - RemoveDevice(xtstptr, FALSE); - RemoveDevice(xtstkeybd, FALSE); - RemoveDevice(keybd, FALSE); - RemoveDevice(ptr, FALSE); - flags[xtstptr->id] |= XISlaveRemoved; - flags[xtstkeybd->id] |= XISlaveRemoved; - flags[keybd->id] |= XIMasterRemoved; - flags[ptr->id] |= XIMasterRemoved; - } - break; - case XIDetachSlave: - { - xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; - DeviceIntPtr *xtstdevice; - - if (c->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = c->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&ptr, c->deviceid, client, - DixWriteAccess); - if (rc != Success) - goto unwind; - - if (IsMaster(ptr)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - xtstdevice = dixLookupPrivate( &ptr->devPrivates, - XTstDevicePrivateKey ); - - /* Don't allow changes to Xtst Devices, these are fixed */ - if( xtstdevice ) - { - 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; - DeviceIntPtr *xtstdevice; - - if (c->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = c->deviceid; - return BadImplementation; - } - if (c->new_master > 0xFF) /* FIXME */ - { - client->errorValue = c->new_master; - return BadImplementation; - } - - rc = dixLookupDevice(&ptr, c->deviceid, client, - DixWriteAccess); - if (rc != Success) - goto unwind; - - if (IsMaster(ptr)) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - xtstdevice = dixLookupPrivate( &ptr->devPrivates, - XTstDevicePrivateKey ); - - /* Don't allow changes to Xtst Devices, these are fixed */ - if( xtstdevice ) - { - client->errorValue = c->deviceid; - rc = BadDevice; - goto unwind; - } - - rc = dixLookupDevice(&newmaster, c->new_master, - client, DixWriteAccess); - 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; - } - - any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4); - } - -unwind: - - XISendDeviceHierarchyEvent(flags); - return rc; -} - diff --git a/Xi/chdevhier.h b/Xi/chdevhier.h deleted file mode 100644 index b46cfb4e2..000000000 --- a/Xi/chdevhier.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request change in the device hierarchy. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef CHDEVHIER_H -#define CHDEVHIER_H 1 - -int SProcXIChangeHierarchy(ClientPtr /* client */); -int ProcXIChangeHierarchy(ClientPtr /* client */); - -void XISendDeviceHierarchyEvent(int flags[]); - -#endif diff --git a/Xi/exevents.c b/Xi/exevents.c index 23d8ee899..24fd11fc0 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -74,7 +74,7 @@ SOFTWARE. #include "scrnintstr.h" #include "listdev.h" /* for CopySwapXXXClass */ #include "xace.h" -#include "querydev.h" /* For List*Info */ +#include "xiquerydevice.h" /* For List*Info */ #include "eventconvert.h" #include diff --git a/Xi/extinit.c b/Xi/extinit.c index 0550bd483..20d49e13b 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -75,9 +75,7 @@ SOFTWARE. /* modules local to Xi */ #include "allowev.h" -#include "chdevcur.h" #include "chgdctl.h" -#include "chdevhier.h" #include "chgfctl.h" #include "chgkbd.h" #include "chgprop.h" @@ -86,7 +84,6 @@ SOFTWARE. #include "devbell.h" #include "getbmap.h" #include "getbmap.h" -#include "getcptr.h" #include "getdctl.h" #include "getfctl.h" #include "getfocus.h" @@ -102,15 +99,11 @@ SOFTWARE. #include "gtmotion.h" #include "listdev.h" #include "opendev.h" -#include "querydp.h" #include "queryst.h" -#include "querydev.h" -#include "queryversion.h" #include "selectev.h" #include "sendexev.h" #include "chgkmap.h" #include "setbmap.h" -#include "setcptr.h" #include "setdval.h" #include "setfocus.h" #include "setmmap.h" @@ -118,13 +111,20 @@ SOFTWARE. #include "ungrdev.h" #include "ungrdevb.h" #include "ungrdevk.h" -#include "warpdevp.h" #include "xiallowev.h" #include "xiselectev.h" #include "xigrabdev.h" #include "xipassivegrab.h" #include "xisetdevfocus.h" #include "xiproperty.h" +#include "xichangecursor.h" +#include "xichangehierarchy.h" +#include "xigetclientpointer.h" +#include "xiquerydevice.h" +#include "xiquerypointer.h" +#include "xiqueryversion.h" +#include "xisetclientpointer.h" +#include "xiwarppointer.h" /* Masks for XI events have to be aligned with core event (partially anyway). diff --git a/Xi/getcptr.c b/Xi/getcptr.c deleted file mode 100644 index 92fae8244..000000000 --- a/Xi/getcptr.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include -#include -#include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ -#include "exevents.h" -#include "exglobals.h" - -#include "getcptr.h" - -/*********************************************************************** - * This procedure allows a client to query another client's client pointer - * setting. - */ - -int -SProcXIGetClientPointer(ClientPtr client) -{ - char n; - REQUEST(xXIGetClientPointerReq); - - swaps(&stuff->length, n); - swapl(&stuff->win, n); - return ProcXIGetClientPointer(client); -} - -int ProcXIGetClientPointer(ClientPtr client) -{ - int rc; - ClientPtr winclient; - xXIGetClientPointerReply rep; - REQUEST(xXIGetClientPointerReq); - REQUEST_SIZE_MATCH(xXIGetClientPointerReq); - - if (stuff->win != None) - { - rc = dixLookupClient(&winclient, stuff->win, client, - DixWriteAccess); - - if (rc != Success) - return BadWindow; - } else - winclient = client; - - rep.repType = X_Reply; - rep.RepType = X_XIGetClientPointer; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.set = (winclient->clientPtr != NULL); - rep.deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0; - - WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep); - return Success; -} - -/*********************************************************************** - * - * This procedure writes the reply for the XGetClientPointer function, - * if the client and server have a different byte ordering. - * - */ - -void -SRepXIGetClientPointer(ClientPtr client, int size, - xXIGetClientPointerReply* rep) -{ - char n; - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->deviceid, n); - WriteToClient(client, size, (char *)rep); -} - diff --git a/Xi/getcptr.h b/Xi/getcptr.h deleted file mode 100644 index 1539aa8a9..000000000 --- a/Xi/getcptr.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef GETCPTR_H -#define GETCPTR_H 1 -int SProcXIGetClientPointer(ClientPtr /* client */); -int ProcXIGetClientPointer(ClientPtr /* client */); -void SRepXIGetClientPointer(ClientPtr /* client */, - int /* size */, - xXIGetClientPointerReply* /* rep */); - -#endif /* GETCPTR_H */ diff --git a/Xi/querydev.c b/Xi/querydev.c deleted file mode 100644 index fd5e4635c..000000000 --- a/Xi/querydev.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: Peter Hutterer - * - */ - -/** - * @file Protocol handling for the XIQueryDevice request/reply. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "inputstr.h" -#include -#include -#include "xkbstr.h" -#include "xkbsrv.h" -#include "xserver-properties.h" -#include "exevents.h" - -#include "querydev.h" - -static int ListDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info); -static int SizeDeviceInfo(DeviceIntPtr dev); -static void SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info); -int -SProcXIQueryDevice(ClientPtr client) -{ - char n; - - REQUEST(xXIQueryDeviceReq); - - swaps(&stuff->length, n); - swaps(&stuff->deviceid, n); - - return ProcXIQueryDevice(client); -} - -int -ProcXIQueryDevice(ClientPtr client) -{ - xXIQueryDeviceReply rep; - DeviceIntPtr dev = NULL; - int rc = Success; - int len = 0; - char *info, *ptr; - - REQUEST(xXIQueryDeviceReq); - REQUEST_SIZE_MATCH(xXIQueryDeviceReq); - - if (stuff->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = stuff->deviceid; - return BadImplementation; - } - - if (stuff->deviceid != XIAllDevices && stuff->deviceid != XIAllMasterDevices) - { - rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->deviceid; - return rc; - } - } - - if (dev) - len += SizeDeviceInfo(dev); - else - { - len = 0; - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (stuff->deviceid == XIAllDevices || - (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) - len += SizeDeviceInfo(dev); - } - - for (dev = inputInfo.off_devices; dev; dev = dev->next) - { - if (stuff->deviceid == XIAllDevices || - (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) - len += SizeDeviceInfo(dev); - } - - dev = NULL; - } - - info = xcalloc(1, len); - if (!info) - return BadAlloc; - - memset(&rep, 0, sizeof(xXIQueryDeviceReply)); - rep.repType = X_Reply; - rep.RepType = X_XIQueryDevice; - rep.sequenceNumber = client->sequence; - rep.length = len/4; - rep.num_devices = 0; - - ptr = info; - if (dev) - { - len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); - if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); - info += len; - rep.num_devices = 1; - } else - { - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (stuff->deviceid == XIAllDevices || - (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) - { - len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); - if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); - info += len; - rep.num_devices++; - } - } - - for (dev = inputInfo.off_devices; dev; dev = dev->next) - { - if (stuff->deviceid == XIAllDevices || - (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) - { - len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); - if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); - info += len; - rep.num_devices++; - } - } - } - - WriteReplyToClient(client, sizeof(xXIQueryDeviceReply), &rep); - WriteToClient(client, rep.length * 4, ptr); - return rc; -} - -void -SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep) -{ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_devices, n); - - /* Device info is already swapped, see ProcXIQueryDevice */ - - WriteToClient(client, size, (char *)rep); -} - - - -/** - * @return The number of bytes needed to store this device's xXIDeviceInfo - * (and its classes). - */ -static int -SizeDeviceInfo(DeviceIntPtr dev) -{ - int len = sizeof(xXIDeviceInfo); - - /* 4-padded name */ - len += (((strlen(dev->name) + 3)/4)*4); - - return len + SizeDeviceClasses(dev); - -} - -/* - * @return The number of bytes needed to store this device's classes. - */ -int -SizeDeviceClasses(DeviceIntPtr dev) -{ - int len = 0; - - if (dev->button) - { - len += sizeof(xXIButtonInfo); - len += dev->button->numButtons * sizeof(Atom); - } - - if (dev->key) - { - XkbDescPtr xkb = dev->key->xkbInfo->desc; - len += sizeof(xXIKeyInfo); - len += (xkb->max_key_code - xkb->min_key_code + 1) * sizeof(uint32_t); - } - - if (dev->valuator) - len += sizeof(xXIValuatorInfo) * dev->valuator->numAxes; - - return len; -} - - -/** - * Write button information into info. - * @return Number of bytes written into info. - */ -int -ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) -{ - info->type = ButtonClass; - info->num_buttons = dev->button->numButtons; - info->length = 2 + info->num_buttons; - - /** XXX: button labels */ - - return info->length * 4; -} - -static void -SwapButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) -{ - char n; - Atom *btn; - int i; - swaps(&info->type, n); - swaps(&info->length, n); - - for (i = 0, btn = (Atom*)&info[1]; i < info->num_buttons; i++, btn++) - swaps(btn, n); - - swaps(&info->num_buttons, n); -} - -/** - * Write key information into info. - * @return Number of bytes written into info. - */ -int -ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) -{ - int i; - XkbDescPtr xkb = dev->key->xkbInfo->desc; - uint32_t *kc; - - info->type = KeyClass; - info->num_keycodes = xkb->max_key_code - xkb->min_key_code + 1; - info->length = 2 + info->num_keycodes; - - kc = (uint32_t*)&info[1]; - for (i = xkb->min_key_code; i <= xkb->max_key_code; i++, kc++) - *kc = i; - - return info->length * 4; -} - -static void -SwapKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) -{ - char n; - uint32_t *key; - int i; - swaps(&info->type, n); - swaps(&info->length, n); - - for (i = 0, key = (uint32_t*)&info[1]; i < info->num_keycodes; i++, key++) - swapl(key, n); - - swaps(&info->num_keycodes, n); -} - -/** - * List axis information for the given axis. - * - * @return The number of bytes written into info. - */ -int -ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber) -{ - ValuatorClassPtr v = dev->valuator; - - info->type = ValuatorClass; - info->length = sizeof(xXIValuatorInfo)/4; - info->name = XIGetKnownProperty(AXIS_LABEL_PROP_REL_MISC); /* XXX */ - info->min.integral = v->axes[axisnumber].min_value; - info->min.frac = 0; - info->max.integral = v->axes[axisnumber].max_value; - info->max.frac = 0; - info->resolution = v->axes[axisnumber].resolution; - info->number = axisnumber; - info->mode = v->mode; /* Server doesn't have per-axis mode yet */ - - return info->length * 4; -} - -static void -SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) -{ - char n; - swaps(&info->type, n); - swaps(&info->length, n); - swapl(&info->name, n); - swapl(&info->min.integral, n); - swapl(&info->min.frac, n); - swapl(&info->max.integral, n); - swapl(&info->max.frac, n); - swaps(&info->number, n); -} - -int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) -{ - DeviceIntPtr master = dev->u.master; - int use; - - if (IsMaster(dev)) - { - DeviceIntPtr paired = GetPairedDevice(dev); - use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; - *attachment = (paired ? paired->id : 0); - } else if (master) - { - use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; - *attachment = master->id; - } else - use = XIFloatingSlave; - - return use; -} - -/** - * Write the info for device dev into the buffer pointed to by info. - * - * @return The number of bytes used. - */ -static int -ListDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) -{ - char *any = (char*)&info[1]; - int len = 0, total_len = 0; - - info->deviceid = dev->id; - info->use = GetDeviceUse(dev, &info->attachment); - info->num_classes = 0; - info->name_len = strlen(dev->name); - info->enabled = dev->enabled; - total_len = sizeof(xXIDeviceInfo); - - len = ((info->name_len + 3)/4) * 4; - memset(any, 0, len); - strncpy(any, dev->name, info->name_len); - any += len; - total_len += len; - - return total_len + ListDeviceClasses(dev, any, &info->num_classes); -} - -/** - * Write the class info of the device into the memory pointed to by any, set - * nclasses to the number of classes in total and return the number of bytes - * written. - */ -int -ListDeviceClasses(DeviceIntPtr dev, char *any, uint16_t *nclasses) -{ - int total_len = 0; - int len; - int i; - - if (dev->button) - { - (*nclasses)++; - len = ListButtonInfo(dev, (xXIButtonInfo*)any); - any += len; - total_len += len; - } - - if (dev->key) - { - (*nclasses)++; - len = ListKeyInfo(dev, (xXIKeyInfo*)any); - any += len; - total_len += len; - } - - for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) - { - (*nclasses)++; - len = ListValuatorInfo(dev, (xXIValuatorInfo*)any, i); - any += len; - total_len += len; - } - - return total_len; -} - -static void -SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) -{ - char n; - char *any = (char*)&info[1]; - int i; - - /* Skip over name */ - any += (((info->name_len + 3)/4) * 4); - - for (i = 0; i < info->num_classes; i++) - { - int len = ((xXIAnyInfo*)any)->length; - switch(((xXIAnyInfo*)any)->type) - { - case XIButtonClass: - SwapButtonInfo(dev, (xXIButtonInfo*)any); - break; - case XIKeyClass: - SwapKeyInfo(dev, (xXIKeyInfo*)any); - break; - case XIValuatorClass: - SwapValuatorInfo(dev, (xXIValuatorInfo*)any); - break; - } - - any += len * 4; - } - - swaps(&info->deviceid, n); - swaps(&info->use, n); - swaps(&info->attachment, n); - swaps(&info->num_classes, n); - swaps(&info->name_len, n); - -} diff --git a/Xi/querydev.h b/Xi/querydev.h deleted file mode 100644 index 34e87bdde..000000000 --- a/Xi/querydev.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: Peter Hutterer - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef QUERYDEV_H -#define QUERYDEV_H 1 - -#include - -int SProcXIQueryDevice(ClientPtr client); -int ProcXIQueryDevice(ClientPtr client); -void SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep); -int SizeDeviceClasses(DeviceIntPtr dev); -int ListDeviceClasses(DeviceIntPtr dev, char* any, uint16_t* nclasses); -int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment); -int ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info); -int ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info); -int ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber); -#endif /* QUERYDEV_H */ diff --git a/Xi/querydp.c b/Xi/querydp.c deleted file mode 100644 index e5bf98d86..000000000 --- a/Xi/querydp.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request to query the pointer location of an extension input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include -#include -#include "extnsionst.h" -#include "exevents.h" -#include "exglobals.h" -#include "eventconvert.h" -#include "xkbsrv.h" - -#ifdef PANORAMIX -#include "panoramiXsrv.h" -#endif - -#include "querydp.h" - -/*********************************************************************** - * - * This procedure allows a client to query the pointer of a device. - * - */ - -int -SProcXIQueryPointer(ClientPtr client) -{ - char n; - - REQUEST(xXIQueryPointerReq); - swaps(&stuff->length, n); - return (ProcXIQueryPointer(client)); -} - -int -ProcXIQueryPointer(ClientPtr client) -{ - int rc; - xXIQueryPointerReply rep; - DeviceIntPtr pDev, kbd; - WindowPtr pWin, t; - SpritePtr pSprite; - XkbStatePtr state; - char *buttons = NULL; - - REQUEST(xXIQueryPointerReq); - REQUEST_SIZE_MATCH(xXIQueryPointerReq); - - if (stuff->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = stuff->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess); - if (rc != Success) - return rc; - - if (pDev->valuator == NULL) - { - client->errorValue = stuff->deviceid; - return BadDevice; - } - - rc = dixLookupWindow(&pWin, stuff->win, client, DixReadAccess); - if (rc != Success) - { - SendErrorToClient(client, IReqCode, X_XIQueryPointer, - stuff->win, rc); - return Success; - } - - if (pDev->valuator->motionHintWindow) - MaybeStopHint(pDev, client); - - kbd = GetPairedDevice(pDev); - - pSprite = pDev->spriteInfo->sprite; - rep.repType = X_Reply; - rep.RepType = X_XIQueryPointer; - rep.length = 5; - rep.sequenceNumber = client->sequence; - rep.root = (GetCurrentRootWindow(pDev))->drawable.id; - rep.root_x = FP1616(pSprite->hot.x, 0); - rep.root_y = FP1616(pSprite->hot.y, 0); - rep.child = None; - - state = &kbd->key->xkbInfo->prev_state; - rep.mods.base_mods = state->base_mods; - rep.mods.latched_mods = state->latched_mods; - rep.mods.locked_mods = state->locked_mods; - - rep.group.base_group = state->base_group; - rep.group.latched_group = state->latched_group; - rep.group.locked_group = state->locked_group; - - if (pDev->button) - { - int i, down; - rep.buttons_len = (((pDev->button->numButtons + 7)/8) + 3)/4; - rep.length += rep.buttons_len; - buttons = xcalloc(rep.buttons_len, 4); - if (!buttons) - return BadAlloc; - - down = pDev->button->buttonsDown; - - for (i = 0; i < pDev->button->numButtons && down; i++) - { - if (BitIsOn(pDev->button->down, i)) - { - SetBit(buttons, i); - down--; - } - } - } else - rep.buttons_len = 0; - - if (pSprite->hot.pScreen == pWin->drawable.pScreen) - { - rep.same_screen = xTrue; - rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0); - rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0); - for (t = pSprite->win; t; t = t->parent) - if (t->parent == pWin) - { - rep.child = t->drawable.id; - break; - } - } else - { - rep.same_screen = xFalse; - rep.win_x = 0; - rep.win_y = 0; - } - -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - rep.root_x += FP1616(panoramiXdataPtr[0].x, 0); - rep.root_y += FP1616(panoramiXdataPtr[0].y, 0); - if (stuff->win == rep.root) - { - rep.win_x += FP1616(panoramiXdataPtr[0].x, 0); - rep.win_y += FP1616(panoramiXdataPtr[0].y, 0); - } - } -#endif - - WriteReplyToClient(client, sizeof(xXIQueryPointerReply), &rep); - if (buttons) - WriteToClient(client, rep.buttons_len * 4, buttons); - - xfree(buttons); - - return Success; -} - -/*********************************************************************** - * - * This procedure writes the reply for the XIQueryPointer function, - * if the client and server have a different byte ordering. - * - */ - -void -SRepXIQueryPointer(ClientPtr client, int size, - xXIQueryPointerReply * rep) -{ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} - diff --git a/Xi/querydp.h b/Xi/querydp.h deleted file mode 100644 index ea22376a6..000000000 --- a/Xi/querydp.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef QUERYDP_H -#define QUERYDP_H 1 - -int SProcXIQueryPointer(ClientPtr /* client */); -int ProcXIQueryPointer(ClientPtr /* client */); -void SRepXIQueryPointer(ClientPtr /* client */ , - int /* size */ , - xXIQueryPointerReply * /* rep */); - -#endif /* QUERYDP_H */ diff --git a/Xi/queryversion.c b/Xi/queryversion.c deleted file mode 100644 index 4d644a955..000000000 --- a/Xi/queryversion.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: Peter Hutterer - * - */ - -/** - * @file queryversion.c - * Protocol handling for the XIQueryVersion request/reply. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - - -#include "inputstr.h" - -#include -#include -#include - -#include "exglobals.h" -#include "exevents.h" -#include "queryversion.h" -#include "misc.h" - -extern XExtensionVersion XIVersion; /* defined in getvers.c */ -/** - * Return the supported XI version. - * - * Saves the version the client claims to support as well, for future - * reference. - */ -int -ProcXIQueryVersion(ClientPtr client) -{ - xXIQueryVersionReply rep; - XIClientPtr pXIClient; - int major, minor; - unsigned int sversion, cversion; - - REQUEST(xXIQueryVersionReq); - REQUEST_SIZE_MATCH(xXIQueryVersionReq); - - /* This request only exists after XI2 */ - if (stuff->major_version < 2) - { - client->errorValue = stuff->major_version; - return BadValue; - } - - pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); - - sversion = XIVersion.major_version * 1000 + XIVersion.minor_version; - cversion = stuff->major_version * 1000 + stuff->minor_version; - - if (sversion > cversion) - { - major = stuff->major_version; - minor = stuff->minor_version; - } else - { - major = XIVersion.major_version; - minor = XIVersion.minor_version; - } - - pXIClient->major_version = major; - pXIClient->minor_version = minor; - - memset(&rep, 0, sizeof(xXIQueryVersionReply)); - rep.repType = X_Reply; - rep.RepType = X_XIQueryVersion; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.major_version = major; - rep.minor_version = minor; - - WriteReplyToClient(client, sizeof(xXIQueryVersionReply), &rep); - - return Success; -} - -/* Swapping routines */ - -int -SProcXIQueryVersion(ClientPtr client) -{ - char n; - - REQUEST(xXIQueryVersionReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xXIQueryVersionReq); - swaps(&stuff->major_version, n); - swaps(&stuff->minor_version, n); - return (ProcXIQueryVersion(client)); -} - -void -SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply *rep) -{ - char n; - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->major_version, n); - swaps(&rep->minor_version, n); - WriteToClient(client, size, (char *)rep); -} diff --git a/Xi/queryversion.h b/Xi/queryversion.h deleted file mode 100644 index 06bb7291a..000000000 --- a/Xi/queryversion.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: Peter Hutterer - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include - -#ifndef QUERYVERSION_H -#define QUERYVERSION_H 1 - -int SProcXIQueryVersion(ClientPtr client); -int ProcXIQueryVersion(ClientPtr client); -void SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply* rep); - -#endif /* QUERYVERSION_H */ diff --git a/Xi/setcptr.c b/Xi/setcptr.c deleted file mode 100644 index d23b2d860..000000000 --- a/Xi/setcptr.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request to set the client pointer for the owner of the given window. - * All subsequent calls that are ambiguous will choose the client pointer as - * default value. - */ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include -#include -#include "extnsionst.h" -#include "exevents.h" -#include "exglobals.h" - -#include "setcptr.h" - -int -SProcXISetClientPointer(ClientPtr client) -{ - char n; - - REQUEST(xXISetClientPointerReq); - swaps(&stuff->length, n); - swapl(&stuff->win, n); - swaps(&stuff->deviceid, n); - REQUEST_SIZE_MATCH(xXISetClientPointerReq); - return (ProcXISetClientPointer(client)); -} - -int -ProcXISetClientPointer(ClientPtr client) -{ - DeviceIntPtr pDev; - ClientPtr targetClient; - int rc; - - REQUEST(xXISetClientPointerReq); - REQUEST_SIZE_MATCH(xXISetClientPointerReq); - - if (stuff->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = stuff->deviceid; - return BadImplementation; - } - - rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess); - if (rc != Success) - { - client->errorValue = stuff->deviceid; - return rc; - } - - if (!IsMaster(pDev)) - { - client->errorValue = stuff->deviceid; - return BadDevice; - } - - pDev = GetMaster(pDev, MASTER_POINTER); - - if (stuff->win != None) - { - rc = dixLookupClient(&targetClient, stuff->win, client, - DixWriteAccess); - - if (rc != Success) - return BadWindow; - - } else - targetClient = client; - - if (!SetClientPointer(targetClient, pDev)) - { - client->errorValue = stuff->deviceid; - return BadDevice; - } - - return Success; -} diff --git a/Xi/setcptr.h b/Xi/setcptr.h deleted file mode 100644 index 5968d98da..000000000 --- a/Xi/setcptr.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef SETCPTR_H -#define SETCPTR_H 1 - -int SProcXISetClientPointer(ClientPtr /* client */); -int ProcXISetClientPointer(ClientPtr /* client */); - -#endif /* SETCPTR_H */ diff --git a/Xi/warpdevp.c b/Xi/warpdevp.c deleted file mode 100644 index bb45bdafc..000000000 --- a/Xi/warpdevp.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -/*********************************************************************** - * - * Request to Warp the pointer location of an extension input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include /* for inputstr.h */ -#include /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include -#include -#include "extnsionst.h" -#include "exevents.h" -#include "exglobals.h" -#include "mipointer.h" /* for miPointerUpdateSprite */ - - -#include "warpdevp.h" -/*********************************************************************** - * - * This procedure allows a client to warp the pointer of a device. - * - */ - -int -SProcXIWarpPointer(ClientPtr client) -{ - char n; - - REQUEST(xXIWarpPointerReq); - swaps(&stuff->length, n); - return (ProcXIWarpPointer(client)); -} - -int -ProcXIWarpPointer(ClientPtr client) -{ - int rc; - int x, y; - WindowPtr dest = NULL; - DeviceIntPtr pDev; - SpritePtr pSprite; - ScreenPtr newScreen; - - REQUEST(xXIWarpPointerReq); - REQUEST_SIZE_MATCH(xXIWarpPointerReq); - - if (stuff->deviceid > 0xFF) /* FIXME */ - { - client->errorValue = stuff->deviceid; - return BadImplementation; - } - - /* FIXME: panoramix stuff is missing, look at ProcWarpPointer */ - - rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess); - - if (rc != Success) - return rc; - - if (stuff->dst_win != None) - { - rc = dixLookupWindow(&dest, stuff->dst_win, client, DixReadAccess); - if (rc != Success) - { - return rc; - } - } - - pSprite = pDev->spriteInfo->sprite; - x = pSprite->hotPhys.x; - y = pSprite->hotPhys.y; - - if (stuff->src_win != None) - { - int winX, winY; - WindowPtr src; - - rc = dixLookupWindow(&src, stuff->src_win, client, DixReadAccess); - if (rc != Success) - { - return rc; - } - - winX = src->drawable.x; - winY = src->drawable.y; - if (src->drawable.pScreen != pSprite->hotPhys.pScreen || - x < winX + stuff->src_x || - y < winY + stuff->src_y || - (stuff->src_width != 0 && - winX + stuff->src_x + (int)stuff->src_width < 0) || - (stuff->src_height != 0 && - winY + stuff->src_y + (int)stuff->src_height < y) || - !PointInWindowIsVisible(src, x, y)) - return Success; - } - - if (dest) - { - x = dest->drawable.x; - y = dest->drawable.y; - newScreen = dest->drawable.pScreen; - } else - newScreen = pSprite->hotPhys.pScreen; - - x += stuff->dst_x; - y += stuff->dst_y; - - if (x < 0) - x = 0; - else if (x > newScreen->width) - x = newScreen->width - 1; - - if (y < 0) - y = 0; - else if (y > newScreen->height) - y = newScreen->height - 1; - - if (newScreen == pSprite->hotPhys.pScreen) - { - if (x < pSprite->physLimits.x1) - x = pSprite->physLimits.x1; - else if (x >= pSprite->physLimits.x2) - x = pSprite->physLimits.x2 - 1; - - if (y < pSprite->physLimits.y1) - y = pSprite->physLimits.y1; - else if (y >= pSprite->physLimits.y2) - y = pSprite->physLimits.y2 - 1; - - if (pSprite->hotShape) - ConfineToShape(pDev, pSprite->hotShape, &x, &y); - (*newScreen->SetCursorPosition)(pDev, newScreen, x, y, TRUE); - } else if (!PointerConfinedToScreen(pDev)) - { - NewCurrentScreen(pDev, newScreen, x, y); - } - - /* if we don't update the device, we get a jump next time it moves */ - pDev->last.valuators[0] = x; - pDev->last.valuators[1] = y; - miPointerUpdateSprite(pDev); - - /* FIXME: XWarpPointer is supposed to generate an event. It doesn't do it - here though. */ - return Success; -} - diff --git a/Xi/warpdevp.h b/Xi/warpdevp.h deleted file mode 100644 index aafc73904..000000000 --- a/Xi/warpdevp.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef WARPDEVP_H -#define WARPDEVP_H 1 - -int SProcXIWarpPointer(ClientPtr /* client */); -int ProcXIWarpPointer(ClientPtr /* client */); - -#endif /* WARPDEVP_H */ diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c new file mode 100644 index 000000000..ee2d65d91 --- /dev/null +++ b/Xi/xichangecursor.c @@ -0,0 +1,113 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request to change a given device pointer's cursor. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#include "extnsionst.h" +#include "exevents.h" +#include "exglobals.h" +#include "input.h" + +#include "xichangecursor.h" + +/*********************************************************************** + * + * This procedure allows a client to set one pointer's cursor. + * + */ + +int +SProcXIChangeCursor(ClientPtr client) +{ + char n; + + REQUEST(xXIChangeCursorReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXIChangeCursorReq); + return (ProcXIChangeCursor(client)); +} + +int ProcXIChangeCursor(ClientPtr client) +{ + int rc; + WindowPtr pWin = NULL; + DeviceIntPtr pDev = NULL; + CursorPtr pCursor = NULL; + + REQUEST(xXIChangeCursorReq); + REQUEST_SIZE_MATCH(xXIChangeCursorReq); + + if (stuff->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = stuff->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess); + if (rc != Success) + return rc; + + if (stuff->win != None) + { + rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess); + if (rc != Success) + return rc; + } + + if (stuff->cursor == None) + { + if (pWin == WindowTable[pWin->drawable.pScreen->myNum]) + pCursor = rootCursor; + else + pCursor = (CursorPtr)None; + } + else + { + rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, + RT_CURSOR, client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? BadCursor : rc; + } + + ChangeWindowDeviceCursor(pWin, pDev, pCursor); + + return Success; +} + diff --git a/Xi/xichangecursor.h b/Xi/xichangecursor.h new file mode 100644 index 000000000..dc6ccb1af --- /dev/null +++ b/Xi/xichangecursor.h @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef CHDEVCUR_H +#define CHDEVCUR_H 1 + +int SProcXIChangeCursor(ClientPtr /* client */); +int ProcXIChangeCursor(ClientPtr /* client */); + +#endif /* CHDEVCUR_H */ diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c new file mode 100644 index 000000000..944bb3017 --- /dev/null +++ b/Xi/xichangehierarchy.c @@ -0,0 +1,540 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * Copyright 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request change in the device hierarchy. + * + */ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#include +#include "extnsionst.h" +#include "exevents.h" +#include "exglobals.h" +#include "geext.h" +#include "xace.h" +#include "xiquerydevice.h" /* for GetDeviceUse */ + +#include "xkbsrv.h" + +#include "xichangehierarchy.h" + +extern DevPrivateKey XTstDevicePrivateKey; + +/** + * Send the current state of the device hierarchy to all clients. + */ +void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) +{ + xXIHierarchyEvent *ev; + xXIHierarchyInfo *info; + DeviceIntRec dummyDev; + DeviceIntPtr dev; + int i; + + if (!flags) + return; + + ev = xcalloc(1, sizeof(xXIHierarchyEvent) + + MAXDEVICES * sizeof(xXIHierarchyInfo)); + ev->type = GenericEvent; + ev->extension = IReqCode; + ev->evtype = XI_HierarchyChanged; + ev->time = GetTimeInMillis(); + ev->flags = 0; + ev->num_info = inputInfo.numDevices; + + info = (xXIHierarchyInfo*)&ev[1]; + for (dev = inputInfo.devices; dev; dev = dev->next) + { + info->deviceid = dev->id; + info->enabled = dev->enabled; + info->use = GetDeviceUse(dev, &info->attachment); + info->flags = flags[dev->id]; + ev->flags |= info->flags; + info++; + } + for (dev = inputInfo.off_devices; dev; dev = dev->next) + { + info->deviceid = dev->id; + info->enabled = dev->enabled; + info->use = GetDeviceUse(dev, &info->attachment); + info->flags = flags[dev->id]; + ev->flags |= info->flags; + info++; + } + + + for (i = 0; i < MAXDEVICES; i++) + { + if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) + { + info->deviceid = i; + info->enabled = FALSE; + info->flags = flags[i]; + info->use = 0; + ev->flags |= info->flags; + ev->num_info++; + info++; + } + } + + ev->length = (ev->num_info * sizeof(xXIHierarchyInfo))/4; + + dummyDev.id = XIAllDevices; + SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1); +} + + +/*********************************************************************** + * + * This procedure allows a client to change the device hierarchy through + * adding new master devices, removing them, etc. + * + */ + +int SProcXIChangeHierarchy(ClientPtr client) +{ + char n; + + REQUEST(xXIChangeHierarchyReq); + swaps(&stuff->length, n); + return (ProcXIChangeHierarchy(client)); +} + +#define SWAPIF(cmd) if (client->swapped) { cmd; } + +int +ProcXIChangeHierarchy(ClientPtr client) +{ + DeviceIntPtr ptr, keybd, xtstptr, xtstkeybd; + xXIAnyHierarchyChangeInfo *any; + int required_len = sizeof(xXIChangeHierarchyReq); + char n; + int rc = Success; + int flags[MAXDEVICES] = {0}; + + REQUEST(xXIChangeHierarchyReq); + REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq); + + if (!stuff->num_changes) + return rc; + + any = (xXIAnyHierarchyChangeInfo*)&stuff[1]; + while(stuff->num_changes--) + { + SWAPIF(swapl(&any->type, n)); + SWAPIF(swaps(&any->length, n)); + + required_len += any->length; + if ((stuff->length * 4) < required_len) + return BadLength; + + switch(any->type) + { + case XIAddMaster: + { + xXIAddMasterInfo* c = (xXIAddMasterInfo*)any; + char* name; + + SWAPIF(swaps(&c->name_len, n)); + name = xcalloc(c->name_len + 1, sizeof(char)); + strncpy(name, (char*)&c[1], c->name_len); + + + rc = AllocDevicePair(client, name, &ptr, &keybd, TRUE); + if (rc != Success) + { + xfree(name); + goto unwind; + } + + if (!c->send_core) + ptr->coreEvents = keybd->coreEvents = FALSE; + + /* Allocate virtual slave devices for xtest events */ + rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd); + if (rc != Success) + { + + xfree(name); + goto unwind; + } + + ActivateDevice(ptr, FALSE); + ActivateDevice(keybd, FALSE); + flags[ptr->id] |= XIMasterAdded; + flags[keybd->id] |= XIMasterAdded; + + ActivateDevice(xtstptr, FALSE); + ActivateDevice(xtstkeybd, FALSE); + flags[xtstptr->id] |= XISlaveAdded; + flags[xtstkeybd->id] |= XISlaveAdded; + + if (c->enable) + { + EnableDevice(ptr, FALSE); + EnableDevice(keybd, FALSE); + flags[ptr->id] |= XIDeviceEnabled; + flags[keybd->id] |= XIDeviceEnabled; + + EnableDevice(xtstptr, FALSE); + EnableDevice(xtstkeybd, FALSE); + flags[xtstptr->id] |= XIDeviceEnabled; + flags[xtstkeybd->id] |= XIDeviceEnabled; + } + + /* Attach the XTest virtual devices to the newly + created master device */ + AttachDevice(NULL, xtstptr, ptr); + AttachDevice(NULL, xtstkeybd, keybd); + flags[xtstptr->id] |= XISlaveAttached; + flags[xtstkeybd->id] |= XISlaveAttached; + + xfree(name); + } + break; + case XIRemoveMaster: + { + xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; + DeviceIntPtr xtstdevice; + + if (r->return_mode != XIAttachToMaster && + r->return_mode != XIFloating) + return BadValue; + + if (r->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = r->deviceid; + return BadImplementation; + } + + 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; + } + + for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) + if( !IsMaster(xtstdevice) && xtstdevice->u.master == ptr && + dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) + break; + + rc = dixLookupDevice(&xtstptr, xtstdevice->id, client, + DixDestroyAccess); + if (rc != Success) + goto unwind; + + /* find keyboards to destroy */ + if (IsPointerDevice(ptr)) + { + rc = dixLookupDevice(&keybd, + ptr->spriteInfo->paired->id, + client, + DixDestroyAccess); + if (rc != Success) + goto unwind; + + } + else + { + keybd = ptr; + rc = dixLookupDevice(&ptr, + keybd->spriteInfo->paired->id, + client, + DixDestroyAccess); + if (rc != Success) + goto unwind; + + } + + /* handle xtst pointer / keyboard slave devices */ + if ( IsPointerDevice(xtstptr)) + { + /* Search the matching keyboard */ + for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) + if( !IsMaster(xtstdevice) && + xtstdevice->u.master == keybd && + IsKeyboardDevice(xtstdevice) && + dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) + break; + + rc = dixLookupDevice(&xtstkeybd, + xtstdevice->id, + client, + DixDestroyAccess); + + if (rc != Success) + goto unwind; + } + else + { + xtstkeybd = xtstptr; + /* Search the matching pointer */ + for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) + if( !IsMaster(xtstdevice) && + xtstdevice->u.master == ptr && + IsPointerDevice(xtstdevice) && + dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey ) + ) + break; + rc = dixLookupDevice(&xtstptr, + xtstdevice->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; + + if (r->return_pointer > 0xFF) /* FIXME */ + { + client->errorValue = r->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&newptr, r->return_pointer, + client, DixWriteAccess); + if (rc != Success) + goto unwind; + + if (!IsMaster(newptr)) + { + client->errorValue = r->return_pointer; + rc = BadDevice; + goto unwind; + } + + if (r->return_keyboard > 0xFF) /* FIXME */ + { + client->errorValue = r->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&newkeybd, r->return_keyboard, + client, DixWriteAccess); + 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; + xtstptr->spriteInfo->paired = NULL; + xtstkeybd->spriteInfo->paired = NULL; + + /* disable the remove the devices, xtst devices must be done first + else the sprites they rely on will be destroyed */ + DisableDevice(xtstptr, FALSE); + DisableDevice(xtstkeybd, FALSE); + DisableDevice(keybd, FALSE); + DisableDevice(ptr, FALSE); + flags[xtstptr->id] |= XIDeviceDisabled | XISlaveDetached; + flags[xtstkeybd->id] |= XIDeviceDisabled | XISlaveDetached; + flags[keybd->id] |= XIDeviceDisabled; + flags[ptr->id] |= XIDeviceDisabled; + + RemoveDevice(xtstptr, FALSE); + RemoveDevice(xtstkeybd, FALSE); + RemoveDevice(keybd, FALSE); + RemoveDevice(ptr, FALSE); + flags[xtstptr->id] |= XISlaveRemoved; + flags[xtstkeybd->id] |= XISlaveRemoved; + flags[keybd->id] |= XIMasterRemoved; + flags[ptr->id] |= XIMasterRemoved; + } + break; + case XIDetachSlave: + { + xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; + DeviceIntPtr *xtstdevice; + + if (c->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = c->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&ptr, c->deviceid, client, + DixWriteAccess); + if (rc != Success) + goto unwind; + + if (IsMaster(ptr)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + xtstdevice = dixLookupPrivate( &ptr->devPrivates, + XTstDevicePrivateKey ); + + /* Don't allow changes to Xtst Devices, these are fixed */ + if( xtstdevice ) + { + 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; + DeviceIntPtr *xtstdevice; + + if (c->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = c->deviceid; + return BadImplementation; + } + if (c->new_master > 0xFF) /* FIXME */ + { + client->errorValue = c->new_master; + return BadImplementation; + } + + rc = dixLookupDevice(&ptr, c->deviceid, client, + DixWriteAccess); + if (rc != Success) + goto unwind; + + if (IsMaster(ptr)) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + xtstdevice = dixLookupPrivate( &ptr->devPrivates, + XTstDevicePrivateKey ); + + /* Don't allow changes to Xtst Devices, these are fixed */ + if( xtstdevice ) + { + client->errorValue = c->deviceid; + rc = BadDevice; + goto unwind; + } + + rc = dixLookupDevice(&newmaster, c->new_master, + client, DixWriteAccess); + 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; + } + + any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4); + } + +unwind: + + XISendDeviceHierarchyEvent(flags); + return rc; +} + diff --git a/Xi/xichangehierarchy.h b/Xi/xichangehierarchy.h new file mode 100644 index 000000000..b46cfb4e2 --- /dev/null +++ b/Xi/xichangehierarchy.h @@ -0,0 +1,44 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request change in the device hierarchy. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef CHDEVHIER_H +#define CHDEVHIER_H 1 + +int SProcXIChangeHierarchy(ClientPtr /* client */); +int ProcXIChangeHierarchy(ClientPtr /* client */); + +void XISendDeviceHierarchyEvent(int flags[]); + +#endif diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c new file mode 100644 index 000000000..859d3fd00 --- /dev/null +++ b/Xi/xigetclientpointer.c @@ -0,0 +1,106 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#include "extnsionst.h" +#include "extinit.h" /* LookupDeviceIntRec */ +#include "exevents.h" +#include "exglobals.h" + +#include "xigetclientpointer.h" + +/*********************************************************************** + * This procedure allows a client to query another client's client pointer + * setting. + */ + +int +SProcXIGetClientPointer(ClientPtr client) +{ + char n; + REQUEST(xXIGetClientPointerReq); + + swaps(&stuff->length, n); + swapl(&stuff->win, n); + return ProcXIGetClientPointer(client); +} + +int ProcXIGetClientPointer(ClientPtr client) +{ + int rc; + ClientPtr winclient; + xXIGetClientPointerReply rep; + REQUEST(xXIGetClientPointerReq); + REQUEST_SIZE_MATCH(xXIGetClientPointerReq); + + if (stuff->win != None) + { + rc = dixLookupClient(&winclient, stuff->win, client, + DixWriteAccess); + + if (rc != Success) + return BadWindow; + } else + winclient = client; + + rep.repType = X_Reply; + rep.RepType = X_XIGetClientPointer; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.set = (winclient->clientPtr != NULL); + rep.deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0; + + WriteReplyToClient(client, sizeof(xXIGetClientPointerReply), &rep); + return Success; +} + +/*********************************************************************** + * + * This procedure writes the reply for the XGetClientPointer function, + * if the client and server have a different byte ordering. + * + */ + +void +SRepXIGetClientPointer(ClientPtr client, int size, + xXIGetClientPointerReply* rep) +{ + char n; + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->deviceid, n); + WriteToClient(client, size, (char *)rep); +} + diff --git a/Xi/xigetclientpointer.h b/Xi/xigetclientpointer.h new file mode 100644 index 000000000..1539aa8a9 --- /dev/null +++ b/Xi/xigetclientpointer.h @@ -0,0 +1,38 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef GETCPTR_H +#define GETCPTR_H 1 +int SProcXIGetClientPointer(ClientPtr /* client */); +int ProcXIGetClientPointer(ClientPtr /* client */); +void SRepXIGetClientPointer(ClientPtr /* client */, + int /* size */, + xXIGetClientPointerReply* /* rep */); + +#endif /* GETCPTR_H */ diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c new file mode 100644 index 000000000..07ddfa1cf --- /dev/null +++ b/Xi/xiquerydevice.c @@ -0,0 +1,451 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: Peter Hutterer + * + */ + +/** + * @file Protocol handling for the XIQueryDevice request/reply. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "inputstr.h" +#include +#include +#include "xkbstr.h" +#include "xkbsrv.h" +#include "xserver-properties.h" +#include "exevents.h" + +#include "xiquerydevice.h" + +static int ListDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info); +static int SizeDeviceInfo(DeviceIntPtr dev); +static void SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info); +int +SProcXIQueryDevice(ClientPtr client) +{ + char n; + + REQUEST(xXIQueryDeviceReq); + + swaps(&stuff->length, n); + swaps(&stuff->deviceid, n); + + return ProcXIQueryDevice(client); +} + +int +ProcXIQueryDevice(ClientPtr client) +{ + xXIQueryDeviceReply rep; + DeviceIntPtr dev = NULL; + int rc = Success; + int len = 0; + char *info, *ptr; + + REQUEST(xXIQueryDeviceReq); + REQUEST_SIZE_MATCH(xXIQueryDeviceReq); + + if (stuff->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = stuff->deviceid; + return BadImplementation; + } + + if (stuff->deviceid != XIAllDevices && stuff->deviceid != XIAllMasterDevices) + { + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); + if (rc != Success) + { + client->errorValue = stuff->deviceid; + return rc; + } + } + + if (dev) + len += SizeDeviceInfo(dev); + else + { + len = 0; + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (stuff->deviceid == XIAllDevices || + (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) + len += SizeDeviceInfo(dev); + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + { + if (stuff->deviceid == XIAllDevices || + (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) + len += SizeDeviceInfo(dev); + } + + dev = NULL; + } + + info = xcalloc(1, len); + if (!info) + return BadAlloc; + + memset(&rep, 0, sizeof(xXIQueryDeviceReply)); + rep.repType = X_Reply; + rep.RepType = X_XIQueryDevice; + rep.sequenceNumber = client->sequence; + rep.length = len/4; + rep.num_devices = 0; + + ptr = info; + if (dev) + { + len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); + if (client->swapped) + SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + info += len; + rep.num_devices = 1; + } else + { + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (stuff->deviceid == XIAllDevices || + (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) + { + len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); + if (client->swapped) + SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + info += len; + rep.num_devices++; + } + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + { + if (stuff->deviceid == XIAllDevices || + (stuff->deviceid == XIAllMasterDevices && IsMaster(dev))) + { + len = ListDeviceInfo(dev, (xXIDeviceInfo*)info); + if (client->swapped) + SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + info += len; + rep.num_devices++; + } + } + } + + WriteReplyToClient(client, sizeof(xXIQueryDeviceReply), &rep); + WriteToClient(client, rep.length * 4, ptr); + return rc; +} + +void +SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep) +{ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_devices, n); + + /* Device info is already swapped, see ProcXIQueryDevice */ + + WriteToClient(client, size, (char *)rep); +} + + + +/** + * @return The number of bytes needed to store this device's xXIDeviceInfo + * (and its classes). + */ +static int +SizeDeviceInfo(DeviceIntPtr dev) +{ + int len = sizeof(xXIDeviceInfo); + + /* 4-padded name */ + len += (((strlen(dev->name) + 3)/4)*4); + + return len + SizeDeviceClasses(dev); + +} + +/* + * @return The number of bytes needed to store this device's classes. + */ +int +SizeDeviceClasses(DeviceIntPtr dev) +{ + int len = 0; + + if (dev->button) + { + len += sizeof(xXIButtonInfo); + len += dev->button->numButtons * sizeof(Atom); + } + + if (dev->key) + { + XkbDescPtr xkb = dev->key->xkbInfo->desc; + len += sizeof(xXIKeyInfo); + len += (xkb->max_key_code - xkb->min_key_code + 1) * sizeof(uint32_t); + } + + if (dev->valuator) + len += sizeof(xXIValuatorInfo) * dev->valuator->numAxes; + + return len; +} + + +/** + * Write button information into info. + * @return Number of bytes written into info. + */ +int +ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) +{ + info->type = ButtonClass; + info->num_buttons = dev->button->numButtons; + info->length = 2 + info->num_buttons; + + /** XXX: button labels */ + + return info->length * 4; +} + +static void +SwapButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) +{ + char n; + Atom *btn; + int i; + swaps(&info->type, n); + swaps(&info->length, n); + + for (i = 0, btn = (Atom*)&info[1]; i < info->num_buttons; i++, btn++) + swaps(btn, n); + + swaps(&info->num_buttons, n); +} + +/** + * Write key information into info. + * @return Number of bytes written into info. + */ +int +ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) +{ + int i; + XkbDescPtr xkb = dev->key->xkbInfo->desc; + uint32_t *kc; + + info->type = KeyClass; + info->num_keycodes = xkb->max_key_code - xkb->min_key_code + 1; + info->length = 2 + info->num_keycodes; + + kc = (uint32_t*)&info[1]; + for (i = xkb->min_key_code; i <= xkb->max_key_code; i++, kc++) + *kc = i; + + return info->length * 4; +} + +static void +SwapKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) +{ + char n; + uint32_t *key; + int i; + swaps(&info->type, n); + swaps(&info->length, n); + + for (i = 0, key = (uint32_t*)&info[1]; i < info->num_keycodes; i++, key++) + swapl(key, n); + + swaps(&info->num_keycodes, n); +} + +/** + * List axis information for the given axis. + * + * @return The number of bytes written into info. + */ +int +ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber) +{ + ValuatorClassPtr v = dev->valuator; + + info->type = ValuatorClass; + info->length = sizeof(xXIValuatorInfo)/4; + info->name = XIGetKnownProperty(AXIS_LABEL_PROP_REL_MISC); /* XXX */ + info->min.integral = v->axes[axisnumber].min_value; + info->min.frac = 0; + info->max.integral = v->axes[axisnumber].max_value; + info->max.frac = 0; + info->resolution = v->axes[axisnumber].resolution; + info->number = axisnumber; + info->mode = v->mode; /* Server doesn't have per-axis mode yet */ + + return info->length * 4; +} + +static void +SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) +{ + char n; + swaps(&info->type, n); + swaps(&info->length, n); + swapl(&info->name, n); + swapl(&info->min.integral, n); + swapl(&info->min.frac, n); + swapl(&info->max.integral, n); + swapl(&info->max.frac, n); + swaps(&info->number, n); +} + +int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) +{ + DeviceIntPtr master = dev->u.master; + int use; + + if (IsMaster(dev)) + { + DeviceIntPtr paired = GetPairedDevice(dev); + use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; + *attachment = (paired ? paired->id : 0); + } else if (master) + { + use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; + *attachment = master->id; + } else + use = XIFloatingSlave; + + return use; +} + +/** + * Write the info for device dev into the buffer pointed to by info. + * + * @return The number of bytes used. + */ +static int +ListDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) +{ + char *any = (char*)&info[1]; + int len = 0, total_len = 0; + + info->deviceid = dev->id; + info->use = GetDeviceUse(dev, &info->attachment); + info->num_classes = 0; + info->name_len = strlen(dev->name); + info->enabled = dev->enabled; + total_len = sizeof(xXIDeviceInfo); + + len = ((info->name_len + 3)/4) * 4; + memset(any, 0, len); + strncpy(any, dev->name, info->name_len); + any += len; + total_len += len; + + return total_len + ListDeviceClasses(dev, any, &info->num_classes); +} + +/** + * Write the class info of the device into the memory pointed to by any, set + * nclasses to the number of classes in total and return the number of bytes + * written. + */ +int +ListDeviceClasses(DeviceIntPtr dev, char *any, uint16_t *nclasses) +{ + int total_len = 0; + int len; + int i; + + if (dev->button) + { + (*nclasses)++; + len = ListButtonInfo(dev, (xXIButtonInfo*)any); + any += len; + total_len += len; + } + + if (dev->key) + { + (*nclasses)++; + len = ListKeyInfo(dev, (xXIKeyInfo*)any); + any += len; + total_len += len; + } + + for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) + { + (*nclasses)++; + len = ListValuatorInfo(dev, (xXIValuatorInfo*)any, i); + any += len; + total_len += len; + } + + return total_len; +} + +static void +SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) +{ + char n; + char *any = (char*)&info[1]; + int i; + + /* Skip over name */ + any += (((info->name_len + 3)/4) * 4); + + for (i = 0; i < info->num_classes; i++) + { + int len = ((xXIAnyInfo*)any)->length; + switch(((xXIAnyInfo*)any)->type) + { + case XIButtonClass: + SwapButtonInfo(dev, (xXIButtonInfo*)any); + break; + case XIKeyClass: + SwapKeyInfo(dev, (xXIKeyInfo*)any); + break; + case XIValuatorClass: + SwapValuatorInfo(dev, (xXIValuatorInfo*)any); + break; + } + + any += len * 4; + } + + swaps(&info->deviceid, n); + swaps(&info->use, n); + swaps(&info->attachment, n); + swaps(&info->num_classes, n); + swaps(&info->name_len, n); + +} diff --git a/Xi/xiquerydevice.h b/Xi/xiquerydevice.h new file mode 100644 index 000000000..34e87bdde --- /dev/null +++ b/Xi/xiquerydevice.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: Peter Hutterer + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef QUERYDEV_H +#define QUERYDEV_H 1 + +#include + +int SProcXIQueryDevice(ClientPtr client); +int ProcXIQueryDevice(ClientPtr client); +void SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep); +int SizeDeviceClasses(DeviceIntPtr dev); +int ListDeviceClasses(DeviceIntPtr dev, char* any, uint16_t* nclasses); +int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment); +int ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info); +int ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info); +int ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber); +#endif /* QUERYDEV_H */ diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c new file mode 100644 index 000000000..1d00b9e6b --- /dev/null +++ b/Xi/xiquerypointer.c @@ -0,0 +1,210 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request to query the pointer location of an extension input device. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#include "extnsionst.h" +#include "exevents.h" +#include "exglobals.h" +#include "eventconvert.h" +#include "xkbsrv.h" + +#ifdef PANORAMIX +#include "panoramiXsrv.h" +#endif + +#include "xiquerypointer.h" + +/*********************************************************************** + * + * This procedure allows a client to query the pointer of a device. + * + */ + +int +SProcXIQueryPointer(ClientPtr client) +{ + char n; + + REQUEST(xXIQueryPointerReq); + swaps(&stuff->length, n); + return (ProcXIQueryPointer(client)); +} + +int +ProcXIQueryPointer(ClientPtr client) +{ + int rc; + xXIQueryPointerReply rep; + DeviceIntPtr pDev, kbd; + WindowPtr pWin, t; + SpritePtr pSprite; + XkbStatePtr state; + char *buttons = NULL; + + REQUEST(xXIQueryPointerReq); + REQUEST_SIZE_MATCH(xXIQueryPointerReq); + + if (stuff->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = stuff->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess); + if (rc != Success) + return rc; + + if (pDev->valuator == NULL) + { + client->errorValue = stuff->deviceid; + return BadDevice; + } + + rc = dixLookupWindow(&pWin, stuff->win, client, DixReadAccess); + if (rc != Success) + { + SendErrorToClient(client, IReqCode, X_XIQueryPointer, + stuff->win, rc); + return Success; + } + + if (pDev->valuator->motionHintWindow) + MaybeStopHint(pDev, client); + + kbd = GetPairedDevice(pDev); + + pSprite = pDev->spriteInfo->sprite; + rep.repType = X_Reply; + rep.RepType = X_XIQueryPointer; + rep.length = 5; + rep.sequenceNumber = client->sequence; + rep.root = (GetCurrentRootWindow(pDev))->drawable.id; + rep.root_x = FP1616(pSprite->hot.x, 0); + rep.root_y = FP1616(pSprite->hot.y, 0); + rep.child = None; + + state = &kbd->key->xkbInfo->prev_state; + rep.mods.base_mods = state->base_mods; + rep.mods.latched_mods = state->latched_mods; + rep.mods.locked_mods = state->locked_mods; + + rep.group.base_group = state->base_group; + rep.group.latched_group = state->latched_group; + rep.group.locked_group = state->locked_group; + + if (pDev->button) + { + int i, down; + rep.buttons_len = (((pDev->button->numButtons + 7)/8) + 3)/4; + rep.length += rep.buttons_len; + buttons = xcalloc(rep.buttons_len, 4); + if (!buttons) + return BadAlloc; + + down = pDev->button->buttonsDown; + + for (i = 0; i < pDev->button->numButtons && down; i++) + { + if (BitIsOn(pDev->button->down, i)) + { + SetBit(buttons, i); + down--; + } + } + } else + rep.buttons_len = 0; + + if (pSprite->hot.pScreen == pWin->drawable.pScreen) + { + rep.same_screen = xTrue; + rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0); + rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0); + for (t = pSprite->win; t; t = t->parent) + if (t->parent == pWin) + { + rep.child = t->drawable.id; + break; + } + } else + { + rep.same_screen = xFalse; + rep.win_x = 0; + rep.win_y = 0; + } + +#ifdef PANORAMIX + if(!noPanoramiXExtension) { + rep.root_x += FP1616(panoramiXdataPtr[0].x, 0); + rep.root_y += FP1616(panoramiXdataPtr[0].y, 0); + if (stuff->win == rep.root) + { + rep.win_x += FP1616(panoramiXdataPtr[0].x, 0); + rep.win_y += FP1616(panoramiXdataPtr[0].y, 0); + } + } +#endif + + WriteReplyToClient(client, sizeof(xXIQueryPointerReply), &rep); + if (buttons) + WriteToClient(client, rep.buttons_len * 4, buttons); + + xfree(buttons); + + return Success; +} + +/*********************************************************************** + * + * This procedure writes the reply for the XIQueryPointer function, + * if the client and server have a different byte ordering. + * + */ + +void +SRepXIQueryPointer(ClientPtr client, int size, + xXIQueryPointerReply * rep) +{ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + WriteToClient(client, size, (char *)rep); +} + diff --git a/Xi/xiquerypointer.h b/Xi/xiquerypointer.h new file mode 100644 index 000000000..ea22376a6 --- /dev/null +++ b/Xi/xiquerypointer.h @@ -0,0 +1,39 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef QUERYDP_H +#define QUERYDP_H 1 + +int SProcXIQueryPointer(ClientPtr /* client */); +int ProcXIQueryPointer(ClientPtr /* client */); +void SRepXIQueryPointer(ClientPtr /* client */ , + int /* size */ , + xXIQueryPointerReply * /* rep */); + +#endif /* QUERYDP_H */ diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c new file mode 100644 index 000000000..ae63297da --- /dev/null +++ b/Xi/xiqueryversion.c @@ -0,0 +1,128 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: Peter Hutterer + * + */ + +/** + * @file xiqueryversion.c + * Protocol handling for the XIQueryVersion request/reply. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + + +#include "inputstr.h" + +#include +#include +#include + +#include "exglobals.h" +#include "exevents.h" +#include "xiqueryversion.h" +#include "misc.h" + +extern XExtensionVersion XIVersion; /* defined in getvers.c */ +/** + * Return the supported XI version. + * + * Saves the version the client claims to support as well, for future + * reference. + */ +int +ProcXIQueryVersion(ClientPtr client) +{ + xXIQueryVersionReply rep; + XIClientPtr pXIClient; + int major, minor; + unsigned int sversion, cversion; + + REQUEST(xXIQueryVersionReq); + REQUEST_SIZE_MATCH(xXIQueryVersionReq); + + /* This request only exists after XI2 */ + if (stuff->major_version < 2) + { + client->errorValue = stuff->major_version; + return BadValue; + } + + pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + + sversion = XIVersion.major_version * 1000 + XIVersion.minor_version; + cversion = stuff->major_version * 1000 + stuff->minor_version; + + if (sversion > cversion) + { + major = stuff->major_version; + minor = stuff->minor_version; + } else + { + major = XIVersion.major_version; + minor = XIVersion.minor_version; + } + + pXIClient->major_version = major; + pXIClient->minor_version = minor; + + memset(&rep, 0, sizeof(xXIQueryVersionReply)); + rep.repType = X_Reply; + rep.RepType = X_XIQueryVersion; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.major_version = major; + rep.minor_version = minor; + + WriteReplyToClient(client, sizeof(xXIQueryVersionReply), &rep); + + return Success; +} + +/* Swapping routines */ + +int +SProcXIQueryVersion(ClientPtr client) +{ + char n; + + REQUEST(xXIQueryVersionReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXIQueryVersionReq); + swaps(&stuff->major_version, n); + swaps(&stuff->minor_version, n); + return (ProcXIQueryVersion(client)); +} + +void +SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply *rep) +{ + char n; + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->major_version, n); + swaps(&rep->minor_version, n); + WriteToClient(client, size, (char *)rep); +} diff --git a/Xi/xiqueryversion.h b/Xi/xiqueryversion.h new file mode 100644 index 000000000..06bb7291a --- /dev/null +++ b/Xi/xiqueryversion.h @@ -0,0 +1,40 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: Peter Hutterer + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include + +#ifndef QUERYVERSION_H +#define QUERYVERSION_H 1 + +int SProcXIQueryVersion(ClientPtr client); +int ProcXIQueryVersion(ClientPtr client); +void SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply* rep); + +#endif /* QUERYVERSION_H */ diff --git a/Xi/xisetclientpointer.c b/Xi/xisetclientpointer.c new file mode 100644 index 000000000..264807475 --- /dev/null +++ b/Xi/xisetclientpointer.c @@ -0,0 +1,113 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request to set the client pointer for the owner of the given window. + * All subsequent calls that are ambiguous will choose the client pointer as + * default value. + */ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#include "extnsionst.h" +#include "exevents.h" +#include "exglobals.h" + +#include "xisetclientpointer.h" + +int +SProcXISetClientPointer(ClientPtr client) +{ + char n; + + REQUEST(xXISetClientPointerReq); + swaps(&stuff->length, n); + swapl(&stuff->win, n); + swaps(&stuff->deviceid, n); + REQUEST_SIZE_MATCH(xXISetClientPointerReq); + return (ProcXISetClientPointer(client)); +} + +int +ProcXISetClientPointer(ClientPtr client) +{ + DeviceIntPtr pDev; + ClientPtr targetClient; + int rc; + + REQUEST(xXISetClientPointerReq); + REQUEST_SIZE_MATCH(xXISetClientPointerReq); + + if (stuff->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = stuff->deviceid; + return BadImplementation; + } + + rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess); + if (rc != Success) + { + client->errorValue = stuff->deviceid; + return rc; + } + + if (!IsMaster(pDev)) + { + client->errorValue = stuff->deviceid; + return BadDevice; + } + + pDev = GetMaster(pDev, MASTER_POINTER); + + if (stuff->win != None) + { + rc = dixLookupClient(&targetClient, stuff->win, client, + DixWriteAccess); + + if (rc != Success) + return BadWindow; + + } else + targetClient = client; + + if (!SetClientPointer(targetClient, pDev)) + { + client->errorValue = stuff->deviceid; + return BadDevice; + } + + return Success; +} diff --git a/Xi/xisetclientpointer.h b/Xi/xisetclientpointer.h new file mode 100644 index 000000000..5968d98da --- /dev/null +++ b/Xi/xisetclientpointer.h @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef SETCPTR_H +#define SETCPTR_H 1 + +int SProcXISetClientPointer(ClientPtr /* client */); +int ProcXISetClientPointer(ClientPtr /* client */); + +#endif /* SETCPTR_H */ diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c new file mode 100644 index 000000000..f3acfe468 --- /dev/null +++ b/Xi/xiwarppointer.c @@ -0,0 +1,179 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +/*********************************************************************** + * + * Request to Warp the pointer location of an extension input device. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#include "extnsionst.h" +#include "exevents.h" +#include "exglobals.h" +#include "mipointer.h" /* for miPointerUpdateSprite */ + + +#include "xiwarppointer.h" +/*********************************************************************** + * + * This procedure allows a client to warp the pointer of a device. + * + */ + +int +SProcXIWarpPointer(ClientPtr client) +{ + char n; + + REQUEST(xXIWarpPointerReq); + swaps(&stuff->length, n); + return (ProcXIWarpPointer(client)); +} + +int +ProcXIWarpPointer(ClientPtr client) +{ + int rc; + int x, y; + WindowPtr dest = NULL; + DeviceIntPtr pDev; + SpritePtr pSprite; + ScreenPtr newScreen; + + REQUEST(xXIWarpPointerReq); + REQUEST_SIZE_MATCH(xXIWarpPointerReq); + + if (stuff->deviceid > 0xFF) /* FIXME */ + { + client->errorValue = stuff->deviceid; + return BadImplementation; + } + + /* FIXME: panoramix stuff is missing, look at ProcWarpPointer */ + + rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess); + + if (rc != Success) + return rc; + + if (stuff->dst_win != None) + { + rc = dixLookupWindow(&dest, stuff->dst_win, client, DixReadAccess); + if (rc != Success) + { + return rc; + } + } + + pSprite = pDev->spriteInfo->sprite; + x = pSprite->hotPhys.x; + y = pSprite->hotPhys.y; + + if (stuff->src_win != None) + { + int winX, winY; + WindowPtr src; + + rc = dixLookupWindow(&src, stuff->src_win, client, DixReadAccess); + if (rc != Success) + { + return rc; + } + + winX = src->drawable.x; + winY = src->drawable.y; + if (src->drawable.pScreen != pSprite->hotPhys.pScreen || + x < winX + stuff->src_x || + y < winY + stuff->src_y || + (stuff->src_width != 0 && + winX + stuff->src_x + (int)stuff->src_width < 0) || + (stuff->src_height != 0 && + winY + stuff->src_y + (int)stuff->src_height < y) || + !PointInWindowIsVisible(src, x, y)) + return Success; + } + + if (dest) + { + x = dest->drawable.x; + y = dest->drawable.y; + newScreen = dest->drawable.pScreen; + } else + newScreen = pSprite->hotPhys.pScreen; + + x += stuff->dst_x; + y += stuff->dst_y; + + if (x < 0) + x = 0; + else if (x > newScreen->width) + x = newScreen->width - 1; + + if (y < 0) + y = 0; + else if (y > newScreen->height) + y = newScreen->height - 1; + + if (newScreen == pSprite->hotPhys.pScreen) + { + if (x < pSprite->physLimits.x1) + x = pSprite->physLimits.x1; + else if (x >= pSprite->physLimits.x2) + x = pSprite->physLimits.x2 - 1; + + if (y < pSprite->physLimits.y1) + y = pSprite->physLimits.y1; + else if (y >= pSprite->physLimits.y2) + y = pSprite->physLimits.y2 - 1; + + if (pSprite->hotShape) + ConfineToShape(pDev, pSprite->hotShape, &x, &y); + (*newScreen->SetCursorPosition)(pDev, newScreen, x, y, TRUE); + } else if (!PointerConfinedToScreen(pDev)) + { + NewCurrentScreen(pDev, newScreen, x, y); + } + + /* if we don't update the device, we get a jump next time it moves */ + pDev->last.valuators[0] = x; + pDev->last.valuators[1] = y; + miPointerUpdateSprite(pDev); + + /* FIXME: XWarpPointer is supposed to generate an event. It doesn't do it + here though. */ + return Success; +} + diff --git a/Xi/xiwarppointer.h b/Xi/xiwarppointer.h new file mode 100644 index 000000000..aafc73904 --- /dev/null +++ b/Xi/xiwarppointer.h @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef WARPDEVP_H +#define WARPDEVP_H 1 + +int SProcXIWarpPointer(ClientPtr /* client */); +int ProcXIWarpPointer(ClientPtr /* client */); + +#endif /* WARPDEVP_H */ diff --git a/dix/devices.c b/dix/devices.c index 3996ca64a..2b0358875 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -78,11 +78,11 @@ SOFTWARE. #include #include "exglobals.h" #include "exevents.h" -#include "querydev.h" /* for SizeDeviceClasses */ +#include "xiquerydevice.h" /* for SizeDeviceClasses */ #include "xiproperty.h" #include "enterleave.h" /* for EnterWindow() */ #include "xserver-properties.h" -#include "chdevhier.h" /* For XISendDeviceHierarchyEvent */ +#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */ /** @file * This file handles input device-related stuff. diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 85ddd61f2..ac2b0c310 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -45,7 +45,7 @@ #include "events.h" #include "exglobals.h" #include "eventconvert.h" -#include "querydev.h" +#include "xiquerydevice.h" #include "xkbsrv.h" -- cgit v1.2.3