diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-02-11 12:47:37 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-02-22 14:35:44 +1000 |
commit | dc57f89959e549403f8488eb9f23425bd7118b22 (patch) | |
tree | 905bf161dacd34e15051811955842ef9eaf65d10 /Xi | |
parent | e48bf3b6403dde33586ca0e421db61e402525453 (diff) |
Switch to use IsFloating()
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.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 6 | ||||
-rw-r--r-- | Xi/xipassivegrab.c | 10 | ||||
-rw-r--r-- | Xi/xiquerydevice.c | 2 | ||||
-rw-r--r-- | Xi/xiquerypointer.c | 2 | ||||
-rw-r--r-- | Xi/xiwarppointer.c | 2 |
5 files changed, 8 insertions, 14 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index b39e202ff..ea9daa905 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 e99b6e554..8663d12a1 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 fdd2c051d..3cad8d7f1 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 8df958ea2..51317994b 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 c01b115f3..a463ab94d 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; |