diff options
author | Joel Bosveld <joel.bosveld@gmail.com> | 2009-09-08 23:06:00 +0800 |
---|---|---|
committer | Joel Bosveld <joel.bosveld@gmail.com> | 2009-09-08 23:55:13 +0800 |
commit | 1ba17340a98a34b40f78442963aa4132e6cfae5c (patch) | |
tree | d11d814844e4ad037d146133250b73f28cdb3e31 /dix/devices.c | |
parent | 5e38708c3466129c3e5af40a915c044bb26e083f (diff) | |
parent | 1bdc9ec617d357b076c9e69296018bc212d91c7d (diff) |
Conflicts:
test/Makefile.am
Diffstat (limited to 'dix/devices.c')
-rw-r--r-- | dix/devices.c | 105 |
1 files changed, 22 insertions, 83 deletions
diff --git a/dix/devices.c b/dix/devices.c index b237e03b1..0be3d58ab 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -72,6 +72,7 @@ SOFTWARE. #include "swaprep.h" #include "dixevents.h" #include "mipointer.h" +#include "eventstr.h" #include <X11/extensions/XI.h> #include <X11/extensions/XI2.h> @@ -93,21 +94,7 @@ DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKeyIndex; /* Used to store classes currently not in use by an MD */ static int UnusedClassesPrivateKeyIndex; DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKeyIndex; -/* Used to store if a device is an XTest Virtual device */ -static int XTstDevicePrivateKeyIndex; -DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex; -/** - * vxtstpointer - * is the virtual pointer for XTest. It is the first slave - * device of the VCP. - * vxtstkeyboard - * is the virtual keyboard for XTest. It is the first slave - * device of the VCK - * - * Neither of these devices can be deleted. - */ -DeviceIntPtr vxtstpointer, vxtstkeyboard; static void RecalculateMasterButtons(DeviceIntPtr slave); @@ -447,6 +434,8 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) } OsReleaseSignals(); + LeaveWindow(dev); + SetFocusOut(dev); *prev = dev->next; dev->next = inputInfo.off_devices; @@ -528,7 +517,7 @@ CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) /** * Device control function for the Virtual Core Keyboard. */ -static int +int CoreKeyboardProc(DeviceIntPtr pDev, int what) { @@ -557,7 +546,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what) /** * Device control function for the Virtual Core Pointer. */ -static int +int CorePointerProc(DeviceIntPtr pDev, int what) { #define NBUTTONS 7 @@ -624,6 +613,7 @@ InitCoreDevices(void) { if (AllocDevicePair(serverClient, "Virtual core", &inputInfo.pointer, &inputInfo.keyboard, + CorePointerProc, CoreKeyboardProc, TRUE) != Success) FatalError("Failed to allocate core devices"); @@ -634,24 +624,7 @@ InitCoreDevices(void) !EnableDevice(inputInfo.keyboard, TRUE)) FatalError("Failed to enable core devices."); - /* - Allocate an virtual slave device for xtest events, this - is a slave device to inputInfo master devices - */ - if(AllocXtstDevice(serverClient, "Virtual core", - &vxtstpointer, - &vxtstkeyboard) != Success) - FatalError("Failed to allocate XTst devices"); - - if (ActivateDevice(vxtstpointer, TRUE) != Success || - ActivateDevice(vxtstkeyboard, TRUE) != Success) - FatalError("Failed to activate xtst core devices."); - if (!EnableDevice(vxtstpointer, TRUE) || - !EnableDevice(vxtstkeyboard, TRUE)) - FatalError("Failed to enable xtst core devices."); - - AttachDevice(NULL, vxtstpointer, inputInfo.pointer); - AttachDevice(NULL, vxtstkeyboard, inputInfo.keyboard); + InitXTestDevices(); } /** @@ -1172,6 +1145,8 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels, butc->sourceid = dev->id; for (i = 1; i <= numButtons; i++) butc->map[i] = map[i]; + for (i = numButtons + 1; i < MAP_LENGTH; i++) + butc->map[i] = i; memcpy(butc->labels, labels, numButtons * sizeof(Atom)); dev->button = butc; return TRUE; @@ -1225,7 +1200,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, dev->last.numValuators = numAxes; if (IsMaster(dev) || /* do not accelerate master or xtest devices */ - dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey )) + IsXTestDevice(dev, NULL)) InitPointerAccelerationScheme(dev, PtrAccelNoOp); else InitPointerAccelerationScheme(dev, PtrAccelDefault); @@ -1530,7 +1505,7 @@ ProcSetModifierMapping(ClientPtr client) REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); if (client->req_len != ((stuff->numKeyPerModifier << 1) + - (sizeof (xSetModifierMappingReq) >> 2))) + bytes_to_int32(sizeof(xSetModifierMappingReq)))) return BadLength; rep.type = X_Reply; @@ -1589,7 +1564,7 @@ ProcChangeKeyboardMapping(ClientPtr client) int rc; REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); - len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq)); if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) return BadLength; @@ -1648,7 +1623,8 @@ ProcSetPointerMapping(ClientPtr client) REQUEST(xSetPointerMappingReq); REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); - if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2) + if (client->req_len != + bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) return BadLength; rep.type = X_Reply; rep.length = 0; @@ -2227,7 +2203,7 @@ ProcGetMotionEvents(ClientPtr client) nEvents++; } } - rep.length = nEvents * (sizeof(xTimecoord) >> 2); + rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord)); rep.nEvents = nEvents; WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); if (nEvents) @@ -2389,11 +2365,6 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) InitializeSprite(dev, currentRoot); dev->spriteInfo->spriteOwner = FALSE; dev->spriteInfo->paired = dev; - - /* Floating an SD makes it appear to XI 1 clients */ - SendDevicePresenceEvent(dev->id, DeviceAdded); - if (dev->enabled) - SendDevicePresenceEvent(dev->id, DeviceEnabled); } else { dev->spriteInfo->sprite = master->spriteInfo->sprite; @@ -2401,14 +2372,6 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) dev->spriteInfo->spriteOwner = FALSE; RecalculateMasterButtons(master); - - if (!oldmaster) - { - /* Attaching a floating SD makes it disappear to XI 1 clients */ - if (dev->enabled) - SendDevicePresenceEvent(dev->id, DeviceDisabled); - SendDevicePresenceEvent(dev->id, DeviceRemoved); - } } /* If we were connected to master device before, this MD may need to @@ -2498,15 +2461,18 @@ GetMaster(DeviceIntPtr dev, int which) */ int AllocDevicePair (ClientPtr client, char* name, - DeviceIntPtr* ptr, DeviceIntPtr* keybd, - Bool master) + DeviceIntPtr* ptr, + DeviceIntPtr* keybd, + DeviceProc ptr_proc, + DeviceProc keybd_proc, + Bool master) { DeviceIntPtr pointer; DeviceIntPtr keyboard; ClassesPtr classes; *ptr = *keybd = NULL; - pointer = AddInputDevice(client, CorePointerProc, TRUE); + pointer = AddInputDevice(client, ptr_proc, TRUE); if (!pointer) return BadAlloc; @@ -2526,7 +2492,7 @@ AllocDevicePair (ClientPtr client, char* name, pointer->last.slave = NULL; pointer->type = (master) ? MASTER_POINTER : SLAVE; - keyboard = AddInputDevice(client, CoreKeyboardProc, TRUE); + keyboard = AddInputDevice(client, keybd_proc, TRUE); if (!keyboard) { RemoveDevice(pointer, FALSE); @@ -2562,30 +2528,3 @@ AllocDevicePair (ClientPtr client, char* name, return Success; } -/** - * Allocate a device pair that is initialised as a slave - * device with properties that identify the devices as belonging - * to XTest subsystem. - * This only creates the pair, Activate/Enable Device - * still need to be called. - */ -int AllocXtstDevice (ClientPtr client, char* name, - DeviceIntPtr* ptr, DeviceIntPtr* keybd) -{ - int retval; - int len = strlen(name); - char *xtstname = xcalloc(len + 6, 1 ); - - strncpy( xtstname, name, len); - strncat( xtstname, " Xtst", 5 ); - - retval = AllocDevicePair( client, xtstname, ptr, keybd, FALSE); - if ( retval == Success ){ - dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)True ); - dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey,(void *)True); - } - - xfree( xtstname ); - - return retval; -} |