[PATCH v2 24/29] Use C99 designated initializers in extension Events

Alan Coopersmith alan.coopersmith at oracle.com
Wed Jul 4 15:37:38 PDT 2012


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 Xext/saver.c                          |   23 ++++---
 Xext/security.c                       |    8 +--
 Xext/shape.c                          |   21 +++---
 Xext/shm.c                            |   16 ++---
 Xext/sync.c                           |   18 ++---
 Xext/xvdisp.c                         |   16 ++---
 Xext/xvmain.c                         |   26 +++----
 Xi/chgdctl.c                          |   13 ++--
 Xi/grabdevb.c                         |   15 +++--
 Xi/grabdevk.c                         |   15 +++--
 Xi/xiproperty.c                       |   39 +++++------
 damageext/damageext.c                 |   20 +++---
 glx/glxdri2.c                         |    5 +-
 hw/xfree86/common/xf86DGA.c           |  120 ++++++++++++++++-----------------
 hw/xfree86/dixmods/extmod/xf86vmode.c |   21 +++---
 hw/xfree86/dri2/dri2ext.c             |   28 ++++----
 randr/rrcrtc.c                        |   34 ++++------
 randr/rroutput.c                      |   36 +++++-----
 randr/rrproperty.c                    |   47 ++++++-------
 randr/rrscreen.c                      |   41 +++++------
 xfixes/cursor.c                       |   16 ++---
 xfixes/select.c                       |   23 +++----
 xkb/xkbEvents.c                       |   39 ++++++-----
 23 files changed, 321 insertions(+), 319 deletions(-)

diff --git a/Xext/saver.c b/Xext/saver.c
index e1e86c0..7f70bc0 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -406,7 +406,6 @@ SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
     ScreenSaverScreenPrivatePtr pPriv;
     ScreenSaverEventPtr pEv;
     unsigned long mask;
-    xScreenSaverNotifyEvent ev;
     int kind;
 
     UpdateCurrentTimeIf();
@@ -424,16 +423,18 @@ SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
     else
         kind = ScreenSaverInternal;
     for (pEv = pPriv->events; pEv; pEv = pEv->next) {
-        if (!(pEv->mask & mask))
-            continue;
-        ev.type = ScreenSaverNotify + ScreenSaverEventBase;
-        ev.state = state;
-        ev.timestamp = currentTime.milliseconds;
-        ev.root = pScreen->root->drawable.id;
-        ev.window = pScreen->screensaver.wid;
-        ev.kind = kind;
-        ev.forced = forced;
-        WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+        if (pEv->mask & mask) {
+            xScreenSaverNotifyEvent ev = {
+                .type = ScreenSaverNotify + ScreenSaverEventBase,
+                .state = state,
+                .timestamp = currentTime.milliseconds,
+                .root = pScreen->root->drawable.id,
+                .window = pScreen->screensaver.wid,
+                .kind = kind,
+                .forced = forced
+            };
+            WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+        }
     }
 }
 
diff --git a/Xext/security.c b/Xext/security.c
index 4144d85..50041de 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -192,10 +192,10 @@ SecurityDeleteAuthorization(pointer value, XID id)
 
     while ((pEventClient = pAuth->eventClients)) {
         /* send revocation event event */
-        xSecurityAuthorizationRevokedEvent are;
-
-        are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
-        are.authId = pAuth->id;
+        xSecurityAuthorizationRevokedEvent are = {
+            .type = SecurityEventBase + XSecurityAuthorizationRevoked,
+            .authId = pAuth->id
+        };
         WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are);
         FreeResource(pEventClient->resource, RT_NONE);
     }
diff --git a/Xext/shape.c b/Xext/shape.c
index ecc6c88..68cbef2 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -826,7 +826,6 @@ void
 SendShapeNotify(WindowPtr pWin, int which)
 {
     ShapeEventPtr *pHead, pShapeEvent;
-    xShapeNotifyEvent se;
     BoxRec extents;
     RegionPtr region;
     BYTE shaped;
@@ -883,15 +882,17 @@ SendShapeNotify(WindowPtr pWin, int which)
         return;
     }
     for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
-        se.type = ShapeNotify + ShapeEventBase;
-        se.kind = which;
-        se.window = pWin->drawable.id;
-        se.x = extents.x1;
-        se.y = extents.y1;
-        se.width = extents.x2 - extents.x1;
-        se.height = extents.y2 - extents.y1;
-        se.time = currentTime.milliseconds;
-        se.shaped = shaped;
+        xShapeNotifyEvent se = {
+            .type = ShapeNotify + ShapeEventBase,
+            .kind = which,
+            .window = pWin->drawable.id,
+            .x = extents.x1,
+            .y = extents.y1,
+            .width = extents.x2 - extents.x1,
+            .height = extents.y2 - extents.y1,
+            .time = currentTime.milliseconds,
+            .shaped = shaped
+        };
         WriteEventsToClient(pShapeEvent->client, 1, (xEvent *) &se);
     }
 }
