Move per_key_repeats and enabled_ctrls to keymap All of the per-key data and global flags are now visible directly in the keymap. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
diff --git a/src/alloc.c b/src/alloc.c
index 8441f52..6cd5fc2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -168,36 +168,6 @@ free_names(struct xkb_keymap *keymap)
free(keymap->compat_section_name);
}
-int
-XkbcAllocControls(struct xkb_keymap *keymap)
-{
- if (!keymap)
- return BadMatch;
-
- if (!keymap->ctrls) {
- keymap->ctrls = uTypedCalloc(1, struct xkb_controls);
- if (!keymap->ctrls)
- return BadAlloc;
- }
-
- keymap->ctrls->per_key_repeat = uTypedCalloc(keymap->max_key_code >> 3,
- unsigned char);
- if (!keymap->ctrls->per_key_repeat)
- return BadAlloc;
-
- return Success;
-}
-
-static void
-XkbcFreeControls(struct xkb_keymap *keymap)
-{
- if (keymap && keymap->ctrls) {
- free(keymap->ctrls->per_key_repeat);
- free(keymap->ctrls);
- keymap->ctrls = NULL;
- }
-}
-
struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *ctx)
{
@@ -229,7 +199,7 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
free(keymap->vmodmap);
darray_free(keymap->sym_interpret);
free_names(keymap);
- XkbcFreeControls(keymap);
+ free(keymap->per_key_repeat);
xkb_context_unref(keymap->ctx);
free(keymap);
}
diff --git a/src/alloc.h b/src/alloc.h
index a525990..34a5a91 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -29,9 +29,6 @@
#include "xkb-priv.h"
-extern int
-XkbcAllocControls(struct xkb_keymap *keymap);
-
extern struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *ctx);
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 8599d2f..b836418 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -842,9 +842,8 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
darray_item(keymap->types, type).name);
}
}
- if (keymap->ctrls &&
- (keymap->explicit[key] & XkbExplicitAutoRepeatMask)) {
- if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)))
+ if (keymap->explicit[key] & XkbExplicitAutoRepeatMask) {
+ if (keymap->per_key_repeat[key / 8] & (1 << (key % 8)))
write_buf(keymap, buf, size, offset,
"\n\t\t\trepeat= Yes,");
else
diff --git a/src/map.c b/src/map.c
index 4fa5876..16ee80d 100644
--- a/src/map.c
+++ b/src/map.c
@@ -357,5 +357,5 @@ err:
_X_EXPORT int
xkb_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key)
{
- return !!(keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)));
+ return !!(keymap->per_key_repeat[key / 8] & (1 << (key % 8)));
}
diff --git a/src/state.c b/src/state.c
index 4174383..76eb287 100644
--- a/src/state.c
+++ b/src/state.c
@@ -562,7 +562,7 @@ xkb_state_led_update_all(struct xkb_state *state)
state->leds |= (1 << led);
}
else if (map->ctrls) {
- if ((map->ctrls & state->keymap->ctrls->enabled_ctrls))
+ if ((map->ctrls & state->keymap->enabled_ctrls))
state->leds |= (1 << led);
}
}
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 9463b1c..0d1431f 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -294,34 +294,33 @@ struct xkb_key_alias {
};
struct xkb_controls {
- /* unsigned char groups_wrap; */
- /* struct xkb_mods internal; */
- /* struct xkb_mods ignore_lock; */
- unsigned int enabled_ctrls;
- /* unsigned short repeat_delay; */
- /* unsigned short repeat_interval; */
- /* unsigned short slow_keys_delay; */
- /* unsigned short debounce_delay; */
- /* unsigned short ax_options; */
- /* unsigned short ax_timeout; */
- /* unsigned short axt_opts_mask; */
- /* unsigned short axt_opts_values; */
- /* unsigned int axt_ctrls_mask; */
- /* unsigned int axt_ctrls_values; */
- unsigned char *per_key_repeat;
+ unsigned char groups_wrap;
+ struct xkb_mods internal;
+ struct xkb_mods ignore_lock;
+ unsigned short repeat_delay;
+ unsigned short repeat_interval;
+ unsigned short slow_keys_delay;
+ unsigned short debounce_delay;
+ unsigned short ax_options;
+ unsigned short ax_timeout;
+ unsigned short axt_opts_mask;
+ unsigned short axt_opts_values;
+ unsigned int axt_ctrls_mask;
+ unsigned int axt_ctrls_values;
};
/* Common keyboard description structure */
struct xkb_keymap {
- struct xkb_context *ctx;
+ struct xkb_context *ctx;
+
+ int refcnt;
+ enum xkb_map_compile_flags flags;
+
+ unsigned int enabled_ctrls;
- unsigned int refcnt;
- unsigned short flags;
xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code;
- struct xkb_controls * ctrls;
-
/* key -> key name mapping */
darray(struct xkb_key_name) key_names;
/* aliases in no particular order */
@@ -355,6 +354,9 @@ struct xkb_keymap {
/* key -> behavior mapping */
struct xkb_behavior *behaviors;
+ /* key -> should repeat mapping - one bit per key */
+ unsigned char *per_key_repeat;
+
struct xkb_indicator_map indicators[XkbNumIndicators];
char *indicator_names[XkbNumIndicators];
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 01dfde3..d7332c1 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -932,8 +932,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
if (group == 0 && level == 0) {
if (!(keymap->explicit[key] & XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat))
- keymap->ctrls->per_key_repeat[key / 8] |=
- (1 << (key % 8));
+ keymap->per_key_repeat[key / 8] |= (1 << (key % 8));
if (!(keymap->explicit[key] & XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey))
keymap->behaviors[key].type = XkbKB_Lock;
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 7f8b9d1..2033e98 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1850,9 +1850,9 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
}
if (key->repeat != RepeatUndefined) {
if (key->repeat == RepeatYes)
- keymap->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
+ keymap->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else
- keymap->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
+ keymap->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
keymap->explicit[kc] |= XkbExplicitAutoRepeatMask;
}
@@ -1942,11 +1942,9 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
if (!keymap->vmodmap)
goto err_info;
- if (XkbcAllocControls(keymap) != Success) {
- WSGO("Could not allocate controls in CompileSymbols\n");
- ACTION("Symbols not added\n");
+ keymap->per_key_repeat = calloc(keymap->max_key_code / 8, 1);
+ if (!keymap->per_key_repeat)
goto err_info;
- }
if (info.name)
keymap->symbols_section_name = strdup(info.name);