summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-20 15:28:16 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-22 15:44:50 +1000
commitb12d302df8283186ce87882c29b2b0294adb2770 (patch)
tree7b2f4ce175d1a1aec64a354b922429b50dcc8bde /dix
parentadd2defac7e59dcb355e5ba12b6de60861741d57 (diff)
Input: rename DeviceIntRec->isMaster to ->type.
isMaster is not enough as long as we differ between master pointers and keyboard. With flexible device classes, the usual checks for whether a master device is a pointer (currently check for ->button, ->valuators or ->key) do not work as an SD may post an event through a master and mess this check up. Example, a device with valuators but no buttons would remove the button class from the VCP and thus result in the IsPointerDevice(inputInfo.pointer) == FALSE. This will become worse in the future when new device classes are introduced that aren't provided in the current system (e.g. a switch class). This patch replaces isMaster with "type", one of SLAVE, MASTER_POINTER and MASTER_KEYBOARD. All checks for dev->isMaster are replaced with an IsMaster(dev).
Diffstat (limited to 'dix')
-rw-r--r--dix/devices.c52
-rw-r--r--dix/enterleave.c4
-rw-r--r--dix/events.c41
-rw-r--r--dix/getevents.c8
-rw-r--r--dix/inpututils.c4
5 files changed, 58 insertions, 51 deletions
diff --git a/dix/devices.c b/dix/devices.c
index e7da2ad1d..3d0d30d29 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -152,7 +152,7 @@ PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd)
return BadDevice;
/* Don't allow pairing for slave devices */
- if (!ptr->isMaster || !kbd->isMaster)
+ if (!IsMaster(ptr) || !IsMaster(kbd))
return BadDevice;
if (ptr->spriteInfo->paired)
@@ -180,7 +180,7 @@ NextFreePointerDevice(void)
{
DeviceIntPtr dev;
for (dev = inputInfo.devices; dev; dev = dev->next)
- if (dev->isMaster &&
+ if (IsMaster(dev) &&
dev->spriteInfo->spriteOwner &&
!dev->spriteInfo->paired)
return dev;
@@ -306,7 +306,7 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
if (!dev->spriteInfo->sprite)
{
- if (dev->isMaster)
+ if (IsMaster(dev))
{
/* Sprites appear on first root window, so we can hardcode it */
if (dev->spriteInfo->spriteOwner)
@@ -398,7 +398,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
return FALSE;
/* float attached devices */
- if (dev->isMaster)
+ if (IsMaster(dev))
{
for (other = inputInfo.devices; other; other = other->next)
{
@@ -413,12 +413,12 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
{
for (other = inputInfo.devices; other; other = other->next)
{
- if (other->isMaster && other->u.lastSlave == dev)
+ if (IsMaster(other) && other->u.lastSlave == dev)
other->u.lastSlave = NULL;
}
}
- if (dev->isMaster && dev->spriteInfo->sprite)
+ if (IsMaster(dev) && dev->spriteInfo->sprite)
{
for (other = inputInfo.devices; other; other = other->next)
{
@@ -488,7 +488,7 @@ ActivateDevice(DeviceIntPtr dev, BOOL sendevent)
return ret;
/* Initialize memory for sprites. */
- if (dev->isMaster && dev->spriteInfo->spriteOwner)
+ if (IsMaster(dev) && dev->spriteInfo->spriteOwner)
pScreen->DeviceCursorInitialize(dev, pScreen);
SendDevicePresenceEvent(dev->id, DeviceAdded);
@@ -847,7 +847,7 @@ CloseDevice(DeviceIntPtr dev)
(void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
/* free sprite memory */
- if (dev->isMaster && dev->spriteInfo->sprite)
+ if (IsMaster(dev) && dev->spriteInfo->sprite)
screen->DeviceCursorCleanup(dev, screen);
/* free acceleration info */
@@ -859,7 +859,7 @@ CloseDevice(DeviceIntPtr dev)
classes = (ClassesPtr)&dev->key;
FreeAllDeviceClasses(classes);
- if (dev->isMaster)
+ if (IsMaster(dev))
{
classes = dixLookupPrivate(&dev->devPrivates, UnusedClassesPrivateKey);
FreeAllDeviceClasses(classes);
@@ -904,7 +904,7 @@ CloseDownDevices(void)
*/
for (dev = inputInfo.devices; dev; dev = dev->next)
{
- if (!dev->isMaster && dev->u.master)
+ if (!IsMaster(dev) && dev->u.master)
dev->u.master = NULL;
}
@@ -990,7 +990,7 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
else
prev->next = next;
- flags[tmp->id] = (tmp->isMaster) ? XIMasterRemoved : XISlaveRemoved;
+ flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
CloseDevice(tmp);
ret = Success;
}
@@ -1000,7 +1000,7 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
next = tmp->next;
if (tmp == dev) {
- flags[tmp->id] = (tmp->isMaster) ? XIMasterRemoved : XISlaveRemoved;
+ flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
CloseDevice(tmp);
if (prev == NULL)
@@ -1194,7 +1194,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
}
dev->last.numValuators = numAxes;
- if(dev->isMaster) /* master devs do not accelerate */
+ if(IsMaster(dev)) /* master devs do not accelerate */
InitPointerAccelerationScheme(dev, PtrAccelNoOp);
else
InitPointerAccelerationScheme(dev, PtrAccelDefault);
@@ -1226,7 +1226,7 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
if(!val)
return FALSE;
- if(dev->isMaster && (scheme != PtrAccelNoOp))
+ if(IsMaster(dev) && (scheme != PtrAccelNoOp))
scheme = PtrAccelNoOp; /* no accel for master devices */
for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
@@ -1587,7 +1587,7 @@ ProcChangeKeyboardMapping(ClientPtr client)
stuff->keyCodes, NULL, client);
for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
- if (tmp->isMaster || tmp->u.master != pDev)
+ if (IsMaster(tmp) || tmp->u.master != pDev)
continue;
if (!tmp->key)
continue;
@@ -1932,7 +1932,7 @@ ProcChangeKeyboardControl (ClientPtr client)
keyboard = PickKeyboard(client);
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard || (!pDev->isMaster && pDev->u.master == keyboard)) &&
+ if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
if (ret != Success)
@@ -1941,7 +1941,7 @@ ProcChangeKeyboardControl (ClientPtr client)
}
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard || (!pDev->isMaster && pDev->u.master == keyboard)) &&
+ if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
if (ret != Success)
@@ -2010,7 +2010,7 @@ ProcBell(ClientPtr client)
newpercent = base - newpercent + stuff->percent;
for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == keybd || (!dev->isMaster && dev->u.master == keybd)) &&
+ if ((dev == keybd || (!IsMaster(dev) && dev->u.master == keybd)) &&
dev->kbdfeed && dev->kbdfeed->BellProc) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess);
@@ -2082,7 +2082,7 @@ ProcChangePointerControl(ClientPtr client)
}
for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == mouse || (!dev->isMaster && dev->u.master == mouse)) &&
+ if ((dev == mouse || (!IsMaster(dev) && dev->u.master == mouse)) &&
dev->ptrfeed && dev->ptrfeed->CtrlProc) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess);
if (rc != Success)
@@ -2091,7 +2091,7 @@ ProcChangePointerControl(ClientPtr client)
}
for (dev = inputInfo.devices; dev; dev = dev->next) {
- if ((dev == mouse || (!dev->isMaster && dev->u.master == mouse)) &&
+ if ((dev == mouse || (!IsMaster(dev) && dev->u.master == mouse)) &&
dev->ptrfeed && dev->ptrfeed->CtrlProc) {
dev->ptrfeed->ctrl = ctrl;
(*dev->ptrfeed->CtrlProc)(dev, &mouse->ptrfeed->ctrl);
@@ -2246,10 +2246,10 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
{
ScreenPtr screen;
DeviceIntPtr oldmaster;
- if (!dev || dev->isMaster)
+ if (!dev || IsMaster(dev))
return BadDevice;
- if (master && !master->isMaster) /* can't attach to slaves */
+ if (master && !IsMaster(master)) /* can't attach to slaves */
return BadDevice;
/* set from floating to floating? */
@@ -2310,7 +2310,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
{
DeviceIntPtr it;
for (it = inputInfo.devices; it; it = it->next)
- if (!it->isMaster && it->u.master == oldmaster)
+ if (!IsMaster(it) && it->u.master == oldmaster)
break;
if (!it) /* no dev is paired with old master */
@@ -2338,7 +2338,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
DeviceIntPtr
GetPairedDevice(DeviceIntPtr dev)
{
- if (!dev->isMaster && dev->u.master)
+ if (!IsMaster(dev) && dev->u.master)
dev = dev->u.master;
return dev->spriteInfo->paired;
@@ -2380,7 +2380,7 @@ AllocDevicePair (ClientPtr client, char* name,
pointer->u.lastSlave = NULL;
pointer->last.slave = NULL;
- pointer->isMaster = master;
+ pointer->type = (master) ? MASTER_POINTER : SLAVE;
keyboard = AddInputDevice(client, CoreKeyboardProc, TRUE);
if (!keyboard)
@@ -2403,7 +2403,7 @@ AllocDevicePair (ClientPtr client, char* name,
keyboard->u.lastSlave = NULL;
keyboard->last.slave = NULL;
- keyboard->isMaster = master;
+ keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE;
/* The ClassesRec stores the device classes currently not used. */
diff --git a/dix/enterleave.c b/dix/enterleave.c
index e45d061d4..eadcc4558 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -546,7 +546,7 @@ CoreEnterLeaveEvents(DeviceIntPtr dev,
WindowPtr to,
int mode)
{
- if (!dev->isMaster)
+ if (!IsMaster(dev))
return;
LeaveWindow(dev, from, mode);
@@ -1216,7 +1216,7 @@ CoreFocusEvents(DeviceIntPtr dev,
WindowPtr to,
int mode)
{
- if (!dev->isMaster)
+ if (!IsMaster(dev))
return;
SetFocusOut(dev, from);
diff --git a/dix/events.c b/dix/events.c
index 10814fa25..3222950f7 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -329,7 +329,7 @@ DevHasCursor(DeviceIntPtr pDev)
Bool
IsPointerDevice(DeviceIntPtr dev)
{
- return (dev->valuator && dev->button);
+ return (dev->type == MASTER_POINTER) || (dev->valuator && dev->button);
}
/*
@@ -342,7 +342,14 @@ IsPointerDevice(DeviceIntPtr dev)
Bool
IsKeyboardDevice(DeviceIntPtr dev)
{
- return (dev->key && dev->kbdfeed) && !IsPointerDevice(dev);
+ return (dev->type == MASTER_KEYBOARD) ||
+ ((dev->key && dev->kbdfeed) && !IsPointerDevice(dev));
+}
+
+Bool
+IsMaster(DeviceIntPtr dev)
+{
+ return (dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD);
}
static WindowPtr XYToWindow(
@@ -455,7 +462,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
return ((inputMasks->xi2mask[dev->id][evtype/8] & filter) ||
inputMasks->xi2mask[XIAllDevices][evtype/8] ||
- (inputMasks->xi2mask[XIAllMasterDevices][evtype/8] && dev->isMaster));
+ (inputMasks->xi2mask[XIAllMasterDevices][evtype/8] && IsMaster(dev)));
}
static Mask
@@ -467,7 +474,7 @@ GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
int byte = ((xGenericEvent*)event)->evtype / 8;
return (other->xi2mask[dev->id][byte] |
other->xi2mask[XIAllDevices][byte] |
- (dev->isMaster? other->xi2mask[XIAllMasterDevices][byte] : 0));
+ (IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0));
} else if (CORE_EVENT(event))
return other->mask[XIAllDevices];
else
@@ -1404,7 +1411,7 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
The correct thing to do would be to freeze all SDs attached to the
paired master device.
*/
- if (thisDev->isMaster)
+ if (IsMaster(thisDev))
{
dev = GetPairedDevice(thisDev);
if (otherMode == GrabModeSync)
@@ -1453,7 +1460,7 @@ RestoreOldMaster(DeviceIntPtr dev)
{
GrabMemoryPtr gm;
- if (dev->isMaster)
+ if (IsMaster(dev))
return;
gm = (GrabMemoryPtr)dixLookupPrivate(&dev->devPrivates, GrabPrivateKey);
@@ -1491,7 +1498,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
Bool isPassive = autoGrab & ~ImplicitGrabMask;
/* slave devices need to float for the duration of the grab. */
- if (!isPassive && !mouse->isMaster)
+ if (!isPassive && !IsMaster(mouse))
{
SaveOldMaster(mouse);
AttachDevice(NULL, mouse, NULL);
@@ -1569,7 +1576,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool pass
WindowPtr oldWin;
/* slave devices need to float for the duration of the grab. */
- if (!passive && !keybd->isMaster)
+ if (!passive && !IsMaster(keybd))
{
SaveOldMaster(keybd);
AttachDevice(NULL, keybd, NULL);
@@ -2311,7 +2318,7 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
filter = GetEventFilter(dev, &ev);
if (type && (inputMasks = wOtherInputMasks(win)) &&
((inputMasks->xi2mask[XIAllDevices][type/8] & filter) ||
- ((inputMasks->xi2mask[XIAllMasterDevices][type/8] & filter) && dev->isMaster) ||
+ ((inputMasks->xi2mask[XIAllMasterDevices][type/8] & filter) && IsMaster(dev)) ||
(inputMasks->xi2mask[dev->id][type/8] & filter)))
rc |= XI2_MASK;
@@ -2430,7 +2437,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
}
/* Core event */
- if ((mask & CORE_MASK) && dev->isMaster && dev->coreEvents)
+ if ((mask & CORE_MASK) && IsMaster(dev) && dev->coreEvents)
{
rc = EventToCore(event, &core);
if (rc != Success)
@@ -3160,7 +3167,7 @@ ProcWarpPointer(ClientPtr client)
dev = PickPointer(client);
for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
- if ((tmp == dev) || (!tmp->isMaster && tmp->u.master == dev)) {
+ if ((tmp == dev) || (!IsMaster(tmp) && tmp->u.master == dev)) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
if (rc != Success)
return rc;
@@ -3492,7 +3499,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
int i;
WindowPtr pWin = NULL;
FocusClassPtr focus = IsPointerEvent((InternalEvent*)event) ? NULL : device->focus;
- BOOL sendCore = (device->isMaster && device->coreEvents);
+ BOOL sendCore = (IsMaster(device) && device->coreEvents);
if (event->type != ET_ButtonPress &&
event->type != ET_KeyPress)
@@ -3548,7 +3555,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
{
DeviceIntPtr ptr;
WindowPtr focus = keybd->focus->win;
- BOOL sendCore = (keybd->isMaster && keybd->coreEvents);
+ BOOL sendCore = (IsMaster(keybd) && keybd->coreEvents);
xEvent core;
xEvent *xE = NULL, *xi2 = NULL;
int count, rc;
@@ -3714,7 +3721,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
mask = grab->eventMask;
- sendCore = (thisDev->isMaster && thisDev->coreEvents);
+ sendCore = (IsMaster(thisDev) && thisDev->coreEvents);
/* try core event */
if (sendCore && grab->grabtype == GRABTYPE_CORE)
{
@@ -4201,7 +4208,7 @@ DeviceEnterLeaveEvent(
if (BitIsOn(mouse->button->down, i))
SetBit(&event[1], i);
- kbd = (mouse->isMaster || mouse->u.master) ? GetPairedDevice(mouse) : NULL;
+ kbd = (IsMaster(mouse) || mouse->u.master) ? GetPairedDevice(mouse) : NULL;
if (kbd && kbd->key)
{
event->mods.base_mods = kbd->key->xkbInfo->state.base_mods;
@@ -5583,7 +5590,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
Bool
SetClientPointer(ClientPtr client, ClientPtr setter, DeviceIntPtr device)
{
- if (!device->isMaster)
+ if (!IsMaster(device))
{
ErrorF("[dix] Need master device for ClientPointer. This is a bug.\n");
return FALSE;
@@ -5627,7 +5634,7 @@ PickPointer(ClientPtr client)
DeviceIntPtr it = inputInfo.devices;
while (it)
{
- if (it->isMaster && it->spriteInfo->spriteOwner)
+ if (IsMaster(it) && it->spriteInfo->spriteOwner)
{
client->clientPtr = it;
break;
diff --git a/dix/getevents.c b/dix/getevents.c
index e40b3dbe9..5ff4f91b9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -325,7 +325,7 @@ AllocateMotionHistory(DeviceIntPtr pDev)
* potential valuators, plus the respective range of the valuators.
* 3 * INT32 for (min_val, max_val, curr_val))
*/
- if (pDev->isMaster)
+ if (IsMaster(pDev))
size = sizeof(INT32) * 3 * MAX_VALUATORS;
else
size = sizeof(INT32) * pDev->valuator->numAxes;
@@ -369,7 +369,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
if (core && !pScreen)
return 0;
- if (pDev->isMaster)
+ if (IsMaster(pDev))
size = (sizeof(INT32) * 3 * MAX_VALUATORS) + sizeof(Time);
else
size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
@@ -421,7 +421,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
coord = rescaleValuatorAxis(coord, &from, to, pScreen->height);
memcpy(corebuf, &coord, sizeof(INT16));
- } else if (pDev->isMaster)
+ } else if (IsMaster(pDev))
{
memcpy(obuff, ibuff, sizeof(Time)); /* copy timestamp */
@@ -497,7 +497,7 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
return;
v = pDev->valuator;
- if (pDev->isMaster)
+ if (IsMaster(pDev))
{
buff += ((sizeof(INT32) * 3 * MAX_VALUATORS) + sizeof(CARD32)) *
v->last_motion;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 152214506..79b6ab7c7 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -268,9 +268,9 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap,
do_modmap_change(client, dev, modmap);
/* Change any attached masters/slaves. */
- if (dev->isMaster) {
+ if (IsMaster(dev)) {
for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
- if (!tmp->isMaster && tmp->u.master == dev)
+ if (!IsMaster(tmp) && tmp->u.master == dev)
if (check_modmap_change_slave(client, dev, tmp, modmap))
do_modmap_change(client, tmp, modmap);
}