[PATCH] input: don't use typecasts to access members of InternalEvent.

Peter Hutterer peter.hutterer at who-t.net
Sun Sep 20 23:52:35 PDT 2009


To avoid confusion, the member names are now postfixed with _event.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c               |    4 ++--
 dix/eventconvert.c          |   10 +++++-----
 dix/events.c                |   10 +++++-----
 hw/xfree86/common/xf86DGA.c |    2 +-
 include/eventstr.h          |    8 ++++----
 mi/mieq.c                   |   12 ++++++------
 xkb/xkbAccessX.c            |    2 +-
 xkb/xkbPrKeyEv.c            |    2 +-
 8 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 0211e72..b0e0ede 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -944,7 +944,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
     int ret = 0;
     int state, i;
     DeviceIntPtr mouse = NULL, kbd = NULL;
-    DeviceEvent *event = (DeviceEvent*)ev;
+    DeviceEvent *event = &ev->device_event;
 
     CHECKEVENT(ev);
 
@@ -954,7 +954,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
         ev->any.type == ET_RawButtonRelease ||
         ev->any.type == ET_RawMotion)
     {
-        ProcessRawEvent((RawDeviceEvent*)ev, device);
+        ProcessRawEvent(&ev->raw_event, device);
         return;
     }
 
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 21eed40..d91ba67 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -107,7 +107,7 @@ EventToCore(InternalEvent *event, xEvent *core)
         case ET_KeyPress:
         case ET_KeyRelease:
             {
-                DeviceEvent *e = (DeviceEvent*)event;
+                DeviceEvent *e = &event->device_event;
 
                 if (e->detail.key > 0xFF)
                     return BadMatch;
@@ -167,7 +167,7 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
         case ET_KeyRelease:
         case ET_ProximityIn:
         case ET_ProximityOut:
-            return eventToKeyButtonPointer((DeviceEvent*)ev, xi, count);
+            return eventToKeyButtonPointer(&ev->device_event, xi, count);
         case ET_DeviceChanged:
         case ET_RawKeyPress:
         case ET_RawKeyRelease:
@@ -215,19 +215,19 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
         case ET_ButtonRelease:
         case ET_KeyPress:
         case ET_KeyRelease:
-            return eventToDeviceEvent((DeviceEvent*)ev, xi);
+            return eventToDeviceEvent(&ev->device_event, xi);
         case ET_ProximityIn:
         case ET_ProximityOut:
             *xi = NULL;
             return BadMatch;
         case ET_DeviceChanged:
-            return eventToDeviceChanged((DeviceChangedEvent*)ev, xi);
+            return eventToDeviceChanged(&ev->changed_event, xi);
         case ET_RawKeyPress:
         case ET_RawKeyRelease:
         case ET_RawButtonPress:
         case ET_RawButtonRelease:
         case ET_RawMotion:
-            return eventToRawEvent((RawDeviceEvent*)ev, xi);
+            return eventToRawEvent(&ev->raw_event, xi);
         default:
             break;
     }
