Commit ff0e5908 authored by Andreas Wettstein's avatar Andreas Wettstein Committed by Alan Coopersmith

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: default avatarAndreas Wettstein <wettstein509@solnet.ch>
Reviewed-By: default avatarRan Benita <ran234@gmail.com>
Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 9edd61b9
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment