[PATCH v2 23/29] Use C99 designated initializers in dix Events

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


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 dix/colormap.c   |   34 +++++-----
 dix/devices.c    |   34 +++++-----
 dix/enterleave.c |   14 ++--
 dix/events.c     |   89 +++++++++++++------------
 dix/inpututils.c |   13 ++--
 dix/property.c   |   13 ++--
 dix/selection.c  |   10 +--
 dix/swapreq.c    |    2 +-
 dix/window.c     |  190 ++++++++++++++++++++++++++----------------------------
 mi/miexpose.c    |   11 ++--
 10 files changed, 204 insertions(+), 206 deletions(-)

diff --git a/dix/colormap.c b/dix/colormap.c
index 36526b8..a43e279 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -450,15 +450,15 @@ FreeColormap(pointer value, XID mid)
 static int
 TellNoMap(WindowPtr pwin, Colormap * pmid)
 {
-    xEvent xE;
-
     if (wColormap(pwin) == *pmid) {
         /* This should be call to DeliverEvent */
+        xEvent xE = {
+            .u.colormap.window = pwin->drawable.id,
+            .u.colormap.colormap = None,
+            .u.colormap.new = TRUE,
+            .u.colormap.state = ColormapUninstalled
+        };
         xE.u.u.type = ColormapNotify;
-        xE.u.colormap.window = pwin->drawable.id;
-        xE.u.colormap.colormap = None;
-        xE.u.colormap.new = TRUE;
-        xE.u.colormap.state = ColormapUninstalled;
 #ifdef PANORAMIX
         if (noPanoramiXExtension || !pwin->drawable.pScreen->myNum)
 #endif
@@ -477,7 +477,6 @@ int
 TellLostMap(WindowPtr pwin, pointer value)
 {
     Colormap *pmid = (Colormap *) value;
-    xEvent xE;
 
 #ifdef PANORAMIX
     if (!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
@@ -485,11 +484,13 @@ TellLostMap(WindowPtr pwin, pointer value)
 #endif
     if (wColormap(pwin) == *pmid) {
         /* This should be call to DeliverEvent */
+        xEvent xE = {
+            .u.colormap.window = pwin->drawable.id,
+            .u.colormap.colormap = *pmid,
+            .u.colormap.new = FALSE,
+            .u.colormap.state = ColormapUninstalled
+        };
         xE.u.u.type = ColormapNotify;
-        xE.u.colormap.window = pwin->drawable.id;
-        xE.u.colormap.colormap = *pmid;
-        xE.u.colormap.new = FALSE;
-        xE.u.colormap.state = ColormapUninstalled;
         DeliverEvents(pwin, &xE, 1, (WindowPtr) NULL);
     }
 
@@ -501,7 +502,6 @@ int
 TellGainedMap(WindowPtr pwin, pointer value)
 {
     Colormap *pmid = (Colormap *) value;
-    xEvent xE;
 
 #ifdef PANORAMIX
     if (!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
@@ -509,11 +509,13 @@ TellGainedMap(WindowPtr pwin, pointer value)
 #endif
     if (wColormap(pwin) == *pmid) {
         /* This should be call to DeliverEvent */
+        xEvent xE = {
+            .u.colormap.window = pwin->drawable.id,
+            .u.colormap.colormap = *pmid,
+            .u.colormap.new = FALSE,
+            .u.colormap.state = ColormapInstalled
+        };
         xE.u.u.type = ColormapNotify;
-        xE.u.colormap.window = pwin->drawable.id;
-        xE.u.colormap.colormap = *pmid;
-        xE.u.colormap.new = FALSE;
-        xE.u.colormap.state = ColormapInstalled;
         DeliverEvents(pwin, &xE, 1, (WindowPtr) NULL);
     }
 
diff --git a/dix/devices.c b/dix/devices.c
index dc99abc..c316d55 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -316,15 +316,14 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
 void
 SendDevicePresenceEvent(int deviceid, int type)
 {
-    DeviceIntRec dummyDev;
-    devicePresenceNotify ev;
-
-    memset(&dummyDev, 0, sizeof(DeviceIntRec));
-    ev.type = DevicePresenceNotify;
-    ev.time = currentTime.milliseconds;
-    ev.devchange = type;
-    ev.deviceid = deviceid;
-    dummyDev.id = XIAllDevices;
+    DeviceIntRec dummyDev = { .id =  XIAllDevices };
+    devicePresenceNotify ev = {
+        .type = DevicePresenceNotify,
+        .time = currentTime.milliseconds,
+        .devchange = type,
+        .deviceid = deviceid
+    };
+
     SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
                           (xEvent *) &ev, 1);
 }
@@ -2444,18 +2443,17 @@ RecalculateMasterButtons(DeviceIntPtr slave)
 
     if (master->button && master->button->numButtons != maxbuttons) {
         int i;
-        DeviceChangedEvent event;
-
-        memset(&event, 0, sizeof(event));
+        DeviceChangedEvent event = {
+            .header = ET_Internal,
+            .type = ET_DeviceChanged,
+            .time = GetTimeInMillis(),
+            .deviceid = master->id,
+            .flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE,
+            .buttons.num_buttons = maxbuttons
+        };
 
         master->button->numButtons = maxbuttons;
 
-        event.header = ET_Internal;
-        event.type = ET_DeviceChanged;
-        event.time = GetTimeInMillis();
-        event.deviceid = master->id;
-        event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE;
-        event.buttons.num_buttons = maxbuttons;
         memcpy(&event.buttons.names, master->button->labels, maxbuttons *
                sizeof(Atom));
 
diff --git a/dix/enterleave.c b/dix/enterleave.c
index 00083e9..431566f 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -827,12 +827,14 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
     free(xi2event);
 
     /* XI 1.x event */
-    event.deviceid = dev->id;
-    event.mode = mode;
-    event.type = (type == XI_FocusIn) ? DeviceFocusIn : DeviceFocusOut;
-    event.detail = detail;
-    event.window = pWin->drawable.id;
-    event.time = currentTime.milliseconds;
+    event = (deviceFocus) {
+        .deviceid = dev->id,
+        .mode = mode,
+        .type = (type == XI_FocusIn) ? DeviceFocusIn : DeviceFocusOut,
+        .detail = detail,
+        .window = pWin->drawable.id,
+        .time = currentTime.milliseconds
+    };
 
     DeliverEventsToWindow(dev, pWin, (xEvent *) &event, 1,
                           DeviceFocusChangeMask, NullGrab);
diff --git a/dix/events.c b/dix/events.c
index 1708710..3b40446 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2834,14 +2834,15 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
     if (win == NoneWin || win == PointerRootWin)
         return FALSE;
 
-    memset(&event, 0, sizeof(DeviceEvent));
-    event.header = ET_Internal;
-    event.type = ET_FocusIn;
-    event.length = sizeof(DeviceEvent);
-    event.time = GetTimeInMillis();
-    event.deviceid = dev->id;
-    event.sourceid = dev->id;
-    event.detail.button = 0;
+    event = (DeviceEvent) {
+        .header = ET_Internal,
+        .type = ET_FocusIn,
+        .length = sizeof(DeviceEvent),
+        .time = GetTimeInMillis(),
+        .deviceid = dev->id,
+        .sourceid = dev->id,
+        .detail.button = 0
+    };
     rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
                                     TRUE) != NULL);
     if (rc)
@@ -2871,14 +2872,15 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
         (*dev->deviceGrab.DeactivateGrab) (dev);
     }
 
-    memset(&event, 0, sizeof(DeviceEvent));
-    event.header = ET_Internal;
-    event.type = ET_Enter;
-    event.length = sizeof(DeviceEvent);
-    event.time = GetTimeInMillis();
-    event.deviceid = dev->id;
-    event.sourceid = dev->id;
-    event.detail.button = 0;
+    event = (DeviceEvent) {
+        .header = ET_Internal,
+        .type = ET_Enter,
+        .length = sizeof(DeviceEvent),
+        .time = GetTimeInMillis(),
+        .deviceid = dev->id,
+        .sourceid = dev->id,
+        .detail.button = 0
+    };
     rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
                                     TRUE) != NULL);
     if (rc)
@@ -4457,7 +4459,10 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
                     int type,
                     int mode, int detail, WindowPtr pWin, Window child)
 {
-    xEvent event;
+    xEvent event = {
+        .u.u.type = type,
+        .u.u.detail = detail
+    };
     WindowPtr focus;
     DeviceIntPtr keybd;
     GrabPtr grab = mouse->deviceGrab.grab;
@@ -4477,9 +4482,6 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
         mask = pWin->eventMask | wOtherEventMasks(pWin);
     }
 
