[PATCH 14/19] Use C99 designated initializers in dix Events
Alan Coopersmith
alan.coopersmith at oracle.com
Sun Jun 24 10:25:21 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 | 148 +++++++++++++++++-----------------
dix/inpututils.c | 13 +--
dix/property.c | 13 ++-
dix/selection.c | 48 +++++------
dix/swapreq.c | 2 +-
dix/window.c | 232 +++++++++++++++++++++++++++---------------------------
mi/miexpose.c | 11 ++-
10 files changed, 275 insertions(+), 274 deletions(-)
diff --git a/dix/colormap.c b/dix/colormap.c
index 1030628..669a5a0 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 bde1e14..6b6aadc 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);
}
@@ -2438,18 +2437,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 761ab3b..22a3d4b 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 7192341..c439d58 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2817,9 +2817,6 @@ XYToWindow(SpritePtr pSprite, int x, int y)
BOOL
ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
{
- BOOL rc = FALSE;
- DeviceEvent event;
-
if (dev->deviceGrab.grab) {
if (!dev->deviceGrab.fromPassiveGrab ||
dev->deviceGrab.grab->type != XI_Enter ||
@@ -2832,20 +2829,22 @@ 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;
- rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
- TRUE) != NULL);
- if (rc)
- DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
- return rc;
+ else {
+ DeviceEvent event = {
+ .header = ET_Internal,
+ .type = ET_FocusIn,
+ .length = sizeof(DeviceEvent),
+ .time = GetTimeInMillis(),
+ .deviceid = dev->id,
+ .sourceid = dev->id,
+ .detail.button = 0
+ };
+ BOOL rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event,
+ FALSE, TRUE) != NULL);
+ if (rc)
+ DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
+ return rc;
+ }
}
/**
@@ -2857,9 +2856,6 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
static BOOL
ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
{
- BOOL rc = FALSE;
- DeviceEvent event;
-
if (dev->deviceGrab.grab) {
if (!dev->deviceGrab.fromPassiveGrab ||
dev->deviceGrab.grab->type != XI_Enter ||
@@ -2870,19 +2866,22 @@ 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;
- rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
- TRUE) != NULL);
- if (rc)
- DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
- return rc;
+ {
+ DeviceEvent event = {
+ .header = ET_Internal,
+ .type = ET_Enter,
+ .length = sizeof(DeviceEvent),
+ .time = GetTimeInMillis(),
+ .deviceid = dev->id,
+ .sourceid = dev->id,
+ .detail.button = 0
+ };
+ BOOL rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event,
+ FALSE, TRUE) != NULL);
+ if (rc)
+ DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
+ return rc;
+ }
}
/**
@@ -4456,7 +4455,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;
@@ -4476,9 +4478,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;
@@ -4509,15 +4508,14 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
}
if ((type == EnterNotify) && (mask & KeymapStateMask)) {
- xKeymapEvent ke;
+ xKeymapEvent ke = {
+ .type = KeymapNotify
+ };
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
- if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
- memset((char *) &ke.map[0], 0, 31);
- else
- memmove((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
+ if (!XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
+ 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);
@@ -4602,27 +4600,25 @@ 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);
- if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
- memset((char *) &ke.map[0], 0, 31);
- else
- memmove((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
+ if (!XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
+ memcpy((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
- ke.type = KeymapNotify;
DeliverEventsToWindow(dev, pWin, (xEvent *) &ke, 1,
KeymapStateMask, NullGrab);
}
@@ -5427,12 +5423,13 @@ ProcGrabKey(ClientPtr client)
REQUEST_SIZE_MATCH(xGrabKeyReq);
- memset(¶m, 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, ¶m);
if (rc != Success)
@@ -5474,7 +5471,6 @@ ProcGrabButton(ClientPtr client)
DeviceIntPtr ptr, modifierDevice;
Mask access_mode = DixGrabAccess;
GrabMask mask;
- GrabParameters param;
int rc;
REQUEST_SIZE_MATCH(xGrabButtonReq);
@@ -5532,22 +5528,24 @@ ProcGrabButton(ClientPtr client)
rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, access_mode);
if (rc != Success)
return rc;
+ else {
+ GrabParameters param = {
+ .grabtype = CORE,
+ .ownerEvents = stuff->ownerEvents,
+ .this_device_mode = stuff->keyboardMode,
+ .other_devices_mode = stuff->pointerMode,
+ .modifiers = stuff->modifiers
+ };
- memset(¶m, 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;
-
- mask.core = stuff->eventMask;
+ mask.core = stuff->eventMask;
- grab = CreateGrab(client->index, ptr, modifierDevice, pWin,
- CORE, &mask, ¶m, ButtonPress,
- stuff->button, confineTo, cursor);
- if (!grab)
- return BadAlloc;
- return AddPassiveGrabToList(client, grab);
+ grab = CreateGrab(client->index, ptr, modifierDevice, pWin,
+ CORE, &mask, ¶m, ButtonPress,
+ stuff->button, confineTo, cursor);
+ if (!grab)
+ return BadAlloc;
+ return AddPassiveGrabToList(client, grab);
+ }
}
/**
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 fcc2c64..32b25f7 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 59d4871..703344b 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);
}
}
@@ -257,7 +257,6 @@ int
ProcConvertSelection(ClientPtr client)
{
Bool paramsOkay;
- xEvent event;
WindowPtr pWin;
Selection *pSel;
int rc;
@@ -278,30 +277,35 @@ ProcConvertSelection(ClientPtr client)
rc = dixLookupSelection(&pSel, stuff->selection, client, DixReadAccess);
- memset(&event, 0, sizeof(xEvent));
if (rc != Success && rc != BadMatch)
return rc;
else if (rc == Success && pSel->window != None) {
- event.u.u.type = SelectionRequest;
- event.u.selectionRequest.owner = pSel->window;
- event.u.selectionRequest.time = stuff->time;
- event.u.selectionRequest.requestor = stuff->requestor;
- event.u.selectionRequest.selection = stuff->selection;
- event.u.selectionRequest.target = stuff->target;
- event.u.selectionRequest.property = stuff->property;
if (pSel->client && pSel->client != serverClient &&
!pSel->client->clientGone) {
+ xEvent event = {
+ .u.selectionRequest.owner = pSel->window,
+ .u.selectionRequest.time = stuff->time,
+ .u.selectionRequest.requestor = stuff->requestor,
+ .u.selectionRequest.selection = stuff->selection,
+ .u.selectionRequest.target = stuff->target,
+ .u.selectionRequest.property = stuff->property
+ };
+ event.u.u.type = SelectionRequest;
WriteEventsToClient(pSel->client, 1, &event);
return Success;
}
}
- event.u.u.type = SelectionNotify;
- event.u.selectionNotify.time = stuff->time;
- event.u.selectionNotify.requestor = stuff->requestor;
- event.u.selectionNotify.selection = stuff->selection;
- event.u.selectionNotify.target = stuff->target;
- event.u.selectionNotify.property = None;
- WriteEventsToClient(client, 1, &event);
- return Success;
+ {
+ xEvent event = {
+ .u.selectionNotify.time = stuff->time,
+ .u.selectionNotify.requestor = stuff->requestor,
+ .u.selectionNotify.selection = stuff->selection,
+ .u.selectionNotify.target = stuff->target,
+ .u.selectionNotify.property = None
+ };
+ event.u.u.type = SelectionNotify;
+ WriteEventsToClient(client, 1, &event);
+ return Success;
+ }
}
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 98f5604..0f695ba 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) {
@@ -2337,7 +2326,6 @@ int
CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
{
WindowPtr pWin, pHead, pFirst;
- xEvent event;
BoxRec box;
pHead = RealChildHead(pParent);
@@ -2361,23 +2349,26 @@ 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;
+ {
+ xEvent event = {
+ .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;
+ if (MaybeDeliverEventsToClient(pParent, &event, 1,
+ SubstructureRedirectMask, client)
+ == 1)
+ return Success;
+ }
- if (RedirectSend(pParent)) {
- event.u.u.type = CirculateRequest;
- if (MaybeDeliverEventsToClient(pParent, &event, 1,
- SubstructureRedirectMask, client) == 1)
- return Success;
+ event.u.u.type = CirculateNotify;
+ DeliverEvents(pWin, &event, 1, NullWindow);
}
-
- event.u.u.type = CirculateNotify;
- DeliverEvents(pWin, &event, 1, NullWindow);
ReflectStackChange(pWin,
(direction == RaiseLowest) ? pFirst : NullWindow,
VTStack);
@@ -2406,7 +2397,6 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent,
{
WindowPtr pPrev, pPriorParent;
Bool WasMapped = (Bool) (pWin->mapped);
- xEvent event;
int bw = wBorderWidth(pWin);
ScreenPtr pScreen;
@@ -2420,20 +2410,23 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent,
if (WasMapped)
UnmapWindow(pWin, FALSE);
- memset(&event, 0, sizeof(xEvent));
- 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;
+ {
+ xEvent event = {
+ .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;
#ifdef PANORAMIX
- if (!noPanoramiXExtension && !pParent->parent) {
- event.u.reparent.x += screenInfo.screens[0]->x;
- event.u.reparent.y += screenInfo.screens[0]->y;
- }
+ 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);
+ DeliverEvents(pWin, &event, 1, pParent);
+ }
/* take out of sibling chain */
@@ -2568,15 +2561,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 +2579,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 +2638,6 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
ScreenPtr pScreen;
Mask parentRedirect;
Mask parentNotify;
- xEvent event;
Bool anyMarked;
WindowPtr pLayerWin;
@@ -2655,10 +2648,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 +2662,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 +2760,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 +2768,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 +2808,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 +2826,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) {
@@ -2960,7 +2956,6 @@ NotClippedByChildren(WindowPtr pWin)
void
SendVisibilityNotify(WindowPtr pWin)
{
- xEvent event;
unsigned int visibility = pWin->visibility;
if (!MapUnmapEventsEnabled(pWin))
@@ -3028,11 +3023,14 @@ SendVisibilityNotify(WindowPtr pWin)
}
#endif
- memset(&event, 0, sizeof(xEvent));
- event.u.u.type = VisibilityNotify;
- event.u.visibility.window = pWin->drawable.id;
- event.u.visibility.state = visibility;
- DeliverEvents(pWin, &event, 1, NullWindow);
+ {
+ xEvent event = {
+ .u.visibility.window = pWin->drawable.id,
+ .u.visibility.state = visibility
+ };
+ event.u.u.type = VisibilityNotify;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
}
#define RANDOM_WIDTH 32
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