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>
master
Ran Benita 2012-07-15 01:45:34 +03:00
parent 1313af8fb5
commit caca60f391
8 changed files with 32 additions and 67 deletions

View File

@ -168,36 +168,6 @@ free_names(struct xkb_keymap *keymap)
free(keymap->compat_section_name); 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 * struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *ctx) XkbcAllocKeyboard(struct xkb_context *ctx)
{ {
@ -229,7 +199,7 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
free(keymap->vmodmap); free(keymap->vmodmap);
darray_free(keymap->sym_interpret); darray_free(keymap->sym_interpret);
free_names(keymap); free_names(keymap);
XkbcFreeControls(keymap); free(keymap->per_key_repeat);
xkb_context_unref(keymap->ctx); xkb_context_unref(keymap->ctx);
free(keymap); free(keymap);
} }

View File

@ -29,9 +29,6 @@
#include "xkb-priv.h" #include "xkb-priv.h"
extern int
XkbcAllocControls(struct xkb_keymap *keymap);
extern struct xkb_keymap * extern struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *ctx); XkbcAllocKeyboard(struct xkb_context *ctx);

View File

@ -842,9 +842,8 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
darray_item(keymap->types, type).name); darray_item(keymap->types, type).name);
} }
} }
if (keymap->ctrls && if (keymap->explicit[key] & XkbExplicitAutoRepeatMask) {
(keymap->explicit[key] & XkbExplicitAutoRepeatMask)) { if (keymap->per_key_repeat[key / 8] & (1 << (key % 8)))
if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)))
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"\n\t\t\trepeat= Yes,"); "\n\t\t\trepeat= Yes,");
else else

View File

@ -357,5 +357,5 @@ err:
_X_EXPORT int _X_EXPORT int
xkb_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key) 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)));
} }

View File

@ -562,7 +562,7 @@ xkb_state_led_update_all(struct xkb_state *state)
state->leds |= (1 << led); state->leds |= (1 << led);
} }
else if (map->ctrls) { else if (map->ctrls) {
if ((map->ctrls & state->keymap->ctrls->enabled_ctrls)) if ((map->ctrls & state->keymap->enabled_ctrls))
state->leds |= (1 << led); state->leds |= (1 << led);
} }
} }

View File

@ -294,34 +294,33 @@ struct xkb_key_alias {
}; };
struct xkb_controls { struct xkb_controls {
/* unsigned char groups_wrap; */ unsigned char groups_wrap;
/* struct xkb_mods internal; */ struct xkb_mods internal;
/* struct xkb_mods ignore_lock; */ struct xkb_mods ignore_lock;
unsigned int enabled_ctrls; unsigned short repeat_delay;
/* unsigned short repeat_delay; */ unsigned short repeat_interval;
/* unsigned short repeat_interval; */ unsigned short slow_keys_delay;
/* unsigned short slow_keys_delay; */ unsigned short debounce_delay;
/* unsigned short debounce_delay; */ unsigned short ax_options;
/* unsigned short ax_options; */ unsigned short ax_timeout;
/* unsigned short ax_timeout; */ unsigned short axt_opts_mask;
/* unsigned short axt_opts_mask; */ unsigned short axt_opts_values;
/* unsigned short axt_opts_values; */ unsigned int axt_ctrls_mask;
/* unsigned int axt_ctrls_mask; */ unsigned int axt_ctrls_values;
/* unsigned int axt_ctrls_values; */
unsigned char *per_key_repeat;
}; };
/* Common keyboard description structure */ /* Common keyboard description structure */
struct xkb_keymap { 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 min_key_code;
xkb_keycode_t max_key_code; xkb_keycode_t max_key_code;
struct xkb_controls * ctrls;
/* key -> key name mapping */ /* key -> key name mapping */
darray(struct xkb_key_name) key_names; darray(struct xkb_key_name) key_names;
/* aliases in no particular order */ /* aliases in no particular order */
@ -355,6 +354,9 @@ struct xkb_keymap {
/* key -> behavior mapping */ /* key -> behavior mapping */
struct xkb_behavior *behaviors; struct xkb_behavior *behaviors;
/* key -> should repeat mapping - one bit per key */
unsigned char *per_key_repeat;
struct xkb_indicator_map indicators[XkbNumIndicators]; struct xkb_indicator_map indicators[XkbNumIndicators];
char *indicator_names[XkbNumIndicators]; char *indicator_names[XkbNumIndicators];

View File

@ -932,8 +932,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
if (group == 0 && level == 0) { if (group == 0 && level == 0) {
if (!(keymap->explicit[key] & XkbExplicitAutoRepeatMask) && if (!(keymap->explicit[key] & XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat)) (!interp || interp->flags & XkbSI_AutoRepeat))
keymap->ctrls->per_key_repeat[key / 8] |= keymap->per_key_repeat[key / 8] |= (1 << (key % 8));
(1 << (key % 8));
if (!(keymap->explicit[key] & XkbExplicitBehaviorMask) && if (!(keymap->explicit[key] & XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey)) interp && (interp->flags & XkbSI_LockingKey))
keymap->behaviors[key].type = XkbKB_Lock; keymap->behaviors[key].type = XkbKB_Lock;

View File

@ -1850,9 +1850,9 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
} }
if (key->repeat != RepeatUndefined) { if (key->repeat != RepeatUndefined) {
if (key->repeat == RepeatYes) if (key->repeat == RepeatYes)
keymap->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8)); keymap->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else else
keymap->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8)); keymap->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
keymap->explicit[kc] |= XkbExplicitAutoRepeatMask; keymap->explicit[kc] |= XkbExplicitAutoRepeatMask;
} }
@ -1942,11 +1942,9 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
if (!keymap->vmodmap) if (!keymap->vmodmap)
goto err_info; goto err_info;
if (XkbcAllocControls(keymap) != Success) { keymap->per_key_repeat = calloc(keymap->max_key_code / 8, 1);
WSGO("Could not allocate controls in CompileSymbols\n"); if (!keymap->per_key_repeat)
ACTION("Symbols not added\n");
goto err_info; goto err_info;
}
if (info.name) if (info.name)
keymap->symbols_section_name = strdup(info.name); keymap->symbols_section_name = strdup(info.name);