[PATCH 20/20] Move master/lastSlave out of the union into separate fields.

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 17 19:52:27 PST 2011


The removal of the double-use will cause some suble bugs as some conditions
to check for the dev->u.master case were broken and also evaluated as true
if lastSlave was set (instead of master).

Also breaks the input ABI.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/devices.c                      |   12 ++++++------
 dix/events.c                       |    4 ++--
 dix/inpututils.c                   |    6 +++---
 include/inputstr.h                 |    6 ++----
 mi/mieq.c                          |    2 +-
 test/xi2/protocol-xiquerypointer.c |    2 +-
 test/xi2/protocol-xiwarppointer.c  |    2 +-
 xkb/xkb.c                          |    4 ++--
 xkb/xkbActions.c                   |    2 +-
 9 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index 058f32b..8fb06bb 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -457,8 +457,8 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
     {
         for (other = inputInfo.devices; other; other = other->next)
         {
-	    if (IsMaster(other) && other->u.lastSlave == dev)
-		other->u.lastSlave = NULL;
+	    if (IsMaster(other) && other->lastSlave == dev)
+		other->lastSlave = NULL;
 	}
     }
 
@@ -988,7 +988,7 @@ CloseDownDevices(void)
     for (dev = inputInfo.devices; dev; dev = dev->next)
     {
         if (!IsMaster(dev) && !IsFloating(dev))
-            dev->u.master = NULL;
+            dev->master = NULL;
     }
 
     CloseDeviceList(&inputInfo.devices);
@@ -2486,7 +2486,7 @@ GetMaster(DeviceIntPtr dev, int which)
     if (IsMaster(dev))
         master = dev;
     else
-        master = dev->u.master;
+        master = dev->master;
 
     if (master && which != MASTER_ATTACHED)
     {
@@ -2541,7 +2541,7 @@ AllocDevicePair (ClientPtr client, char* name,
     pointer->coreEvents = TRUE;
     pointer->spriteInfo->spriteOwner = TRUE;
 
-    pointer->u.lastSlave = NULL;
+    pointer->lastSlave = NULL;
     pointer->last.slave = NULL;
     pointer->type = (master) ? MASTER_POINTER : SLAVE;
 
@@ -2567,7 +2567,7 @@ AllocDevicePair (ClientPtr client, char* name,
     keyboard->coreEvents = TRUE;
     keyboard->spriteInfo->spriteOwner = FALSE;
 
-    keyboard->u.lastSlave = NULL;
+    keyboard->lastSlave = NULL;
     keyboard->last.slave = NULL;
     keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE;
 
diff --git a/dix/events.c b/dix/events.c
index 8b3bfb7..f39d8a9 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3244,8 +3244,8 @@ ProcWarpPointer(ClientPtr client)
 	}
     }
 
-    if (dev->u.lastSlave)
-        dev = dev->u.lastSlave;
+    if (dev->lastSlave)
+        dev = dev->lastSlave;
     pSprite = dev->spriteInfo->sprite;
 
 #ifdef PANORAMIX
diff --git a/dix/inpututils.c b/dix/inpututils.c
index abeabf2..077ffce 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -273,10 +273,10 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap,
                     do_modmap_change(client, tmp, modmap);
         }
     }
-    else if (!IsFloating(dev) && GetMaster(dev, MASTER_KEYBOARD)->u.lastSlave == dev) {
+    else if (!IsFloating(dev) && GetMaster(dev, MASTER_KEYBOARD)->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);
+        if (check_modmap_change(client, dev->master, modmap))
+            do_modmap_change(client, dev->master, modmap);
     }
 
     return Success;
diff --git a/include/inputstr.h b/include/inputstr.h
index 58d318f..4c67e3d 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -530,10 +530,8 @@ typedef struct _DeviceIntRec {
     PrivateRec		*devPrivates;
     DeviceUnwrapProc    unwrapProc;
     SpriteInfoPtr       spriteInfo;
-    union {
-        DeviceIntPtr        master;     /* master device */
-        DeviceIntPtr        lastSlave;  /* last slave device used */
-    } u;
+    DeviceIntPtr        master;     /* master device */
+    DeviceIntPtr        lastSlave;  /* last slave device used */
 
     /* last valuator values recorded, not posted to client;
      * for slave devices, valuators is in device coordinates
diff --git a/mi/mieq.c b/mi/mieq.c
index a3e6085..08a0c87 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -402,7 +402,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
     master = CopyGetMasterEvent(dev, event, &mevent);
 
     if (master)
-        master->u.lastSlave = dev;
+        master->lastSlave = dev;
 
     /* If someone's registered a custom event handler, let them
      * steal it. */
diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
index 810c615..a42d595 100644
--- a/test/xi2/protocol-xiquerypointer.c
+++ b/test/xi2/protocol-xiquerypointer.c
@@ -185,7 +185,7 @@ static void test_XIQueryPointer(void)
     request_XIQueryPointer(&client_request, &request, BadDevice);
 
     test_data.dev = devices.mouse;
-    devices.mouse->u.master = NULL; /* Float, kind-of */
+    devices.mouse->master = NULL; /* Float, kind-of */
     request.deviceid = devices.mouse->id;
     request_XIQueryPointer(&client_request, &request, Success);
 
diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
index 4f8860e..75b7617 100644
--- a/test/xi2/protocol-xiwarppointer.c
+++ b/test/xi2/protocol-xiwarppointer.c
@@ -145,7 +145,7 @@ static void test_XIWarpPointer(void)
     request.deviceid = devices.kbd->id;
     request_XIWarpPointer(&client_request, &request, BadDevice);
 
-    devices.mouse->u.master = NULL; /* Float, kind-of */
+    devices.mouse->master = NULL; /* Float, kind-of */
     request.deviceid = devices.mouse->id;
     request_XIWarpPointer(&client_request, &request, Success);
 
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 169c604..3c36060 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5886,9 +5886,9 @@ ProcXkbGetKbdByName(ClientPtr client)
 
 	if (!IsMaster(dev) && (master = GetMaster(dev, MASTER_KEYBOARD)))
 	{
-	    if (master->u.lastSlave == dev)
+	    if (master->lastSlave == dev)
 	    {
-		XkbCopyDeviceKeymap(dev->u.master, dev);
+		XkbCopyDeviceKeymap(dev->master, dev);
 		XkbSendNewKeyboardNotify(dev,&nkn);
 	    }
 	}
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index eda409c..65c678a 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1365,7 +1365,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat
 
     if (IsMaster(dev)) {
         mpointer = GetMaster(dev, MASTER_POINTER);
-        lastSlave = mpointer->u.lastSlave;
+        lastSlave = mpointer->lastSlave;
         ptr = GetXTestDevice(mpointer);
     } else if (IsFloating(dev))
         ptr = dev;
-- 
1.7.4



More information about the xorg-devel mailing list