diff --git a/dix/events.c b/dix/events.c
index 0d01df5..a79cf6d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -809,7 +809,7 @@ CheckVirtualMotion(
 
     if (qe)
     {
-        ev = (DeviceEvent*)qe->event;
+        ev = &qe->event->device_event;
         switch(ev->type)
         {
             case ET_Motion:
@@ -1130,7 +1130,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
     QdEventPtr	qe;
     SpritePtr	pSprite = device->spriteInfo->sprite;
     int		eventlen;
-    DeviceEvent *event = (DeviceEvent*)ev;
+    DeviceEvent *event = &ev->device_event;
 
     NoticeTime((InternalEvent*)event);
 
@@ -1179,7 +1179,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
             (tail->device == device) &&
 	    (tail->pScreen == pSprite->hotPhys.pScreen))
 	{
-            DeviceEvent *tailev = (DeviceEvent*)tail->event;
+            DeviceEvent *tailev = &tail->event->device_event;
 	    tailev->root_x = pSprite->hotPhys.x;
 	    tailev->root_y = pSprite->hotPhys.y;
 	    tailev->time = event->time;
@@ -1238,7 +1238,7 @@ PlayReleasedEvents(void)
 	      will translate from sprite screen to screen 0 upon reentry
 	      to the DIX layer */
 	    if(!noPanoramiXExtension) {
-                DeviceEvent *ev = (DeviceEvent*)(qe->event);
+                DeviceEvent *ev = &qe->event->device_event;
                 switch(ev->type)
                 {
                     case ET_Motion:
@@ -3993,7 +3993,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
 	    FreezeThaw(thisDev, TRUE);
 	    if (!grabinfo->sync.event)
 		grabinfo->sync.event = xcalloc(1, sizeof(InternalEvent));
-	    *grabinfo->sync.event = *(DeviceEvent*)event;
+	    *grabinfo->sync.event = event->device_event;
 	    break;
 	}
     }
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 8328f58..42b7c58 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1193,7 +1193,7 @@ DGAGetOldDGAMode(int index)
 static void
 DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
 {
-    DGAEvent	    *event= (DGAEvent*)ev;
+    DGAEvent	    *event= &ev->dga_event;
     ScreenPtr       pScreen = screenInfo.screens[screen_num];
     DGAScreenPtr    pScreenPriv;
 
diff --git a/include/eventstr.h b/include/eventstr.h
index f082db3..509982b 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -221,12 +221,12 @@ union _InternalEvent {
             int length;           /**< Length in bytes */
             Time time;            /**< Time in ms. */
         } any;
-        DeviceEvent device;
-        DeviceChangedEvent changed;
+        DeviceEvent device_event;
+        DeviceChangedEvent changed_event;
 #if XFreeXDGA
-        DGAEvent dga;
+        DGAEvent dga_event;
 #endif
-        RawDeviceEvent raw;
+        RawDeviceEvent raw_event;
 };
 
 #endif
diff --git a/mi/mieq.c b/mi/mieq.c
index 0b64882..4c6c3bd 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -269,7 +269,7 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
         case ET_ProximityOut:
         case ET_Hierarchy:
         case ET_DeviceChanged:
-            event->device.deviceid = dev->id;
+            event->device_event.deviceid = dev->id;
             break;
 #if XFreeXDGA
         case ET_DGAEvent:
@@ -280,7 +280,7 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
         case ET_RawButtonPress:
         case ET_RawButtonRelease:
         case ET_RawMotion:
-            event->raw.deviceid = dev->id;
+            event->raw_event.deviceid = dev->id;
             break;
         default:
             ErrorF("[mi] Unknown event type (%d), cannot change id.\n",
@@ -299,11 +299,11 @@ FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev,
     if (original->any.type == ET_ButtonPress ||
         original->any.type == ET_ButtonRelease)
     {
-        int btn = original->device.detail.button;
+        int btn = original->device_event.detail.button;
         if (!sdev->button)
             return; /* Should never happen */
 
-        master->device.detail.button = sdev->button->map[btn];
+        master->device_event.detail.button = sdev->button->map[btn];
     }
 }
 
@@ -382,8 +382,8 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
         case ET_ButtonRelease:
             if (dev && screen && screen != DequeueScreen(dev) && !handler) {
                 DequeueScreen(dev) = screen;
-                x = event->device.root_x;
-                y = event->device.root_y;
+                x = event->device_event.root_x;
+                y = event->device_event.root_y;
                 NewCurrentScreen (dev, DequeueScreen(dev), x, y);
             }
             break;
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index fd30a1c..2fc7642 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -690,7 +690,7 @@ XkbSrvInfoPtr	xkbi = NULL;
 unsigned 	changed = 0;
 ProcessInputProc backupproc;
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
-DeviceEvent     *event = (DeviceEvent*)ev;
+DeviceEvent     *event = &ev->device_event;
 
     dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse;
 
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index 8f6705f..630f17c 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -148,7 +148,7 @@ ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd)
     XkbSrvInfoPtr xkbi = NULL;
     ProcessInputProc backup_proc;
     xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd);
-    DeviceEvent *event = (DeviceEvent*)ev;
+    DeviceEvent *event = &ev->device_event;
     int is_press = (event->type == ET_KeyPress);
     int is_release = (event->type == ET_KeyRelease);
 
-- 
1.6.3.rc1.2.g0164.dirty


More information about the xorg-devel mailing list