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);
}
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);
}

View File

@ -29,9 +29,6 @@
#include "xkb-priv.h"
extern int
XkbcAllocControls(struct xkb_keymap *keymap);
extern struct xkb_keymap *
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);
}
}
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

View File

@ -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)));
}

View File

@ -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);
}
}

View File

@ -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];

View File

@ -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;

View File

@ -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);