From caca60f3918af555b1236b7a0b0188ff410419c4 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 15 Jul 2012 01:45:34 +0300 Subject: [PATCH] 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 --- src/alloc.c | 32 +------------------------------- src/alloc.h | 3 --- src/keymap-dump.c | 5 ++--- src/map.c | 2 +- src/state.c | 2 +- src/xkb-priv.h | 42 ++++++++++++++++++++++-------------------- src/xkbcomp/compat.c | 3 +-- src/xkbcomp/symbols.c | 10 ++++------ 8 files changed, 32 insertions(+), 67 deletions(-) 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);