diff --git a/Xext/shm.c b/Xext/shm.c
index 6c9b16d..be10a49 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -595,14 +595,14 @@ ProcShmPutImage(ClientPtr client)
                       stuff->dstX, stuff->dstY, shmdesc->addr + stuff->offset);
 
     if (stuff->sendEvent) {
-        xShmCompletionEvent ev;
-
-        ev.type = ShmCompletionCode;
-        ev.drawable = stuff->drawable;
-        ev.minorEvent = X_ShmPutImage;
-        ev.majorEvent = ShmReqCode;
-        ev.shmseg = stuff->shmseg;
-        ev.offset = stuff->offset;
+        xShmCompletionEvent ev = {
+            .type = ShmCompletionCode,
+            .drawable = stuff->drawable,
+            .minorEvent = X_ShmPutImage,
+            .majorEvent = ShmReqCode,
+            .shmseg = stuff->shmseg,
+            .offset = stuff->offset
+        };
         WriteEventsToClient(client, 1, (xEvent *) &ev);
     }
 
diff --git a/Xext/sync.c b/Xext/sync.c
index 3ad2b1b..b203c5e 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -437,9 +437,16 @@ SyncSendAlarmNotifyEvents(SyncAlarm * pAlarm)
 
     UpdateCurrentTime();
 
-    ane.type = SyncEventBase + XSyncAlarmNotify;
-    ane.kind = XSyncAlarmNotify;
-    ane.alarm = pAlarm->alarm_id;
+    ane = (xSyncAlarmNotifyEvent) {
+        .type = SyncEventBase + XSyncAlarmNotify,
+        .kind = XSyncAlarmNotify,
+        .alarm = pAlarm->alarm_id,
+        .alarm_value_hi = XSyncValueHigh32(pTrigger->test_value),
+        .alarm_value_lo = XSyncValueLow32(pTrigger->test_value),
+        .time = currentTime.milliseconds,
+        .state = pAlarm->state
+    };
+
     if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type) {
         ane.counter_value_hi = XSyncValueHigh32(pCounter->value);
         ane.counter_value_lo = XSyncValueLow32(pCounter->value);
@@ -449,11 +456,6 @@ SyncSendAlarmNotifyEvents(SyncAlarm * pAlarm)
         ane.counter_value_hi = ane.counter_value_lo = 0;
     }
 
-    ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
-    ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
-    ane.time = currentTime.milliseconds;
-    ane.state = pAlarm->state;
-
     /* send to owner */
     if (pAlarm->events)
         WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index dae9772..31b7783 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1029,14 +1029,14 @@ ProcXvShmPutImage(ClientPtr client)
                           stuff->send_event, stuff->width, stuff->height);
 
     if ((status == Success) && stuff->send_event) {
-        xShmCompletionEvent ev;
-
-        ev.type = ShmCompletionCode;
-        ev.drawable = stuff->drawable;
-        ev.minorEvent = xv_ShmPutImage;
-        ev.majorEvent = XvReqCode;
-        ev.shmseg = stuff->shmseg;
-        ev.offset = stuff->offset;
+        xShmCompletionEvent ev = {
+            .type = ShmCompletionCode,
+            .drawable = stuff->drawable,
+            .minorEvent = xv_ShmPutImage,
+            .majorEvent = XvReqCode,
+            .shmseg = stuff->shmseg,
+            .offset = stuff->offset
+        };
         WriteEventsToClient(client, 1, (xEvent *) &ev);
     }
 
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 736114b..74872fc 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -507,19 +507,20 @@ XvdiDestroyEncoding(pointer value, XID id)
 static int
 XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
 {
-    xvEvent event;
     XvVideoNotifyPtr pn;
 
     dixLookupResourceByType((pointer *) &pn, pDraw->id, XvRTVideoNotifyList,
                             serverClient, DixReadAccess);
 
     while (pn) {
+        xvEvent event = {
+            .u.videoNotify.reason = reason,
+            .u.videoNotify.time = currentTime.milliseconds,
+            .u.videoNotify.drawable = pDraw->id,
+            .u.videoNotify.port = pPort->id
+        };
         event.u.u.type = XvEventBase + XvVideoNotify;
-        event.u.videoNotify.time = currentTime.milliseconds;
-        event.u.videoNotify.drawable = pDraw->id;
-        event.u.videoNotify.port = pPort->id;
-        event.u.videoNotify.reason = reason;
-        WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
+        WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
         pn = pn->next;
     }
 
@@ -530,18 +531,19 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
 int
 XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value)
 {
-    xvEvent event;
     XvPortNotifyPtr pn;
 
     pn = pPort->pNotify;
 
     while (pn) {
+        xvEvent event = {
+            .u.portNotify.time = currentTime.milliseconds,
+            .u.portNotify.port = pPort->id,
+            .u.portNotify.attribute = attribute,
+            .u.portNotify.value = value
+        };
         event.u.u.type = XvEventBase + XvPortNotify;
-        event.u.portNotify.time = currentTime.milliseconds;
-        event.u.portNotify.port = pPort->id;
-        event.u.portNotify.attribute = attribute;
-        event.u.portNotify.value = value;
-        WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
+        WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
         pn = pn->next;
     }
 
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index caef0bf..9fe69a5 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -113,7 +113,6 @@ ProcXChangeDeviceControl(ClientPtr client)
     AxisInfoPtr a;
     CARD32 *resolution;
     xDeviceEnableCtl *e;
-    devicePresenceNotify dpn;
 
     REQUEST(xChangeDeviceControlReq);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
@@ -211,11 +210,13 @@ ProcXChangeDeviceControl(ClientPtr client)
 
  out:
     if (ret == Success) {
-        dpn.type = DevicePresenceNotify;
-        dpn.time = currentTime.milliseconds;
-        dpn.devchange = DeviceControlChanged;
-        dpn.deviceid = dev->id;
-        dpn.control = stuff->control;
+        devicePresenceNotify dpn = {
+            .type = DevicePresenceNotify,
+            .time = currentTime.milliseconds,
+            .devchange = DeviceControlChanged,
+            .deviceid = dev->id,
+            .control = stuff->control
+        };
         SendEventToAllWindows(dev, DevicePresenceNotifyMask,
                               (xEvent *) &dpn, 1);
 
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index 0f0e975..8b4ae69 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -137,13 +137,14 @@ ProcXGrabDeviceButton(ClientPtr client)
                                   X_GrabDeviceButton)) != Success)
         return ret;
 
