[PATCH 1/3] xkb: factor out modifier/group latching into a helper function
Peter Hutterer
peter.hutterer at who-t.net
Sun Feb 23 21:33:49 PST 2014
Just moving code around, no functional changes
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
include/xkbsrv.h | 13 ++++++++
xkb/xkb.c | 100 +++++++++++++++++++++++++++++++++++--------------------
2 files changed, 77 insertions(+), 36 deletions(-)
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index e799799..73a7b19 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -746,6 +747,18 @@ extern _X_EXPORT void XkbInitRules(XkbRMLVOSet * /* rmlvo */,
const char * /* options */
) ;
+int
+XkbLatchLockState(ClientPtr client,
+ DeviceIntPtr dev,
+ int affectModLocks,
+ int modLocks,
+ int lockGroup,
+ int groupLock,
+ int affectModLatches,
+ int modLatches,
+ int latchGroup,
+ int groupLatch);
+
extern _X_EXPORT void XkbGetRulesDflts(XkbRMLVOSet * /* rmlvo */
);
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 31bb8d3..ad64402 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -604,17 +604,68 @@ ProcXkbGetState(ClientPtr client)
}
/***====================================================================***/
-
int
-ProcXkbLatchLockState(ClientPtr client)
+XkbLatchLockState(ClientPtr client,
+ DeviceIntPtr dev,
+ int affectModLocks,
+ int modLocks,
+ int lockGroup,
+ int groupLock,
+ int affectModLatches,
+ int modLatches,
+ int latchGroup,
+ int groupLatch)
{
- int status;
- DeviceIntPtr dev, tmpd;
XkbStateRec oldState, *newState;
CARD16 changed;
xkbStateNotify sn;
XkbEventCauseRec cause;
+ int status = Success;
+
+ oldState = dev->key->xkbInfo->state;
+ newState = &dev->key->xkbInfo->state;
+ if (affectModLocks) {
+ newState->locked_mods &= ~affectModLocks;
+ newState->locked_mods |=
+ (affectModLocks & modLocks);
+ }
+ if (status == Success && lockGroup)
+ newState->locked_group = groupLock;
+ if (status == Success && affectModLatches)
+ status = XkbLatchModifiers(dev, affectModLatches, modLatches);
+ if (status == Success && latchGroup)
+ status = XkbLatchGroup(dev, groupLatch);
+
+ if (status != Success)
+ return status;
+
+ XkbComputeDerivedState(dev->key->xkbInfo);
+
+ changed = XkbStateChangedFlags(&oldState, newState);
+ if (changed) {
+ sn.keycode = 0;
+ sn.eventType = 0;
+ sn.requestMajor = XkbReqCode;
+ sn.requestMinor = X_kbLatchLockState;
+ sn.changed = changed;
+ XkbSendStateNotify(dev, &sn);
+ changed = XkbIndicatorsToUpdate(dev, changed, FALSE);
+ if (changed) {
+ XkbSetCauseXkbReq(&cause, X_kbLatchLockState, client);
+ XkbUpdateIndicators(dev, changed, TRUE, NULL, &cause);
+ }
+ }
+
+ return status;
+}
+
+int
+ProcXkbLatchLockState(ClientPtr client)
+{
+ int status;
+ DeviceIntPtr dev, tmpd;
+
REQUEST(xkbLatchLockStateReq);
REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
@@ -633,40 +684,17 @@ ProcXkbLatchLockState(ClientPtr client)
if (!tmpd->key || !tmpd->key->xkbInfo)
continue;
- oldState = tmpd->key->xkbInfo->state;
- newState = &tmpd->key->xkbInfo->state;
- if (stuff->affectModLocks) {
- newState->locked_mods &= ~stuff->affectModLocks;
- newState->locked_mods |=
- (stuff->affectModLocks & stuff->modLocks);
- }
- if (status == Success && stuff->lockGroup)
- newState->locked_group = stuff->groupLock;
- if (status == Success && stuff->affectModLatches)
- status = XkbLatchModifiers(tmpd, stuff->affectModLatches,
- stuff->modLatches);
- if (status == Success && stuff->latchGroup)
- status = XkbLatchGroup(tmpd, stuff->groupLatch);
-
+ status = XkbLatchLockState(client, tmpd,
+ stuff->affectModLocks,
+ stuff->modLocks,
+ stuff->lockGroup,
+ stuff->groupLock,
+ stuff->affectModLatches,
+ stuff->modLatches,
+ stuff->latchGroup,
+ stuff->groupLatch);
if (status != Success)
return status;
-
- XkbComputeDerivedState(tmpd->key->xkbInfo);
-
- changed = XkbStateChangedFlags(&oldState, newState);
- if (changed) {
- sn.keycode = 0;
- sn.eventType = 0;
- sn.requestMajor = XkbReqCode;
- sn.requestMinor = X_kbLatchLockState;
- sn.changed = changed;
- XkbSendStateNotify(tmpd, &sn);
- changed = XkbIndicatorsToUpdate(tmpd, changed, FALSE);
- if (changed) {
- XkbSetCauseXkbReq(&cause, X_kbLatchLockState, client);
- XkbUpdateIndicators(tmpd, changed, TRUE, NULL, &cause);
- }
- }
}
}
--
1.8.4.2
More information about the xorg-devel
mailing list