[PATCH 19/20] input: Change a bunch of direct dev->u.master accesses to use GetMaster()

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


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c          |    2 +-
 Xi/xichangehierarchy.c |    4 ++--
 Xi/xiquerydevice.c     |    2 +-
 dix/devices.c          |   10 +++++-----
 dix/events.c           |    4 ++--
 mi/mieq.c              |   10 ++++++----
 6 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 0df6579..7368960 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -716,7 +716,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
     if (IsFloating(slave))
         return; /* set floating since the event */
 
-    if (slave->u.master->id != dce->masterid)
+    if (GetMaster(slave, MASTER_ATTACHED)->id != dce->masterid)
         return; /* not our slave anymore, don't care */
 
     /* FIXME: we probably need to send a DCE for the new slave now */
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index b9cdedf..6683f6a 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -282,12 +282,12 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
         for (attached = inputInfo.devices; attached; attached = attached->next)
         {
             if (!IsMaster(attached)) {
-                if (attached->u.master == ptr)
+                if (GetMaster(attached, MASTER_ATTACHED) == ptr)
                 {
                     AttachDevice(client, attached, newptr);
                     flags[attached->id] |= XISlaveAttached;
                 }
-                if (attached->u.master == keybd)
+                if (GetMaster(attached, MASTER_ATTACHED) == keybd)
                 {
                     AttachDevice(client, attached, newkeybd);
                     flags[attached->id] |= XISlaveAttached;
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 3cad8d7..8b54211 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -375,7 +375,7 @@ SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info)
 
 int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment)
 {
-    DeviceIntPtr master = dev->u.master;
+    DeviceIntPtr master = GetMaster(dev, MASTER_ATTACHED);
     int use;
 
     if (IsMaster(dev))
diff --git a/dix/devices.c b/dix/devices.c
index f7018d0..058f32b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -446,7 +446,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
     {
         for (other = inputInfo.devices; other; other = other->next)
         {
-            if (other->u.master == dev)
+            if (!IsMaster(other) && GetMaster(other, MASTER_ATTACHED) == dev)
             {
                 AttachDevice(NULL, other, NULL);
                 flags[other->id] |= XISlaveDetached;
@@ -2327,7 +2327,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
     for (dev = inputInfo.devices; dev; dev = dev->next)
     {
         if (IsMaster(dev) ||
-            dev->u.master != master ||
+            GetMaster(dev, MASTER_ATTACHED) != master ||
             !dev->button)
             continue;
 
@@ -2408,8 +2408,8 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
         free(dev->spriteInfo->sprite);
     }
 
-    oldmaster = dev->u.master;
-    dev->u.master = master;
+    oldmaster = GetMaster(dev, MASTER_ATTACHED);
+    dev->master = master;
 
     /* If device is set to floating, we need to create a sprite for it,
      * otherwise things go bad. However, we don't want to render the cursor,
@@ -2460,7 +2460,7 @@ DeviceIntPtr
 GetPairedDevice(DeviceIntPtr dev)
 {
     if (!IsMaster(dev) && !IsFloating(dev))
-        dev = dev->u.master;
+        dev = GetMaster(dev, MASTER_ATTACHED);
 
     return dev->spriteInfo->paired;
 }
diff --git a/dix/events.c b/dix/events.c
index b0e52f1..8b3bfb7 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1407,7 +1407,7 @@ DetachFromMaster(DeviceIntPtr dev)
     if (!IsFloating(dev))
         return;
 
-    dev->saved_master_id = dev->u.master->id;
+    dev->saved_master_id = GetMaster(dev, MASTER_ATTACHED)->id;
 
     AttachDevice(NULL, dev, NULL);
 }
@@ -3237,7 +3237,7 @@ ProcWarpPointer(ClientPtr client)
     dev = PickPointer(client);
 
     for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
-        if ((tmp == dev) || (!IsMaster(tmp) && tmp->u.master == dev)) {
+        if (GetMaster(tmp, MASTER_ATTACHED) == dev) {
 	    rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
 	    if (rc != Success)
 		return rc;
diff --git a/mi/mieq.c b/mi/mieq.c
index 6853103..a3e6085 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -321,6 +321,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
     DeviceIntPtr mdev;
     int len = original->any.length;
     int type = original->any.type;
+    int mtype; /* which master type? */
 
     CHECKEVENT(original);
 
@@ -337,20 +338,21 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
     {
         case ET_KeyPress:
         case ET_KeyRelease:
-            mdev = GetMaster(sdev, MASTER_KEYBOARD);
+            mtype = MASTER_KEYBOARD;
             break;
         case ET_ButtonPress:
         case ET_ButtonRelease:
         case ET_Motion:
         case ET_ProximityIn:
         case ET_ProximityOut:
-            mdev = GetMaster(sdev, MASTER_POINTER);
+            mtype = MASTER_POINTER;
             break;
         default:
-            mdev = sdev->u.master;
+            mtype = MASTER_ATTACHED;
             break;
     }
 
+    mdev = GetMaster(sdev, mtype);
     memcpy(copy, original, len);
     ChangeDeviceID(mdev, copy);
     FixUpEventForMaster(mdev, sdev, original, copy);
@@ -466,7 +468,7 @@ mieqProcessInputEvents(void)
         pthread_mutex_unlock(&miEventQueueMutex);
 #endif
 
-        master  = (dev && !IsMaster(dev) && dev->u.master) ? dev->u.master : NULL;
+        master = (dev) ? GetMaster(dev, MASTER_ATTACHED) : NULL;
 
         if (screenIsSaved == SCREEN_SAVER_ON)
             dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
-- 
1.7.4



More information about the xorg-devel mailing list