-    memset(&param, 0, sizeof(param));
-    param.grabtype = XI;
-    param.ownerEvents = stuff->ownerEvents;
-    param.this_device_mode = stuff->this_device_mode;
-    param.other_devices_mode = stuff->other_devices_mode;
-    param.grabWindow = stuff->grabWindow;
-    param.modifiers = stuff->modifiers;
+    param = (GrabParameters) {
+        .grabtype = XI,
+        .ownerEvents = stuff->ownerEvents,
+        .this_device_mode = stuff->this_device_mode,
+        .other_devices_mode = stuff->other_devices_mode,
+        .grabWindow = stuff->grabWindow,
+        .modifiers = stuff->modifiers
+    };
     mask.xi = tmp[stuff->grabbed_device].mask;
 
     ret = GrabButton(client, dev, mdev, stuff->button, &param, XI, &mask);
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index b755182..8694f9e 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -135,13 +135,14 @@ ProcXGrabDeviceKey(ClientPtr client)
                                   X_GrabDeviceKey)) != Success)
         return ret;
 
-    memset(&param, 0, sizeof(param));
-    param.grabtype = XI;
-    param.ownerEvents = stuff->ownerEvents;
-    param.this_device_mode = stuff->this_device_mode;
-    param.other_devices_mode = stuff->other_devices_mode;
-    param.grabWindow = stuff->grabWindow;
-    param.modifiers = stuff->modifiers;
+    param = (GrabParameters) {
+        .grabtype = XI,
+        .ownerEvents = stuff->ownerEvents,
+        .this_device_mode = stuff->this_device_mode,
+        .other_devices_mode = stuff->other_devices_mode,
+        .grabWindow = stuff->grabWindow,
+        .modifiers = stuff->modifiers
+    };
     mask.xi = tmp[stuff->grabbed_device].mask;
 
     ret = GrabKey(client, dev, mdev, stuff->key, &param, XI, &mask);
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 51a36d4..ca73104 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -182,30 +182,27 @@ static long XIPropHandlerID = 1;
 static void
 send_property_event(DeviceIntPtr dev, Atom property, int what)
 {
-    devicePropertyNotify event;
-    xXIPropertyEvent xi2;
-    int state;
-
-    if (what == XIPropertyDeleted)
-        state = PropertyDelete;
-    else
-        state = PropertyNewValue;
+    int state = (what == XIPropertyDeleted) ? PropertyDelete : PropertyNewValue;
+    devicePropertyNotify event = {
+        .type = DevicePropertyNotify,
+        .deviceid = dev->id,
+        .state = state,
+        .atom = property,
+        .time = currentTime.milliseconds
+    };
+    xXIPropertyEvent xi2 = {
+        .type = GenericEvent,
+        .extension = IReqCode,
+        .length = 0,
+        .evtype = XI_PropertyEvent,
+        .deviceid = dev->id,
+        .time = currentTime.milliseconds,
+        .property = property,
+        .what = what
+    };
 
-    event.type = DevicePropertyNotify;
-    event.deviceid = dev->id;
-    event.state = state;
-    event.atom = property;
-    event.time = currentTime.milliseconds;
     SendEventToAllWindows(dev, DevicePropertyNotifyMask, (xEvent *) &event, 1);
 
-    xi2.type = GenericEvent;
-    xi2.extension = IReqCode;
-    xi2.length = 0;
-    xi2.evtype = XI_PropertyEvent;
-    xi2.deviceid = dev->id;
-    xi2.time = currentTime.milliseconds;
-    xi2.property = property;
-    xi2.what = what;
     SendEventToAllWindows(dev, GetEventFilter(dev, (xEvent *) &xi2),
                           (xEvent *) &xi2, 1);
 }
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 2eddfb3..222643c 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -46,15 +46,17 @@ DamageExtNotify(DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
     int i;
 
     UpdateCurrentTimeIf();
-    ev.type = DamageEventBase + XDamageNotify;
-    ev.level = pDamageExt->level;
-    ev.drawable = pDamageExt->drawable;
-    ev.damage = pDamageExt->id;
-    ev.timestamp = currentTime.milliseconds;
-    ev.geometry.x = pDrawable->x;
-    ev.geometry.y = pDrawable->y;
-    ev.geometry.width = pDrawable->width;
-    ev.geometry.height = pDrawable->height;
+    ev = (xDamageNotifyEvent) {
+        .type = DamageEventBase + XDamageNotify,
+        .level = pDamageExt->level,
+        .drawable = pDamageExt->drawable,
+        .damage = pDamageExt->id,
+        .timestamp = currentTime.milliseconds,
+        .geometry.x = pDrawable->x,
+        .geometry.y = pDrawable->y,
+        .geometry.width = pDrawable->width,
+        .geometry.height = pDrawable->height
+    };
     if (pBoxes) {
         for (i = 0; i < nBoxes; i++) {
             ev.level = pDamageExt->level;
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 7b76c3a..3892d69 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -168,12 +168,13 @@ __glXdriSwapEvent(ClientPtr client, void *data, int type, CARD64 ust,
                   CARD64 msc, CARD32 sbc)
 {
     __GLXdrawable *drawable = data;
-    xGLXBufferSwapComplete2 wire;
+    xGLXBufferSwapComplete2 wire =  {
+        .type = __glXEventBase + GLX_BufferSwapComplete
+    };
 
     if (!(drawable->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
         return;
 
-    wire.type = __glXEventBase + GLX_BufferSwapComplete;
     switch (type) {
     case DRI2_EXCHANGE_COMPLETE:
         wire.event_type = GLX_EXCHANGE_COMPLETE_INTEL;
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 6416372..3bbe357 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -891,15 +891,16 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
     if (!pScreenPriv || !pScreenPriv->grabKeyboard)     /* no direct mode */
         return FALSE;
 
-    memset(&event, 0, sizeof(event));
-    event.header = ET_Internal;
-    event.type = ET_DGAEvent;
-    event.length = sizeof(event);
-    event.time = GetTimeInMillis();
-    event.subtype = (is_down ? ET_KeyPress : ET_KeyRelease);
-    event.detail = key_code;
-    event.dx = 0;
-    event.dy = 0;
+    event = (DGAEvent) {
+        .header = ET_Internal,
+        .type = ET_DGAEvent,
+        .length = sizeof(event),
+        .time = GetTimeInMillis(),
+        .subtype = (is_down ? ET_KeyPress : ET_KeyRelease),
+        .detail = key_code,
+        .dx = 0,
+        .dy = 0
+    };
     mieqEnqueue(dev, (InternalEvent *) &event);
 
     return TRUE;
@@ -919,15 +920,16 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
     if (!pScreenPriv || !pScreenPriv->grabMouse)        /* no direct mode */
         return FALSE;
 
-    memset(&event, 0, sizeof(event));
-    event.header = ET_Internal;
-    event.type = ET_DGAEvent;
-    event.length = sizeof(event);
-    event.time = GetTimeInMillis();
-    event.subtype = ET_Motion;
-    event.detail = 0;
-    event.dx = dx;
-    event.dy = dy;
+    event = (DGAEvent) {
+        .header = ET_Internal,
+        .type = ET_DGAEvent,
+        .length = sizeof(event),
+        .time = GetTimeInMillis(),
+        .subtype = ET_Motion,
+        .detail = 0,
+        .dx = dx,
+        .dy = dy
+    };
     mieqEnqueue(dev, (InternalEvent *) &event);
     return TRUE;
 }
@@ -946,15 +948,16 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
     if (!pScreenPriv || !pScreenPriv->grabMouse)
         return FALSE;
 
-    memset(&event, 0, sizeof(event));
-    event.header = ET_Internal;
-    event.type = ET_DGAEvent;
-    event.length = sizeof(event);
-    event.time = GetTimeInMillis();
-    event.subtype = (is_down ? ET_ButtonPress : ET_ButtonRelease);
-    event.detail = button;
-    event.dx = 0;
-    event.dy = 0;
+    event = (DGAEvent) {
+        .header = ET_Internal,
+        .type = ET_DGAEvent,
+        .length = sizeof(event),
+        .time = GetTimeInMillis(),
+        .subtype = (is_down ? ET_ButtonPress : ET_ButtonRelease),
+        .detail = button,
+        .dx = 0,
+        .dy = 0
+    };
     mieqEnqueue(dev, (InternalEvent *) &event);
 
     return TRUE;
@@ -979,16 +982,15 @@ DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
     KeyClassPtr keyc = keybd->key;
     DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
     DeviceIntPtr pointer = GetMaster(keybd, POINTER_OR_FLOAT);
-    DeviceEvent ev;
-
-    memset(&ev, 0, sizeof(ev));
-    ev.header = ET_Internal;
-    ev.length = sizeof(ev);
-    ev.detail.key = event->detail;
-    ev.type = event->subtype;
-    ev.root_x = 0;
-    ev.root_y = 0;
-    ev.corestate = XkbStateFieldFromRec(&keyc->xkbInfo->state);
+    DeviceEvent ev = {
+        .header = ET_Internal,
+        .length = sizeof(ev),
+        .detail.key = event->detail,
+        .type = event->subtype,
+        .root_x = 0,
+        .root_y = 0,
+        .corestate = XkbStateFieldFromRec(&keyc->xkbInfo->state)
+    };
     ev.corestate |= pointer->button->state;
 
     UpdateDeviceState(keybd, &ev);
@@ -997,15 +999,15 @@ DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
      * Deliver the DGA event
      */
     if (pScreenPriv->client) {
-        dgaEvent de;
-
+        dgaEvent de = {
+            .u.event.time = event->time,
+            .u.event.dx = event->dx,
+            .u.event.dy = event->dy,
+            .u.event.screen = pScreen->myNum,
+            .u.event.state = ev.corestate
+        };
         de.u.u.type = *XDGAEventBase + GetCoreType(ev.type);
         de.u.u.detail = event->detail;
-        de.u.event.time = event->time;
-        de.u.event.dx = event->dx;
-        de.u.event.dy = event->dy;
-        de.u.event.screen = pScreen->myNum;
-        de.u.event.state = ev.corestate;
 
         /* If the DGA client has selected input, then deliver based on the usual filter */
         TryClientEvents(pScreenPriv->client, keybd, (xEvent *) &de, 1,
@@ -1030,14 +1032,14 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
 {
     ButtonClassPtr butc = mouse->button;
     DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-    DeviceEvent ev;
     DeviceIntPtr master = GetMaster(mouse, MASTER_KEYBOARD);
+    DeviceEvent ev = {
+        .header = ET_Internal,
+        .length = sizeof(ev),
+        .type = event->subtype,
+        .corestate = butc ? butc->state : 0
+    };
 
-    memset(&ev, 0, sizeof(ev));
-    ev.header = ET_Internal;
-    ev.length = sizeof(ev);
-    ev.type = event->subtype;
-    ev.corestate = butc ? butc->state : 0;
     if (master && master->key)
         ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state);
 
@@ -1047,18 +1049,16 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
      * Deliver the DGA event
      */
     if (pScreenPriv->client) {
-        dgaEvent de;
-        int coreEquiv;
-
-        coreEquiv = GetCoreType(ev.type);
-
+        int coreEquiv = GetCoreType(ev.type);
+        dgaEvent de = {
+            .u.event.time = event->time,
+            .u.event.dx = event->dx,
+            .u.event.dy = event->dy,
+            .u.event.screen = pScreen->myNum,
+            .u.event.state = ev.corestate
+        };
         de.u.u.type = *XDGAEventBase + coreEquiv;
         de.u.u.detail = event->detail;
-        de.u.event.time = event->time;
-        de.u.event.dx = event->dx;
-        de.u.event.dy = event->dy;
-        de.u.event.screen = pScreen->myNum;
-        de.u.event.state = ev.corestate;
 
         /* If the DGA client has selected input, then deliver based on the usual filter */
         TryClientEvents(pScreenPriv->client, mouse, (xEvent *) &de, 1,
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 455ff34..3d66852 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -240,7 +240,6 @@ static void
 SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
 {
     XF86VidModeScreenPrivatePtr pPriv;
-    XF86VidModeEventPtr pEv;
     unsigned long mask;
     xXF86VidModeNotifyEvent ev;
     int kind;
@@ -253,15 +252,17 @@ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
         return;
     kind = XF86VidModeModeChange;
     for (pEv = pPriv->events; pEv; pEv = pEv->next) {
-        if (!(pEv->mask & mask))
-            continue;
-        ev.type = XF86VidModeNotify + XF86VidModeEventBase;
-        ev.state = state;
-        ev.timestamp = currentTime.milliseconds;
-        ev.root = pScreen->root->drawable.id;
-        ev.kind = kind;
-        ev.forced = forced;
-        WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+        if (pEv->mask & mask) {
+            XF86VidModeEventPtr pEv = {
+                .type = XF86VidModeNotify + XF86VidModeEventBase,
+                .state = state,
+                .timestamp = currentTime.milliseconds,
+                .root = pScreen->root->drawable.id,
+                .kind = kind,
+                .forced = forced
+            };
+            WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+        }
     }
 }
 
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 349686c..b73a45f 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -161,11 +161,11 @@ ProcDRI2Authenticate(ClientPtr client)
 static void
 DRI2InvalidateBuffersEvent(DrawablePtr pDraw, void *priv, XID id)
 {
-    xDRI2InvalidateBuffers event;
     ClientPtr client = priv;
-
-    event.type = DRI2EventBase + DRI2_InvalidateBuffers;
-    event.drawable = id;
+    xDRI2InvalidateBuffers event = {
+        .type = DRI2EventBase + DRI2_InvalidateBuffers,
+        .drawable = id
+    };
 
     WriteEventsToClient(client, 1, (xEvent *) &event);
 }
@@ -363,17 +363,17 @@ static void
 DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc,
               CARD32 sbc)
 {
-    xDRI2BufferSwapComplete2 event;
     DrawablePtr pDrawable = data;
-
-    event.type = DRI2EventBase + DRI2_BufferSwapComplete;
-    event.event_type = type;
-    event.drawable = pDrawable->id;
-    event.ust_hi = (CARD64) ust >> 32;
-    event.ust_lo = ust & 0xffffffff;
-    event.msc_hi = (CARD64) msc >> 32;
-    event.msc_lo = msc & 0xffffffff;
-    event.sbc = sbc;
+    xDRI2BufferSwapComplete2 event = {
+        .type = DRI2EventBase + DRI2_BufferSwapComplete,
+        .event_type = type,
+        .drawable = pDrawable->id,
+        .ust_hi = (CARD64) ust >> 32,
+        .ust_lo = ust & 0xffffffff,
+        .msc_hi = (CARD64) msc >> 32,
+        .msc_lo = msc & 0xffffffff,
+        .sbc = sbc
+    };
 
     WriteEventsToClient(client, 1, (xEvent *) &event);
 }
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index aa9b44f..36692ce 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -236,29 +236,21 @@ RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
     rrScrPriv(pScreen);
-    xRRCrtcChangeNotifyEvent ce;
     RRModePtr mode = crtc->mode;
 
-    ce.type = RRNotify + RREventBase;
-    ce.subCode = RRNotify_CrtcChange;
-    ce.timestamp = pScrPriv->lastSetTime.milliseconds;
-    ce.window = pWin->drawable.id;
-    ce.crtc = crtc->id;
-    ce.rotation = crtc->rotation;
-    if (mode) {
-        ce.mode = mode->mode.id;
-        ce.x = crtc->x;
-        ce.y = crtc->y;
-        ce.width = mode->mode.width;
-        ce.height = mode->mode.height;
-    }
-    else {
-        ce.mode = None;
-        ce.x = 0;
-        ce.y = 0;
-        ce.width = 0;
-        ce.height = 0;
-    }
+    xRRCrtcChangeNotifyEvent ce = {
+        .type = RRNotify + RREventBase,
+        .subCode = RRNotify_CrtcChange,
+        .timestamp = pScrPriv->lastSetTime.milliseconds,
+        .window = pWin->drawable.id,
+        .crtc = crtc->id,
+        .mode = mode ? mode->mode.id : None,
+        .rotation = crtc->rotation,
+        .x = mode ? crtc->x : 0,
+        .y = mode ? crtc->y : 0,
+        .width = mode ? mode->mode.width : 0,
+        .height = mode ? mode->mode.height : 0
+    };
     WriteEventsToClient(client, 1, (xEvent *) &ce);
 }
 
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 0932508..88781ba 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -305,28 +305,22 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output)
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
     rrScrPriv(pScreen);
-    xRROutputChangeNotifyEvent oe;
     RRCrtcPtr crtc = output->crtc;
-    RRModePtr mode = crtc ? crtc->mode : 0;
-
-    oe.type = RRNotify + RREventBase;
-    oe.subCode = RRNotify_OutputChange;
-    oe.timestamp = pScrPriv->lastSetTime.milliseconds;
-    oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
-    oe.window = pWin->drawable.id;
-    oe.output = output->id;
-    if (crtc) {
-        oe.crtc = crtc->id;
-        oe.mode = mode ? mode->mode.id : None;
-        oe.rotation = crtc->rotation;
-    }
-    else {
-        oe.crtc = None;
-        oe.mode = None;
-        oe.rotation = RR_Rotate_0;
-    }
-    oe.connection = output->connection;
-    oe.subpixelOrder = output->subpixelOrder;
+    RRModePtr mode = crtc ? crtc->mode : NULL;
+
+    xRROutputChangeNotifyEvent oe = {
+        .type = RRNotify + RREventBase,
+        .subCode = RRNotify_OutputChange,
+        .timestamp = pScrPriv->lastSetTime.milliseconds,
+        .configTimestamp = pScrPriv->lastConfigTime.milliseconds,
+        .window = pWin->drawable.id,
+        .output = output->id,
+        .crtc = crtc ? crtc->id : None,
+        .mode = mode ? mode->mode.id : None,
+        .rotation = crtc ? crtc->rotation : RR_Rotate_0,
+        .connection = output->connection,
+        .subpixelOrder = output->subpixelOrder
+    };
     WriteEventsToClient(client, 1, (xEvent *) &oe);
 }
 
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 7ce085c..7f09092 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -65,14 +65,14 @@ RRDestroyOutputProperty(RRPropertyPtr prop)
 static void
 RRDeleteProperty(RROutputRec * output, RRPropertyRec * prop)
 {
-    xRROutputPropertyNotifyEvent event;
-
-    event.type = RREventBase + RRNotify;
-    event.subCode = RRNotify_OutputProperty;
-    event.output = output->id;
-    event.state = PropertyDelete;
-    event.atom = prop->propertyName;
-    event.timestamp = currentTime.milliseconds;
+    xRROutputPropertyNotifyEvent event = {
+        .type = RREventBase + RRNotify,
+        .subCode = RRNotify_OutputProperty,
+        .output = output->id,
+        .state = PropertyDelete,
+        .atom = prop->propertyName,
+        .timestamp = currentTime.milliseconds
+    };
 
     RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event);
 
@@ -138,7 +138,6 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
                        pointer value, Bool sendevent, Bool pending)
 {
     RRPropertyPtr prop;
-    xRROutputPropertyNotifyEvent event;
     rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen);
     int size_in_bytes;
     int total_size;
@@ -237,12 +236,14 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
         output->pendingProperties = TRUE;
 
     if (sendevent) {
-        event.type = RREventBase + RRNotify;
-        event.subCode = RRNotify_OutputProperty;
-        event.output = output->id;
-        event.state = PropertyNewValue;
-        event.atom = prop->propertyName;
-        event.timestamp = currentTime.milliseconds;
+        xRROutputPropertyNotifyEvent event = {
+            .type = RREventBase + RRNotify,
+            .subCode = RRNotify_OutputProperty,
+            .output = output->id,
+            .state = PropertyNewValue,
+            .atom = prop->propertyName,
+            .timestamp = currentTime.milliseconds
+        };
         RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event);
     }
     return Success;
@@ -682,14 +683,14 @@ ProcRRGetOutputProperty(ClientPtr client)
     reply.propertyType = prop_value->type;
 
     if (stuff->delete && (reply.bytesAfter == 0)) {
-        xRROutputPropertyNotifyEvent event;
-
-        event.type = RREventBase + RRNotify;
-        event.subCode = RRNotify_OutputProperty;
-        event.output = output->id;
-        event.state = PropertyDelete;
-        event.atom = prop->propertyName;
-        event.timestamp = currentTime.milliseconds;
+        xRROutputPropertyNotifyEvent event = {
+            .type = RREventBase + RRNotify,
+            .subCode = RRNotify_OutputProperty,
+            .output = output->id,
+            .state = PropertyDelete,
+            .atom = prop->propertyName,
+            .timestamp = currentTime.milliseconds
+        };
         RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event);
     }
 
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index da6a207..94505b4 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -71,20 +71,20 @@ void
 RRSendConfigNotify(ScreenPtr pScreen)
 {
     WindowPtr pWin = pScreen->root;
-    xEvent event;
-
-    event.u.u.type = ConfigureNotify;
-    event.u.configureNotify.window = pWin->drawable.id;
-    event.u.configureNotify.aboveSibling = None;
-    event.u.configureNotify.x = 0;
-    event.u.configureNotify.y = 0;
+    xEvent event = {
+        .u.configureNotify.window = pWin->drawable.id,
+        .u.configureNotify.aboveSibling = None,
+        .u.configureNotify.x = 0,
+        .u.configureNotify.y = 0,
 
     /* XXX xinerama stuff ? */
 
-    event.u.configureNotify.width = pWin->drawable.width;
-    event.u.configureNotify.height = pWin->drawable.height;
-    event.u.configureNotify.borderWidth = wBorderWidth(pWin);
-    event.u.configureNotify.override = pWin->overrideRedirect;
+        .u.configureNotify.width = pWin->drawable.width,
+        .u.configureNotify.height = pWin->drawable.height,
+        .u.configureNotify.borderWidth = wBorderWidth(pWin),
+        .u.configureNotify.override = pWin->overrideRedirect
+    };
+    event.u.u.type = ConfigureNotify;
     DeliverEvents(pWin, &event, 1, NullWindow);
 }
 
@@ -92,19 +92,20 @@ void
 RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
 {
     rrScrPriv(pScreen);
-    xRRScreenChangeNotifyEvent se;
     RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
     WindowPtr pRoot = pScreen->root;
 
-    se.type = RRScreenChangeNotify + RREventBase;
-    se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
-    se.timestamp = pScrPriv->lastSetTime.milliseconds;
-    se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
-    se.root = pRoot->drawable.id;
-    se.window = pWin->drawable.id;
-    se.subpixelOrder = PictureGetSubpixelOrder(pScreen);
+    xRRScreenChangeNotifyEvent se = {
+        .type = RRScreenChangeNotify + RREventBase,
+        .rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0),
+        .timestamp = pScrPriv->lastSetTime.milliseconds,
+        .configTimestamp = pScrPriv->lastConfigTime.milliseconds,
+        .root = pRoot->drawable.id,
+        .window = pWin->drawable.id,
+        .subpixelOrder = PictureGetSubpixelOrder(pScreen),
 
-    se.sizeID = RR10CurrentSizeID(pScreen);
+        .sizeID = RR10CurrentSizeID(pScreen)
+    };
 
     if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
         se.widthInPixels = pScreen->height;
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 68f7b74..4eee592 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -172,14 +172,14 @@ CursorDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
         CursorCurrent[pDev->id] = pCursor;
         for (e = cursorEvents; e; e = e->next) {
             if ((e->eventMask & XFixesDisplayCursorNotifyMask)) {
-                xXFixesCursorNotifyEvent ev;
-
-                ev.type = XFixesEventBase + XFixesCursorNotify;
-                ev.subtype = XFixesDisplayCursorNotify;
-                ev.window = e->pWindow->drawable.id;
-                ev.cursorSerial = pCursor ? pCursor->serialNumber : 0;
-                ev.timestamp = currentTime.milliseconds;
-                ev.name = pCursor ? pCursor->name : None;
+                xXFixesCursorNotifyEvent ev = {
+                    .type = XFixesEventBase + XFixesCursorNotify,
+                    .subtype = XFixesDisplayCursorNotify,
+                    .window = e->pWindow->drawable.id,
+                    .cursorSerial = pCursor ? pCursor->serialNumber : 0,
+                    .timestamp = currentTime.milliseconds,
+                    .name = pCursor ? pCursor->name : None
+                };
                 WriteEventsToClient(e->pClient, 1, (xEvent *) &ev);
             }
         }
diff --git a/xfixes/select.c b/xfixes/select.c
index a896846..ee8ed6f 100644
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -77,19 +77,16 @@ XFixesSelectionCallback(CallbackListPtr *callbacks, pointer data, pointer args)
     }
     for (e = selectionEvents; e; e = e->next) {
         if (e->selection == selection->selection && (e->eventMask & eventMask)) {
-            xXFixesSelectionNotifyEvent ev;
-
-            memset(&ev, 0, sizeof(xXFixesSelectionNotifyEvent));
-            ev.type = XFixesEventBase + XFixesSelectionNotify;
-            ev.subtype = subtype;
-            ev.window = e->pWindow->drawable.id;
-            if (subtype == XFixesSetSelectionOwnerNotify)
-                ev.owner = selection->window;
-            else
-                ev.owner = 0;
-            ev.selection = e->selection;
-            ev.timestamp = currentTime.milliseconds;
-            ev.selectionTimestamp = selection->lastTimeChanged.milliseconds;
+            xXFixesSelectionNotifyEvent ev = {
+                .type = XFixesEventBase + XFixesSelectionNotify,
+                .subtype = subtype,
+                .window = e->pWindow->drawable.id,
+                .owner = (subtype == XFixesSetSelectionOwnerNotify) ?
+                            selection->window : 0,
+                .selection = e->selection,
+                .timestamp = currentTime.milliseconds,
+                .selectionTimestamp = selection->lastTimeChanged.milliseconds
+            };
             WriteEventsToClient(e->pClient, 1, (xEvent *) &ev);
         }
     }
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index beb09cf..87a4485 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -59,8 +59,6 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
     int i;
     int keymap_changed = 0;
     int modmap_changed = 0;
-    xEvent core_mn;
-    deviceMappingNotify xi_mn;
     CARD32 time = GetTimeInMillis();
 
     if (xkb_event == XkbNewKeyboardNotify) {
@@ -78,11 +76,6 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
     if (!keymap_changed && !modmap_changed)
         return;
 
-    core_mn.u.u.type = MappingNotify;
-    xi_mn.type = DeviceMappingNotify;
-    xi_mn.deviceid = kbd->id;
-    xi_mn.time = time;
-
     /* 0 is serverClient. */
     for (i = 1; i < currentMaxClients; i++) {
         if (!clients[i] || clients[i]->clientState != ClientStateRunning)
@@ -106,6 +99,7 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
             continue;
 
         if (keymap_changed) {
+            xEvent core_mn = { .u.u.type = MappingNotify };
             core_mn.u.mappingNotify.request = MappingKeyboard;
 
             /* Clip the keycode range to what the client knows about, so it
@@ -123,9 +117,12 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
             WriteEventsToClient(clients[i], 1, &core_mn);
         }
         if (modmap_changed) {
-            core_mn.u.mappingNotify.request = MappingModifier;
-            core_mn.u.mappingNotify.firstKeyCode = 0;
-            core_mn.u.mappingNotify.count = 0;
+            xEvent core_mn = {
+                .u.mappingNotify.request = MappingModifier,
+                .u.mappingNotify.firstKeyCode = 0,
+                .u.mappingNotify.count = 0
+            };
+            core_mn.u.u.type = MappingNotify;
             WriteEventsToClient(clients[i], 1, &core_mn);
         }
     }
@@ -134,16 +131,26 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
      * here? Clients might be upset, but that seems better than the
      * alternative of stale keymaps. -ds */
     if (keymap_changed) {
-        xi_mn.request = MappingKeyboard;
-        xi_mn.firstKeyCode = first_key;
-        xi_mn.count = num_keys;
+        deviceMappingNotify xi_mn = {
+            .type = DeviceMappingNotify,
+            .deviceid = kbd->id,
+            .request = MappingKeyboard,
+            .firstKeyCode = first_key,
+            .count = num_keys,
+            .time = time
+        };
         SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
                               1);
     }
     if (modmap_changed) {
-        xi_mn.request = MappingModifier;
-        xi_mn.firstKeyCode = 0;
-        xi_mn.count = 0;
+        deviceMappingNotify xi_mn = {
+            .type = DeviceMappingNotify,
+            .deviceid = kbd->id,
+            .request = MappingModifier,
+            .firstKeyCode = 0,
+            .count = 0,
+            .time = time
+        };
         SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
                               1);
     }
-- 
1.7.9.2



More information about the xorg-devel mailing list