From ff0e59084d6b9f2e7085fc88ba68916150085afb Mon Sep 17 00:00:00 2001 From: Andreas Wettstein Date: Sat, 15 Feb 2014 17:34:41 +0100 Subject: xkbcomp Fix missing support for "affect" and incorrect modifier handling for ISOLock Add missing support for "affect" flag to selectively affect locking or unlocking for for modifier locking, control locking, and ISOLock. Fix some incorrect masking and modifier handling for ISOLock. Signed-off-by: Andreas Wettstein Reviewed-By: Ran Benita Signed-off-by: Alan Coopersmith --- action.c | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'action.c') diff --git a/action.c b/action.c index 6efe65b..292f2ea 100644 --- a/action.c +++ b/action.c @@ -436,6 +436,14 @@ HandleSetLatchMods(XkbDescPtr xkb, return ReportIllegal(action->type, field); } +static LookupEntry lockWhich[] = { + {"both", 0}, + {"lock", XkbSA_LockNoUnlock}, + {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)}, + {"unlock", XkbSA_LockNoLock}, + {NULL, 0} +}; + static Bool HandleLockMods(XkbDescPtr xkb, XkbAnyAction * action, @@ -443,12 +451,19 @@ HandleLockMods(XkbDescPtr xkb, { XkbModAction *act; unsigned t1, t2; + ExprResult rtrn; act = (XkbModAction *) action; - if ((array_ndx != NULL) && (field == F_Modifiers)) + if ((array_ndx != NULL) && (field == F_Modifiers || field == F_Affect)) return ReportActionNotArray(action->type, field); switch (field) { + case F_Affect: + if (!ExprResolveEnum(value, &rtrn, lockWhich)) + return ReportMismatch(action->type, field, "lock or unlock"); + act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); + act->flags |= rtrn.uval; + return True; case F_Modifiers: t1 = act->flags; if (CheckModifierField(xkb, action->type, value, &t1, &t2)) @@ -642,14 +657,6 @@ static LookupEntry btnNames[] = { {NULL, 0} }; -static LookupEntry lockWhich[] = { - {"both", 0}, - {"lock", XkbSA_LockNoUnlock}, - {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)}, - {"unlock", XkbSA_LockNoLock}, - {NULL, 0} -}; - static Bool HandlePtrBtn(XkbDescPtr xkb, XkbAnyAction * action, @@ -683,7 +690,7 @@ HandlePtrBtn(XkbDescPtr xkb, if (!ExprResolveEnum(value, &rtrn, lockWhich)) return ReportMismatch(action->type, field, "lock or unlock"); act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); - act->flags |= rtrn.ival; + act->flags |= rtrn.uval; return True; } else if (field == F_Count) @@ -780,8 +787,12 @@ static LookupEntry isoNames[] = { {"pointer", XkbSA_ISONoAffectPtr}, {"ctrls", XkbSA_ISONoAffectCtrls}, {"controls", XkbSA_ISONoAffectCtrls}, - {"all", ~((unsigned) 0)}, + {"all", XkbSA_ISOAffectMask}, {"none", 0}, + {"both", 0}, + {"lock", XkbSA_LockNoUnlock}, + {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)}, + {"unlock", XkbSA_LockNoLock}, {NULL, 0}, }; @@ -805,8 +816,8 @@ HandleISOLock(XkbDescPtr xkb, if (CheckModifierField(xkb, action->type, value, &flags, &mods)) { act->flags = flags & (~XkbSA_ISODfltIsGroup); - act->real_mods = mods & 0xff; - mods = (mods >> 8) & 0xff; + act->real_mods = act->mask = (mods & 0xff); + mods = (mods >> 8) & 0xffff; XkbSetModActionVMods(act, mods); return True; } @@ -828,6 +839,8 @@ HandleISOLock(XkbDescPtr xkb, if (!ExprResolveMask(value, &rtrn, SimpleLookup, (XPointer) isoNames)) return ReportMismatch(action->type, field, "keyboard component"); act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask; + act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); + act->flags |= rtrn.uval & (XkbSA_LockNoLock | XkbSA_LockNoUnlock); return True; } return ReportIllegal(action->type, field); @@ -944,6 +957,15 @@ HandleSetLockControls(XkbDescPtr xkb, XkbActionSetCtrls(act, rtrn.uval); return True; } + else if (field == F_Affect && action->type == XkbSA_LockControls) { + if (array_ndx != NULL) + return ReportActionNotArray(action->type, field); + if (!ExprResolveEnum(value, &rtrn, lockWhich)) + return ReportMismatch(action->type, field, "lock or unlock"); + act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); + act->flags |= rtrn.uval; + return True; + } return ReportIllegal(action->type, field); } @@ -1123,7 +1145,7 @@ HandleDeviceBtn(XkbDescPtr xkb, if (!ExprResolveEnum(value, &rtrn, lockWhich)) return ReportMismatch(action->type, field, "lock or unlock"); act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); - act->flags |= rtrn.ival; + act->flags |= rtrn.uval; return True; } else if (field == F_Count) @@ -1290,7 +1312,7 @@ ApplyActionFactoryDefaults(XkbAction * action) } else if (action->type == XkbSA_ISOLock) { - action->iso.real_mods = LockMask; + action->iso.real_mods = action->iso.mask = LockMask; } return; } -- cgit v1.2.1