Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlays #514

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion include/xkbcommon/xkbcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,15 @@ enum xkb_state_component {
* Use this unless you explicitly care how the state came about. */
XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7),
/** LEDs (derived from the other state components). */
XKB_STATE_LEDS = (1 << 8)
XKB_STATE_LEDS = (1 << 8),
/** TODO: doc */
XKB_STATE_OVERLAYS_SET = (1 << 9),
/** TODO: doc */
XKB_STATE_OVERLAYS_LOCKED = (1 << 10),
/** TODO: doc */
XKB_STATE_OVERLAYS_EFFECTIVE = (1 << 11),
/** TODO: doc */
XKB_STATE_OVERLAID_KEYS = (1 << 12),
};

/**
Expand Down Expand Up @@ -1502,6 +1510,9 @@ xkb_state_update_mask(struct xkb_state *state,
xkb_layout_index_t latched_layout,
xkb_layout_index_t locked_layout);

xkb_keycode_t
xkb_state_key_get_overlay_keycode(struct xkb_state *state, xkb_keycode_t kc);

/**
* Get the keysyms obtained from pressing a particular key in a given
* keyboard state.
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ libxkbcommon_sources = [
'src/messages-codes.h',
'src/scanner-utils.h',
'src/state.c',
'src/state.h',
'src/text.c',
'src/text.h',
'src/utf8.c',
Expand Down
4 changes: 4 additions & 0 deletions src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ xkb_keymap_unref(struct xkb_keymap *keymap)
}
free(key->groups);
}
if (key->overlays) {
free(key->overlays);
}
}
free(keymap->keys);
}
Expand All @@ -92,6 +95,7 @@ xkb_keymap_unref(struct xkb_keymap *keymap)
}
free(keymap->types);
}
free(keymap->incompatible_overlays);
free(keymap->sym_interprets);
free(keymap->key_aliases);
free(keymap->group_names);
Expand Down
21 changes: 20 additions & 1 deletion src/keymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ enum mod_type {
};
#define MOD_REAL_MASK_ALL ((xkb_mod_mask_t) 0x000000ff)

/* TODO: doc */
#define XKB_MAX_OVERLAYS 8

#if XKB_MAX_OVERLAYS > 8
#error "Cannot store overlays indexes"
#endif
typedef uint8_t xkb_overlay_index_t;
typedef uint8_t xkb_overlay_mask_t;

enum xkb_action_type {
ACTION_TYPE_NONE = 0,
ACTION_TYPE_MOD_SET,
Expand Down Expand Up @@ -165,11 +174,15 @@ enum xkb_action_controls {
CONTROL_AX_FEEDBACK = (1 << 8),
CONTROL_BELL = (1 << 9),
CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
#define _CONTROL_OVERLAY1_LOG2 11
#define CONTROL_OVERLAYS (CONTROL_OVERLAY1 | CONTROL_OVERLAY2)
CONTROL_OVERLAY1 = (1 << 11),
CONTROL_OVERLAY2 = (1 << 12),
CONTROL_ALL = \
(CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
CONTROL_IGNORE_GROUP_LOCK)
CONTROL_IGNORE_GROUP_LOCK | CONTROL_OVERLAY1 | CONTROL_OVERLAY2)
};

enum xkb_match_operation {
Expand Down Expand Up @@ -201,6 +214,7 @@ struct xkb_controls_action {
enum xkb_action_type type;
enum xkb_action_flags flags;
enum xkb_action_controls ctrls;
xkb_overlay_mask_t overlays;
};

struct xkb_pointer_default_action {
Expand Down Expand Up @@ -336,6 +350,9 @@ struct xkb_key {
xkb_keycode_t keycode;
xkb_atom_t name;

xkb_overlay_mask_t overlays_mask;
xkb_keycode_t *overlays;

enum xkb_explicit_components explicit;

xkb_mod_mask_t modmap;
Expand Down Expand Up @@ -370,6 +387,8 @@ struct xkb_keymap {
enum xkb_keymap_format format;

enum xkb_action_controls enabled_ctrls;
xkb_overlay_index_t num_overlays;
xkb_overlay_mask_t *incompatible_overlays;

xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code;
Expand Down
Loading