[PATCH v2 2/4] xkb: constify XkbSendStateNotify

Peter Hutterer peter.hutterer at who-t.net
Sun Mar 2 21:44:21 PST 2014


No functional changes, but this way we're guaranteed to be able to re-use the
original event.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/xkbsrv.h |  2 +-
 xkb/xkbEvents.c  | 61 ++++++++++++++++++++++++++++----------------------------
 2 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 73a7b19..0299327 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -574,7 +574,7 @@ extern _X_EXPORT unsigned int XkbStateChangedFlags(XkbStatePtr /* old */ ,
     );
 
 extern _X_EXPORT void XkbSendStateNotify(DeviceIntPtr /* kbd */ ,
-                                         xkbStateNotify *       /* pSN */
+                                         const xkbStateNotify *       /* pSN */
     );
 
 extern _X_EXPORT void XkbSendMapNotify(DeviceIntPtr /* kbd */ ,
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 210d8eb..d905770 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -200,8 +200,9 @@ XkbSendNewKeyboardNotify(DeviceIntPtr kbd, xkbNewKeyboardNotify * pNKN)
 /***====================================================================***/
 
 void
-XkbSendStateNotify(DeviceIntPtr kbd, xkbStateNotify * pSN)
+XkbSendStateNotify(DeviceIntPtr kbd, const xkbStateNotify * pSN)
 {
+    xkbStateNotify sn = *pSN;
     XkbSrvInfoPtr xkbi;
     XkbStatePtr state;
     XkbInterestPtr interest;
@@ -214,43 +215,43 @@ XkbSendStateNotify(DeviceIntPtr kbd, xkbStateNotify * pSN)
     xkbi = kbd->key->xkbInfo;
     state = &xkbi->state;
 
-    pSN->type = XkbEventCode + XkbEventBase;
-    pSN->xkbType = XkbStateNotify;
-    pSN->deviceID = kbd->id;
-    pSN->time = time = GetTimeInMillis();
-    pSN->mods = state->mods;
-    pSN->baseMods = state->base_mods;
-    pSN->latchedMods = state->latched_mods;
-    pSN->lockedMods = state->locked_mods;
-    pSN->group = state->group;
-    pSN->baseGroup = state->base_group;
-    pSN->latchedGroup = state->latched_group;
-    pSN->lockedGroup = state->locked_group;
-    pSN->compatState = state->compat_state;
-    pSN->grabMods = state->grab_mods;
-    pSN->compatGrabMods = state->compat_grab_mods;
-    pSN->lookupMods = state->lookup_mods;
-    pSN->compatLookupMods = state->compat_lookup_mods;
-    pSN->ptrBtnState = state->ptr_buttons;
-    changed = pSN->changed;
-    bState = pSN->ptrBtnState;
+    sn.type = XkbEventCode + XkbEventBase;
+    sn.xkbType = XkbStateNotify;
+    sn.deviceID = kbd->id;
+    sn.time = time = GetTimeInMillis();
+    sn.mods = state->mods;
+    sn.baseMods = state->base_mods;
+    sn.latchedMods = state->latched_mods;
+    sn.lockedMods = state->locked_mods;
+    sn.group = state->group;
+    sn.baseGroup = state->base_group;
+    sn.latchedGroup = state->latched_group;
+    sn.lockedGroup = state->locked_group;
+    sn.compatState = state->compat_state;
+    sn.grabMods = state->grab_mods;
+    sn.compatGrabMods = state->compat_grab_mods;
+    sn.lookupMods = state->lookup_mods;
+    sn.compatLookupMods = state->compat_lookup_mods;
+    sn.ptrBtnState = state->ptr_buttons;
+    changed = sn.changed;
+    bState = sn.ptrBtnState;
 
     while (interest) {
         if ((!interest->client->clientGone) &&
             (interest->client->requestVector != InitialVector) &&
             (interest->client->xkbClientFlags & _XkbClientInitialized) &&
             (interest->stateNotifyMask & changed)) {
-            pSN->sequenceNumber = interest->client->sequence;
-            pSN->time = time;
-            pSN->changed = changed;
-            pSN->ptrBtnState = bState;
+            sn.sequenceNumber = interest->client->sequence;
+            sn.time = time;
+            sn.changed = changed;
+            sn.ptrBtnState = bState;
             if (interest->client->swapped) {
-                swaps(&pSN->sequenceNumber);
-                swapl(&pSN->time);
-                swaps(&pSN->changed);
-                swaps(&pSN->ptrBtnState);
+                swaps(&sn.sequenceNumber);
+                swapl(&sn.time);
+                swaps(&sn.changed);
+                swaps(&sn.ptrBtnState);
             }
-            WriteToClient(interest->client, sizeof(xEvent), pSN);
+            WriteToClient(interest->client, sizeof(xEvent), &sn);
         }
         interest = interest->next;
     }
-- 
1.8.4.2



More information about the xorg-devel mailing list