-    memset(&event, 0, sizeof(xEvent));
-    event.u.u.type = type;
-    event.u.u.detail = detail;
     event.u.enterLeave.time = currentTime.milliseconds;
     event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x;
     event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y;
@@ -4510,16 +4512,16 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
     }
 
     if ((type == EnterNotify) && (mask & KeymapStateMask)) {
-        xKeymapEvent ke;
+        xKeymapEvent ke = {
+            .type = KeymapNotify
+        };
         ClientPtr client = grab ? rClient(grab) : wClient(pWin);
         int rc;
 
-        memset((char *) &ke.map[0], 0, 31);
         rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
         if (rc == Success)
             memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
 
-        ke.type = KeymapNotify;
         if (grab)
             TryClientEvents(rClient(grab), keybd, (xEvent *) &ke, 1,
                             mask, KeymapStateMask, grab);
@@ -4604,28 +4606,27 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
 void
 CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
 {
-    xEvent event;
-
-    memset(&event, 0, sizeof(xEvent));
+    xEvent event = {
+        .u.u.type = type,
+        .u.u.detail = detail
+    };
     event.u.focus.mode = mode;
-    event.u.u.type = type;
-    event.u.u.detail = detail;
     event.u.focus.window = pWin->drawable.id;
 
     DeliverEventsToWindow(dev, pWin, &event, 1,
                           GetEventFilter(dev, &event), NullGrab);
     if ((type == FocusIn) &&
         ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) {
-        xKeymapEvent ke;
+        xKeymapEvent ke = {
+            .type = KeymapNotify
+        };
         ClientPtr client = wClient(pWin);
         int rc;
 
-        memset((char *) &ke.map[0], 0, 31);
         rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess);
         if (rc == Success)
             memcpy((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
 
-        ke.type = KeymapNotify;
         DeliverEventsToWindow(dev, pWin, (xEvent *) &ke, 1,
                               KeymapStateMask, NullGrab);
     }
@@ -5429,12 +5430,13 @@ ProcGrabKey(ClientPtr client)
 
     REQUEST_SIZE_MATCH(xGrabKeyReq);
 
-    memset(&param, 0, sizeof(param));
-    param.grabtype = CORE;
-    param.ownerEvents = stuff->ownerEvents;
-    param.this_device_mode = stuff->keyboardMode;
-    param.other_devices_mode = stuff->pointerMode;
-    param.modifiers = stuff->modifiers;
+    param = (GrabParameters) {
+        .grabtype = CORE,
+        .ownerEvents = stuff->ownerEvents,
+        .this_device_mode = stuff->keyboardMode,
+        .other_devices_mode = stuff->pointerMode,
+        .modifiers = stuff->modifiers
+    };
 
     rc = CheckGrabValues(client, &param);
     if (rc != Success)
@@ -5535,12 +5537,13 @@ ProcGrabButton(ClientPtr client)
     if (rc != Success)
         return rc;
 
-    memset(&param, 0, sizeof(param));
-    param.grabtype = CORE;
-    param.ownerEvents = stuff->ownerEvents;
-    param.this_device_mode = stuff->keyboardMode;
-    param.other_devices_mode = stuff->pointerMode;
-    param.modifiers = stuff->modifiers;
+    param = (GrabParameters) {
+        .grabtype = CORE,
+        .ownerEvents = stuff->ownerEvents,
+        .this_device_mode = stuff->keyboardMode,
+        .other_devices_mode = stuff->pointerMode,
+        .modifiers = stuff->modifiers
+    };
 
     mask.core = stuff->eventMask;
 
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 223d547..f01e9a7 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -71,14 +71,13 @@ static void
 do_butmap_change(DeviceIntPtr dev, CARD8 *map, int len, ClientPtr client)
 {
     int i;
-    xEvent core_mn;
+    xEvent core_mn = { .u.u.type = MappingNotify };
     deviceMappingNotify xi_mn;
 
     /* The map in ButtonClassRec refers to button numbers, whereas the
      * protocol is zero-indexed.  Sigh. */
     memcpy(&(dev->button->map[1]), map, len);
 
-    core_mn.u.u.type = MappingNotify;
     core_mn.u.mappingNotify.request = MappingPointer;
 
     /* 0 is the server client. */
@@ -93,10 +92,12 @@ do_butmap_change(DeviceIntPtr dev, CARD8 *map, int len, ClientPtr client)
         WriteEventsToClient(clients[i], 1, &core_mn);
     }
 
-    xi_mn.type = DeviceMappingNotify;
-    xi_mn.request = MappingPointer;
-    xi_mn.deviceid = dev->id;
-    xi_mn.time = GetTimeInMillis();
+    xi_mn = (deviceMappingNotify) {
+        .type = DeviceMappingNotify,
+        .request = MappingPointer,
+        .deviceid = dev->id,
+        .time = GetTimeInMillis()
+    };
 
     SendEventToAllWindows(dev, DeviceMappingNotifyMask, (xEvent *) &xi_mn, 1);
 }
diff --git a/dix/property.c b/dix/property.c
index 5aa6f4a..dec4090 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -108,14 +108,13 @@ dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom propertyName,
 static void
 deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom)
 {
-    xEvent event;
-
-    memset(&event, 0, sizeof(xEvent));
+    xEvent event = {
+        .u.property.window = pWin->drawable.id,
+        .u.property.state = state,
+        .u.property.atom = atom,
+        .u.property.time = currentTime.milliseconds
+    };
     event.u.u.type = PropertyNotify;
-    event.u.property.window = pWin->drawable.id;
-    event.u.property.state = state;
-    event.u.property.atom = atom;
-    event.u.property.time = currentTime.milliseconds;
     DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
 }
 
diff --git a/dix/selection.c b/dix/selection.c
index 80b5893..e905b1e 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -174,8 +174,6 @@ ProcSetSelectionOwner(ClientPtr client)
     rc = dixLookupSelection(&pSel, stuff->selection, client, DixSetAttrAccess);
 
     if (rc == Success) {
-        xEvent event;
-
         /* If the timestamp in client's request is in the past relative
            to the time stamp indicating the last time the owner of the
            selection was set, do not set the selection, just return 
@@ -183,10 +181,12 @@ ProcSetSelectionOwner(ClientPtr client)
         if (CompareTimeStamps(time, pSel->lastTimeChanged) == EARLIER)
             return Success;
         if (pSel->client && (!pWin || (pSel->client != client))) {
+            xEvent event = {
+                .u.selectionClear.time = time.milliseconds,
+                .u.selectionClear.window = pSel->window,
+                .u.selectionClear.atom = pSel->selection
+            };
             event.u.u.type = SelectionClear;
-            event.u.selectionClear.time = time.milliseconds;
-            event.u.selectionClear.window = pSel->window;
-            event.u.selectionClear.atom = pSel->selection;
             WriteEventsToClient(pSel->client, 1, &event);
         }
     }
diff --git a/dix/swapreq.c b/dix/swapreq.c
index a896b4b..0f6d49e 100644
--- a/dix/swapreq.c
+++ b/dix/swapreq.c
@@ -283,7 +283,7 @@ SProcConvertSelection(ClientPtr client)
 int
 SProcSendEvent(ClientPtr client)
 {
-    xEvent eventT;
+    xEvent eventT = { .u.u.type = 0 };
     EventSwapPtr proc;
 
     REQUEST(xSendEventReq);
diff --git a/dix/window.c b/dix/window.c
index 5cc3a50..1af4f43 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -641,7 +641,6 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
     WindowPtr pWin;
     WindowPtr pHead;
     ScreenPtr pScreen;
-    xEvent event;
     int idepth, ivisual;
     Bool fOK;
     DepthPtr pDepth;
@@ -828,16 +827,17 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
     }
 
     if (SubSend(pParent)) {
-        memset(&event, 0, sizeof(xEvent));
+        xEvent event = {
+            .u.createNotify.window = wid,
+            .u.createNotify.parent = pParent->drawable.id,
+            .u.createNotify.x = x,
+            .u.createNotify.y = y,
+            .u.createNotify.width = w,
+            .u.createNotify.height = h,
+            .u.createNotify.borderWidth = bw,
+            .u.createNotify.override = pWin->overrideRedirect
+        };
         event.u.u.type = CreateNotify;
-        event.u.createNotify.window = wid;
-        event.u.createNotify.parent = pParent->drawable.id;
-        event.u.createNotify.x = x;
-        event.u.createNotify.y = y;
-        event.u.createNotify.width = w;
-        event.u.createNotify.height = h;
-        event.u.createNotify.borderWidth = bw;
-        event.u.createNotify.override = pWin->overrideRedirect;
         DeliverEvents(pParent, &event, 1, NullWindow);
     }
     return pWin;
@@ -912,7 +912,6 @@ CrushTree(WindowPtr pWin)
 {
     WindowPtr pChild, pSib, pParent;
     UnrealizeWindowProcPtr UnrealizeWindow;
-    xEvent event;
 
     if (!(pChild = pWin->firstChild))
         return;
@@ -925,8 +924,7 @@ CrushTree(WindowPtr pWin)
         while (1) {
             pParent = pChild->parent;
             if (SubStrSend(pChild, pParent)) {
-                memset(&event, 0, sizeof(xEvent));
-                event.u.u.type = DestroyNotify;
+                xEvent event = { .u.u.type = DestroyNotify };
                 event.u.destroyNotify.window = pChild->drawable.id;
                 DeliverEvents(pChild, &event, 1, NullWindow);
             }
@@ -961,7 +959,6 @@ DeleteWindow(pointer value, XID wid)
 {
     WindowPtr pParent;
     WindowPtr pWin = (WindowPtr) value;
-    xEvent event;
 
     UnmapWindow(pWin, FALSE);
 
@@ -969,8 +966,7 @@ DeleteWindow(pointer value, XID wid)
 
     pParent = pWin->parent;
     if (wid && pParent && SubStrSend(pWin, pParent)) {
-        memset(&event, 0, sizeof(xEvent));
-        event.u.u.type = DestroyNotify;
+        xEvent event = { .u.u.type = DestroyNotify };
         event.u.destroyNotify.window = pWin->drawable.id;
         DeliverEvents(pWin, &event, 1, NullWindow);
     }
@@ -1355,11 +1351,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
                         CheckWindowOptionalNeed(pChild);
                 }
 
+                xE = (xEvent) {
+                    .u.colormap.window = pWin->drawable.id,
+                    .u.colormap.colormap = cmap,
+                    .u.colormap.new = xTrue,
+                    .u.colormap.state = IsMapInstalled(cmap, pWin)
+                };
                 xE.u.u.type = ColormapNotify;
-                xE.u.colormap.window = pWin->drawable.id;
-                xE.u.colormap.colormap = cmap;
-                xE.u.colormap.new = xTrue;
-                xE.u.colormap.state = IsMapInstalled(cmap, pWin);
                 DeliverEvents(pWin, &xE, 1, NullWindow);
             }
             break;
@@ -1746,12 +1744,12 @@ ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh)
             GravityTranslate(cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh,
                              pSib->winGravity, &cwsx, &cwsy);
             if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) {
-                xEvent event;
-
+                xEvent event = {
+                    .u.gravity.window = pSib->drawable.id,
+                    .u.gravity.x = cwsx - wBorderWidth(pSib),
+                    .u.gravity.y = cwsy - wBorderWidth(pSib)
+                };
                 event.u.u.type = GravityNotify;
-                event.u.gravity.window = pSib->drawable.id;
-                event.u.gravity.x = cwsx - wBorderWidth(pSib);
-                event.u.gravity.y = cwsy - wBorderWidth(pSib);
                 DeliverEvents(pSib, &event, 1, NullWindow);
                 pSib->origin.x = cwsx;
                 pSib->origin.y = cwsy;
@@ -2090,7 +2088,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
     unsigned short w = pWin->drawable.width,
         h = pWin->drawable.height, bw = pWin->borderWidth;
     int rc, action, smode = Above;
-    xEvent event;
 
     if ((pWin->drawable.class == InputOnly) &&
         (mask & IllegalInputOnlyConfigureMask))
@@ -2179,30 +2176,25 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
 
     if ((!pWin->overrideRedirect) && (RedirectSend(pParent)
         )) {
-        memset(&event, 0, sizeof(xEvent));
+        xEvent event = {
+            .u.configureRequest.window = pWin->drawable.id,
+            .u.configureRequest.sibling = (mask & CWSibling) ? sibwid : None,
+            .u.configureRequest.x = x,
+            .u.configureRequest.y = y,
+            .u.configureRequest.width = w,
+            .u.configureRequest.height = h,
+            .u.configureRequest.borderWidth = bw,
+            .u.configureRequest.valueMask = mask,
+            .u.configureRequest.parent = pParent->drawable.id
+        };
         event.u.u.type = ConfigureRequest;
-        event.u.configureRequest.window = pWin->drawable.id;
-        if (mask & CWSibling)
-            event.u.configureRequest.sibling = sibwid;
-        else
-            event.u.configureRequest.sibling = None;
-        if (mask & CWStackMode)
-            event.u.u.detail = smode;
-        else
-            event.u.u.detail = Above;
-        event.u.configureRequest.x = x;
-        event.u.configureRequest.y = y;
+        event.u.u.detail = (mask & CWStackMode) ? smode : Above;
 #ifdef PANORAMIX
         if (!noPanoramiXExtension && (!pParent || !pParent->parent)) {
             event.u.configureRequest.x += screenInfo.screens[0]->x;
             event.u.configureRequest.y += screenInfo.screens[0]->y;
         }
 #endif
-        event.u.configureRequest.width = w;
-        event.u.configureRequest.height = h;
-        event.u.configureRequest.borderWidth = bw;
-        event.u.configureRequest.valueMask = mask;
-        event.u.configureRequest.parent = pParent->drawable.id;
         if (MaybeDeliverEventsToClient(pParent, &event, 1,
                                        SubstructureRedirectMask, client) == 1)
             return Success;
@@ -2213,13 +2205,12 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
 
         if (size_change &&
             ((pWin->eventMask | wOtherEventMasks(pWin)) & ResizeRedirectMask)) {
-            xEvent eventT;
-
-            memset(&eventT, 0, sizeof(xEvent));
+            xEvent eventT = {
+                .u.resizeRequest.window = pWin->drawable.id,
+                .u.resizeRequest.width = w,
+                .u.resizeRequest.height = h
+            };
             eventT.u.u.type = ResizeRequest;
-            eventT.u.resizeRequest.window = pWin->drawable.id;
-            eventT.u.resizeRequest.width = w;
-            eventT.u.resizeRequest.height = h;
             if (MaybeDeliverEventsToClient(pWin, &eventT, 1,
                                            ResizeRedirectMask, client) == 1) {
                 /* if event is delivered, leave the actual size alone. */
@@ -2270,25 +2261,23 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
     }
 
     if (SubStrSend(pWin, pParent)) {
-        memset(&event, 0, sizeof(xEvent));
+        xEvent event = {
+            .u.configureNotify.window = pWin->drawable.id,
+            .u.configureNotify.aboveSibling = pSib ? pSib->drawable.id : None,
+            .u.configureNotify.x = x,
+            .u.configureNotify.y = y,
+            .u.configureNotify.width = w,
+            .u.configureNotify.height = h,
+            .u.configureNotify.borderWidth = bw,
+            .u.configureNotify.override = pWin->overrideRedirect
+        };
         event.u.u.type = ConfigureNotify;
-        event.u.configureNotify.window = pWin->drawable.id;
-        if (pSib)
-            event.u.configureNotify.aboveSibling = pSib->drawable.id;
-        else
-            event.u.configureNotify.aboveSibling = None;
-        event.u.configureNotify.x = x;
-        event.u.configureNotify.y = y;
 #ifdef PANORAMIX
         if (!noPanoramiXExtension && (!pParent || !pParent->parent)) {
             event.u.configureNotify.x += screenInfo.screens[0]->x;
             event.u.configureNotify.y += screenInfo.screens[0]->y;
         }
 #endif
-        event.u.configureNotify.width = w;
-        event.u.configureNotify.height = h;
-        event.u.configureNotify.borderWidth = bw;
-        event.u.configureNotify.override = pWin->overrideRedirect;
         DeliverEvents(pWin, &event, 1, NullWindow);
     }
     if (mask & CWBorderWidth) {
@@ -2361,13 +2350,13 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
             return Success;
     }
 
-    event.u.circulate.window = pWin->drawable.id;
-    event.u.circulate.parent = pParent->drawable.id;
-    event.u.circulate.event = pParent->drawable.id;
-    if (direction == RaiseLowest)
-        event.u.circulate.place = PlaceOnTop;
-    else
-        event.u.circulate.place = PlaceOnBottom;
+    event = (xEvent) {
+        .u.circulate.window = pWin->drawable.id,
+        .u.circulate.parent = pParent->drawable.id,
+        .u.circulate.event = pParent->drawable.id,
+        .u.circulate.place = (direction == RaiseLowest) ?
+                              PlaceOnTop : PlaceOnBottom,
+    };
 
     if (RedirectSend(pParent)) {
         event.u.u.type = CirculateRequest;
@@ -2420,19 +2409,20 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent,
     if (WasMapped)
         UnmapWindow(pWin, FALSE);
 
-    memset(&event, 0, sizeof(xEvent));
+    event = (xEvent) {
+        .u.reparent.window = pWin->drawable.id,
+        .u.reparent.parent = pParent->drawable.id,
+        .u.reparent.x = x,
+        .u.reparent.y = y,
+        .u.reparent.override = pWin->overrideRedirect
+    };
     event.u.u.type = ReparentNotify;
-    event.u.reparent.window = pWin->drawable.id;
-    event.u.reparent.parent = pParent->drawable.id;
-    event.u.reparent.x = x;
-    event.u.reparent.y = y;
 #ifdef PANORAMIX
     if (!noPanoramiXExtension && !pParent->parent) {
         event.u.reparent.x += screenInfo.screens[0]->x;
         event.u.reparent.y += screenInfo.screens[0]->y;
     }
 #endif
-    event.u.reparent.override = pWin->overrideRedirect;
     DeliverEvents(pWin, &event, 1, pParent);
 
     /* take out of sibling chain */
@@ -2568,15 +2558,15 @@ MapWindow(WindowPtr pWin, ClientPtr client)
 
     pScreen = pWin->drawable.pScreen;
     if ((pParent = pWin->parent)) {
-        xEvent event;
         Bool anyMarked;
 
         if ((!pWin->overrideRedirect) && (RedirectSend(pParent)
             )) {
-            memset(&event, 0, sizeof(xEvent));
+            xEvent event = {
+                .u.mapRequest.window = pWin->drawable.id,
+                .u.mapRequest.parent = pParent->drawable.id
+            };
             event.u.u.type = MapRequest;
-            event.u.mapRequest.window = pWin->drawable.id;
-            event.u.mapRequest.parent = pParent->drawable.id;
 
             if (MaybeDeliverEventsToClient(pParent, &event, 1,
                                            SubstructureRedirectMask,
@@ -2586,10 +2576,11 @@ MapWindow(WindowPtr pWin, ClientPtr client)
 
         pWin->mapped = TRUE;
         if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) {
-            memset(&event, 0, sizeof(xEvent));
+            xEvent event = {
+                .u.mapNotify.window = pWin->drawable.id,
+                .u.mapNotify.override = pWin->overrideRedirect,
+            };
             event.u.u.type = MapNotify;
-            event.u.mapNotify.window = pWin->drawable.id;
-            event.u.mapNotify.override = pWin->overrideRedirect;
             DeliverEvents(pWin, &event, 1, NullWindow);
         }
 
@@ -2644,7 +2635,6 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
     ScreenPtr pScreen;
     Mask parentRedirect;
     Mask parentNotify;
-    xEvent event;
     Bool anyMarked;
     WindowPtr pLayerWin;
 
@@ -2655,10 +2645,11 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
     for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) {
         if (!pWin->mapped) {
             if (parentRedirect && !pWin->overrideRedirect) {
-                memset(&event, 0, sizeof(xEvent));
+                xEvent event = {
+                    .u.mapRequest.window = pWin->drawable.id,
+                    .u.mapRequest.parent = pParent->drawable.id
+                };
                 event.u.u.type = MapRequest;
-                event.u.mapRequest.window = pWin->drawable.id;
-                event.u.mapRequest.parent = pParent->drawable.id;
 
                 if (MaybeDeliverEventsToClient(pParent, &event, 1,
                                                SubstructureRedirectMask,
@@ -2668,10 +2659,11 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
 
             pWin->mapped = TRUE;
             if (parentNotify || StrSend(pWin)) {
-                memset(&event, 0, sizeof(xEvent));
+                xEvent event = {
+                    .u.mapNotify.window = pWin->drawable.id,
+                    .u.mapNotify.override = pWin->overrideRedirect
+                };
                 event.u.u.type = MapNotify;
-                event.u.mapNotify.window = pWin->drawable.id;
-                event.u.mapNotify.override = pWin->overrideRedirect;
                 DeliverEvents(pWin, &event, 1, NullWindow);
             }
 
@@ -2765,7 +2757,6 @@ int
 UnmapWindow(WindowPtr pWin, Bool fromConfigure)
 {
     WindowPtr pParent;
-    xEvent event;
     Bool wasRealized = (Bool) pWin->realized;
     Bool wasViewable = (Bool) pWin->viewable;
     ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -2774,10 +2765,11 @@ UnmapWindow(WindowPtr pWin, Bool fromConfigure)
     if ((!pWin->mapped) || (!(pParent = pWin->parent)))
         return Success;
     if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) {
-        memset(&event, 0, sizeof(xEvent));
+        xEvent event = {
+            .u.unmapNotify.window = pWin->drawable.id,
+            .u.unmapNotify.fromConfigure = fromConfigure
+        };
         event.u.u.type = UnmapNotify;
-        event.u.unmapNotify.window = pWin->drawable.id;
-        event.u.unmapNotify.fromConfigure = fromConfigure;
         DeliverEvents(pWin, &event, 1, NullWindow);
     }
     if (wasViewable && !fromConfigure) {
@@ -2813,7 +2805,6 @@ void
 UnmapSubwindows(WindowPtr pWin)
 {
     WindowPtr pChild, pHead;
-    xEvent event;
     Bool wasRealized = (Bool) pWin->realized;
     Bool wasViewable = (Bool) pWin->viewable;
     Bool anyMarked = FALSE;
@@ -2832,9 +2823,11 @@ UnmapSubwindows(WindowPtr pWin)
     for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) {
         if (pChild->mapped) {
             if (parentNotify || StrSend(pChild)) {
+                xEvent event = {
+                    .u.unmapNotify.window = pChild->drawable.id,
+                    .u.unmapNotify.fromConfigure = xFalse
+                };
                 event.u.u.type = UnmapNotify;
-                event.u.unmapNotify.window = pChild->drawable.id;
-                event.u.unmapNotify.fromConfigure = xFalse;
                 DeliverEvents(pChild, &event, 1, NullWindow);
             }
             if (pChild->viewable) {
@@ -3028,10 +3021,11 @@ SendVisibilityNotify(WindowPtr pWin)
     }
 #endif
 
-    memset(&event, 0, sizeof(xEvent));
+    event = (xEvent) {
+        .u.visibility.window = pWin->drawable.id,
+        .u.visibility.state = visibility
+    };
     event.u.u.type = VisibilityNotify;
-    event.u.visibility.window = pWin->drawable.id;
-    event.u.visibility.state = visibility;
     DeliverEvents(pWin, &event, 1, NullWindow);
 }
 
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 2dc465d..8b7c93f 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -349,13 +349,12 @@ miSendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
         free(pEvent);
     }
     else {
-        xEvent event;
-
-        memset(&event, 0, sizeof(xEvent));
+        xEvent event = {
+            .u.noExposure.drawable = drawable,
+            .u.noExposure.majorEvent = major,
+            .u.noExposure.minorEvent = minor
+        };
         event.u.u.type = NoExpose;
-        event.u.noExposure.drawable = drawable;
-        event.u.noExposure.majorEvent = major;
-        event.u.noExposure.minorEvent = minor;
         WriteEventsToClient(client, 1, &event);
     }
 }
-- 
1.7.9.2



More information about the xorg-devel mailing list