[PATCH 3/4] xkbcomp: Support 'noLock'/'noUnlock' flags and group locks in LockMods #865, #27903

Andreas Wettstein wettstein509 at solnet.ch
Sat Nov 10 08:08:35 PST 2012


Support syntax to use the 'noLock' and 'noUnlock' flags in 'LockMods', as well
as the possibility to specify a group change in 'LockMods".  This is required
to fix #865 and #27903 without using 'Private' actions, which assume a
particular memory layout (see comment 1 for bug #56491).

Signed-off-by: Andreas Wettstein <wettstein509 at solnet.ch>
---
 action.c | 88 ++++++++++++++++++++++++++++++++++++++--------------------------
 1 Datei geändert, 53 Zeilen hinzugefügt(+), 35 Zeilen entfernt(-)

diff --git a/action.c b/action.c
index 3b82e64..99ec32c 100644
--- a/action.c
+++ b/action.c
@@ -436,33 +436,13 @@ HandleSetLatchMods(XkbDescPtr xkb,
     return ReportIllegal(action->type, field);
 }
 
-static Bool
-HandleLockMods(XkbDescPtr xkb,
-               XkbAnyAction * action,
-               unsigned field, ExprDef * array_ndx, ExprDef * value)
-{
-    XkbModAction *act;
-    unsigned t1, t2;
-
-    act = (XkbModAction *) action;
-    if ((array_ndx != NULL) && (field == F_Modifiers))
-        return ReportActionNotArray(action->type, field);
-    switch (field)
-    {
-    case F_Modifiers:
-        t1 = act->flags;
-        if (CheckModifierField(xkb, action->type, value, &t1, &t2))
-        {
-            act->flags = t1;
-            act->real_mods = act->mask = (t2 & 0xff);
-            t2 = (t2 >> 8) & 0xffff;
-            XkbSetModActionVMods(act, t2);
-            return True;
-        }
-        return False;
-    }
-    return ReportIllegal(action->type, field);
-}
+static LookupEntry lockWhich[] = {
+    {"both", 0},
+    {"lock", XkbSA_LockNoUnlock},
+    {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
+    {"unlock", XkbSA_LockNoLock},
+    {NULL, 0}
+};
 
 static LookupEntry groupNames[] = {
     {"group1", 1},
@@ -514,6 +494,52 @@ CheckGroupField(unsigned action,
 }
 
 static Bool
+HandleLockMods(XkbDescPtr xkb,
+               XkbAnyAction * action,
+               unsigned field, ExprDef * array_ndx, ExprDef * value)
+{
+    XkbModAction *act;
+    unsigned t1, t2;
+    ExprResult rtrn;
+    int t3;
+
+    act = (XkbModAction *) action;
+    if ((array_ndx != NULL) &&
+	(field == F_Modifiers || field == F_Affect || field == F_Group))
+        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.ival;
+        return True;
+    case F_Modifiers:
+        t1 = act->flags;
+        if (CheckModifierField(xkb, action->type, value, &t1, &t2))
+        {
+            act->flags = t1;
+            act->real_mods = act->mask = (t2 & 0xff);
+            t2 = (t2 >> 8) & 0xffff;
+            XkbSetModActionVMods(act, t2);
+            return True;
+        }
+        return False;
+    case F_Group:
+        t1 = act->group_flags;
+        if (CheckGroupField(action->type, value, &t1, &t3))
+        {
+            act->group_flags = t1;
+            XkbSASetGroup(act, t3);
+            return True;
+        }
+        return False;
+    }
+    return ReportIllegal(action->type, field);
+}
+
+static Bool
 HandleSetLatchGroup(XkbDescPtr xkb,
                     XkbAnyAction * action,
                     unsigned field, ExprDef * array_ndx, ExprDef * value)
@@ -641,14 +667,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,
-- 
1.7.11.3



More information about the xorg-devel mailing list