Commit 32bf4053766250d280191ec57e79c863bfb1dca7

Daniel Stone 2012-09-10T20:44:52

kbproto unentanglement: Xkb{Wrap,Clamp,Redirect}IntoRange Signed-off-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 0a478f2..0c5e49a 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -681,14 +681,17 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
         }
 
         switch (key->out_of_range_group_action) {
-        case XkbClampIntoRange:
+        case RANGE_SATURATE:
             write_buf(buf, "\n\t\t\tgroupsClamp,");
             break;
 
-        case XkbRedirectIntoRange:
+        case RANGE_REDIRECT:
             write_buf(buf, "\n\t\t\tgroupsRedirect= Group%u,",
                       key->out_of_range_group_number + 1);
             break;
+
+        default:
+            break;
         }
 
         if (key->explicit & XkbExplicitInterpretMask)
diff --git a/src/map.c b/src/map.c
index 8b751e6..384ff22 100644
--- a/src/map.c
+++ b/src/map.c
@@ -335,17 +335,17 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
         return ret;
 
     switch (key->out_of_range_group_action) {
-    case XkbRedirectIntoRange:
+    case RANGE_REDIRECT:
         ret = key->out_of_range_group_number;
         if (ret >= key->num_groups)
             ret = 0;
         break;
 
-    case XkbClampIntoRange:
+    case RANGE_SATURATE:
         ret = key->num_groups - 1;
         break;
 
-    case XkbWrapIntoRange:
+    case RANGE_WRAP:
     default:
         ret %= key->num_groups;
         break;
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 95f1348..ae0aef0 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -298,6 +298,13 @@ struct xkb_controls {
     unsigned int axt_ctrls_values;
 };
 
+/* Such an awkward name.  Oh well. */
+enum xkb_range_exceed_type {
+    RANGE_SATURATE,
+    RANGE_WRAP,
+    RANGE_REDIRECT,
+};
+
 struct xkb_key {
     char name[XKB_KEY_NAME_LENGTH];
 
@@ -316,7 +323,7 @@ struct xkb_key {
     /* How many levels the largest group has. */
     xkb_level_index_t width;
 
-    uint8_t out_of_range_group_action;
+    enum xkb_range_exceed_type out_of_range_group_action;
     xkb_group_index_t out_of_range_group_number;
 
     /* per level/group index into 'syms' */
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index f9cbe92..91b63d4 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -85,7 +85,7 @@ typedef struct _KeyInfo {
     xkb_mod_mask_t vmodmap;
     xkb_atom_t dfltType;
 
-    uint8_t out_of_range_group_action;
+    enum xkb_range_exceed_type out_of_range_group_action;
     xkb_group_index_t out_of_range_group_number;
 } KeyInfo;
 
@@ -116,7 +116,7 @@ InitKeyInfo(KeyInfo *keyi, unsigned file_id)
     keyi->dfltType = XKB_ATOM_NONE;
     keyi->vmodmap = 0;
     keyi->repeat = KEY_REPEAT_UNDEFINED;
-    keyi->out_of_range_group_action = 0;
+    keyi->out_of_range_group_action = RANGE_WRAP;
     keyi->out_of_range_group_number = 0;
 }
 
@@ -1128,9 +1128,9 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         }
 
         if (set)
-            keyi->out_of_range_group_action = XkbWrapIntoRange;
+            keyi->out_of_range_group_action = RANGE_WRAP;
         else
-            keyi->out_of_range_group_action = XkbClampIntoRange;
+            keyi->out_of_range_group_action = RANGE_SATURATE;
 
         keyi->defined |= KEY_FIELD_GROUPINFO;
     }
@@ -1147,9 +1147,9 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         }
 
         if (set)
-            keyi->out_of_range_group_action = XkbClampIntoRange;
+            keyi->out_of_range_group_action = RANGE_SATURATE;
         else
-            keyi->out_of_range_group_action = XkbWrapIntoRange;
+            keyi->out_of_range_group_action = RANGE_WRAP;
 
         keyi->defined |= KEY_FIELD_GROUPINFO;
     }
@@ -1165,7 +1165,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
             return false;
         }
 
-        keyi->out_of_range_group_action = XkbRedirectIntoRange;
+        keyi->out_of_range_group_action = RANGE_REDIRECT;
         keyi->out_of_range_group_number = grp - 1;
         keyi->defined |= KEY_FIELD_GROUPINFO;
     }
@@ -1805,10 +1805,8 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
         key->explicit |= XkbExplicitInterpretMask;
     }
 
-    if (keyi->defined & KEY_FIELD_GROUPINFO) {
-        key->out_of_range_group_number = keyi->out_of_range_group_number;
-        key->out_of_range_group_action = keyi->out_of_range_group_action;
-    }
+    key->out_of_range_group_number = keyi->out_of_range_group_number;
+    key->out_of_range_group_action = keyi->out_of_range_group_action;
 
     for (i = 0; i < nGroups; i++) {
         /* assign kt_index[i] to the index of the type in map->types.