This is not a straightforward search/replacement due to a long-standing issue.
dev->u.master is the same field as dev->u.lastSlave. Thus, if dev is a master device, a check for dev->u.master may give us false positives and false negatives. The switch to IsFloating() spells out these cases and modifies the conditions accordingly to cover both cases. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- Xi/exevents.c | 6 +++--- Xi/xipassivegrab.c | 10 ++-------- Xi/xiquerydevice.c | 2 +- Xi/xiquerypointer.c | 2 +- Xi/xiwarppointer.c | 2 +- dix/devices.c | 8 ++++---- dix/events.c | 6 +++--- dix/getevents.c | 6 +++--- dix/inpututils.c | 2 +- mi/mieq.c | 6 +++--- mi/mipointer.c | 4 ++-- mi/misprite.c | 16 ++++++++-------- xkb/xkb.c | 2 +- xkb/xkbAccessX.c | 2 +- xkb/xkbActions.c | 6 +++--- 15 files changed, 37 insertions(+), 43 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index b39e202..ea9daa9 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -713,7 +713,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) if (IsMaster(slave)) return; - if (!slave->u.master) + if (IsFloating(slave)) return; /* set floating since the event */ if (slave->u.master->id != dce->masterid) @@ -1009,7 +1009,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) b = device->button; k = device->key; - if (IsMaster(device) || !device->u.master) + if (IsMaster(device) || IsFloating(device)) CheckMotion(event, device); switch (event->type) @@ -1226,7 +1226,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, DeviceIntPtr mouse; int btlen, len, i; - mouse = (IsMaster(dev) || dev->u.master) ? GetMaster(dev, MASTER_POINTER) : dev; + mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER); /* XI 2 event */ btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0; diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index e99b6e5..8663d12 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -162,10 +162,7 @@ ProcXIPassiveGrabDevice(ClientPtr client) if (!modifiers_failed) return BadAlloc; - if (!IsMaster(dev) && dev->u.master) - mod_dev = GetMaster(dev, MASTER_KEYBOARD); - else - mod_dev = dev; + mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { @@ -280,10 +277,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client) if (rc != Success) return rc; - if (!IsMaster(dev) && dev->u.master) - mod_dev = GetMaster(dev, MASTER_KEYBOARD); - else - mod_dev = dev; + mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); tempGrab.resource = client->clientAsMask; tempGrab.device = dev; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index fdd2c05..3cad8d7 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -383,7 +383,7 @@ int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) DeviceIntPtr paired = GetPairedDevice(dev); use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; *attachment = (paired ? paired->id : 0); - } else if (master) + } else if (!IsFloating(dev)) { use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; *attachment = master->id; diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index b521c48..26fb43a 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -93,7 +93,7 @@ ProcXIQueryPointer(ClientPtr client) } if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || - (!IsMaster(pDev) && pDev->u.master)) /* no attached devices */ + (!IsMaster(pDev) && !IsFloating(pDev))) /* no attached devices */ { client->errorValue = stuff->deviceid; return BadDevice; diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c index c01b115..a463ab9 100644 --- a/Xi/xiwarppointer.c +++ b/Xi/xiwarppointer.c @@ -97,7 +97,7 @@ ProcXIWarpPointer(ClientPtr client) return rc; } - if ((!IsMaster(pDev) && pDev->u.master) || + if ((!IsMaster(pDev) && !IsFloating(pDev)) || (IsMaster(pDev) && !IsPointerDevice(pDev))) { client->errorValue = stuff->deviceid; diff --git a/dix/devices.c b/dix/devices.c index 6c0dc42..a3367f7 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -987,7 +987,7 @@ CloseDownDevices(void) */ for (dev = inputInfo.devices; dev; dev = dev->next) { - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) dev->u.master = NULL; } @@ -2397,11 +2397,11 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) return BadDevice; /* set from floating to floating? */ - if (!dev->u.master && !master && dev->enabled) + if (IsFloating(dev) && !master && dev->enabled) return Success; /* free the existing sprite. */ - if (!dev->u.master && dev->spriteInfo->paired == dev) + if (IsFloating(dev) && dev->spriteInfo->paired == dev) { screen = miPointerGetScreen(dev); screen->DeviceCursorCleanup(dev, screen); @@ -2459,7 +2459,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) DeviceIntPtr GetPairedDevice(DeviceIntPtr dev) { - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) dev = dev->u.master; return dev->spriteInfo->paired; diff --git a/dix/events.c b/dix/events.c index f6d92cf..b0e52f1 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1404,7 +1404,7 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) static void DetachFromMaster(DeviceIntPtr dev) { - if (!dev->u.master) + if (!IsFloating(dev)) return; dev->saved_master_id = dev->u.master->id; @@ -2806,7 +2806,7 @@ WindowsRestructured(void) DeviceIntPtr pDev = inputInfo.devices; while(pDev) { - if (IsMaster(pDev) || !pDev->u.master) + if (IsMaster(pDev) || IsFloating(pDev)) CheckMotion(NULL, pDev); pDev = pDev->next; } @@ -3401,7 +3401,7 @@ CheckPassiveGrabsOnWindow( * attached master keyboard. Since the slave may have been * reattached after the grab, the modifier device may not be the * same. */ - if (!IsMaster(grab->device) && device->u.master) + if (!IsMaster(grab->device) && !IsFloating(device)) gdev = GetMaster(device, MASTER_KEYBOARD); } diff --git a/dix/getevents.c b/dix/getevents.c index 60282a8..5b8e379 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -767,7 +767,7 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask) /* if attached, clip both x and y to the defined limits (usually * co-ord space limit). If it is attached, we need x/y to go over the * limits to be able to change screens. */ - if(dev->u.master && dev->valuator) { + if(dev->valuator && IsMaster(dev) || !IsFloating(dev)) { if (valuator_get_mode(dev, 0) == Absolute) clipAxis(dev, 0, x); if (valuator_get_mode(dev, 1) == Absolute) @@ -865,7 +865,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac, * to the current screen. */ miPointerSetPosition(dev, screenx, screeny); - if (dev->u.master) { + if(!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); master->last.valuators[0] = *screenx; master->last.valuators[1] = *screeny; @@ -912,7 +912,7 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms) return; updateMotionHistory(dev, ms, mask, dev->last.valuators); - if (dev->u.master) + if(!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); updateMotionHistory(master, ms, mask, dev->last.valuators); diff --git a/dix/inpututils.c b/dix/inpututils.c index ef3142c..8b7b035 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -273,7 +273,7 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap, do_modmap_change(client, tmp, modmap); } } - else if (dev->u.master && dev->u.master->u.lastSlave == dev) { + else if (!IsFloating(dev) && dev->u.master->u.lastSlave == dev) { /* If this fails, expect the results to be weird. */ if (check_modmap_change(client, dev->u.master, modmap)) do_modmap_change(client, dev->u.master, modmap); diff --git a/mi/mieq.c b/mi/mieq.c index c0020c3..6853103 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -325,7 +325,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev, CHECKEVENT(original); /* ET_XQuartz has sdev == NULL */ - if (!sdev || IsMaster(sdev) || !sdev->u.master) + if (!sdev || IsMaster(sdev) || IsFloating(sdev)) return NULL; #if XFreeXDGA @@ -410,7 +410,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, handler(screenNum, event, dev); /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) handler(screenNum, &mevent, master); } else { @@ -419,7 +419,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) master->public.processInputProc(&mevent, master); } } diff --git a/mi/mipointer.c b/mi/mipointer.c index aa0ca6d..5b82978 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -73,7 +73,7 @@ DevPrivateKeyRec miPointerScreenKeyRec; DevPrivateKeyRec miPointerPrivKeyRec; #define MIPOINTER(dev) \ - ((!IsMaster(dev) && !dev->u.master) ? \ + (IsFloating(dev) ? \ (miPointerPtr)dixLookupPrivate(&(dev)->devPrivates, miPointerPrivKey): \ (miPointerPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miPointerPrivKey)) @@ -332,7 +332,7 @@ miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) { SetupScreen(pScreen); - if (!IsMaster(pDev) && pDev->u.master) + if (!IsMaster(pDev) && !IsFloating(pDev)) return; (*pScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen); diff --git a/mi/misprite.c b/mi/misprite.c index 770951e..b0290af 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -143,7 +143,7 @@ typedef struct { #endif #define MISPRITE(dev) \ - ((!IsMaster(dev) && !dev->u.master) ? \ + (IsFloating(dev) ? \ (miCursorInfoPtr)dixLookupPrivate(&dev->devPrivates, miSpriteDevPrivatesKey) : \ (miCursorInfoPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miSpriteDevPrivatesKey)) @@ -766,7 +766,7 @@ miSpriteRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return FALSE; pCursorInfo = MISPRITE(pDev); @@ -790,7 +790,7 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, miCursorInfoPtr pPointer; miSpriteScreenPtr pScreenPriv; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pPointer = MISPRITE(pDev); @@ -848,7 +848,7 @@ miSpriteMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { CursorPtr pCursor; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pCursor = MISPRITE(pDev)->pCursor; @@ -905,7 +905,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen) miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -944,7 +944,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -985,7 +985,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -1025,7 +1025,7 @@ miSpriteComputeSaved (DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pCursorInfo = MISPRITE(pDev); diff --git a/xkb/xkb.c b/xkb/xkb.c index 6fd66c5..43d847a 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5883,7 +5883,7 @@ ProcXkbGetKbdByName(ClientPtr client) nkn.changed|= XkbNKN_GeometryMask; XkbSendNewKeyboardNotify(dev,&nkn); - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) { DeviceIntPtr master = dev->u.master; if (master->u.lastSlave == dev) diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 10c38ca..12fe2a1 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -694,7 +694,7 @@ ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); DeviceEvent *event = &ev->device_event; - dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse; + dev = IsFloating(mouse) ? mouse : GetMaster(mouse, MASTER_KEYBOARD); if (dev && dev->key) { diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 8d7c124..eda409c 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1367,7 +1367,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat mpointer = GetMaster(dev, MASTER_POINTER); lastSlave = mpointer->u.lastSlave; ptr = GetXTestDevice(mpointer); - } else if (!dev->u.master) + } else if (IsFloating(dev)) ptr = dev; else return; @@ -1397,7 +1397,7 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y) int gpe_flags = 0; /* ignore attached SDs */ - if (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) != NULL) + if (!IsMaster(dev) && !IsFloating(dev)) return; if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY) @@ -1427,7 +1427,7 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) if (IsMaster(dev)) { DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER); ptr = GetXTestDevice(mpointer); - } else if (!dev->u.master) + } else if (IsFloating(dev)) ptr = dev; else return; -- 1.7.4 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel