diff options
author | Ran Benita <ran234@gmail.com> | 2012-10-22 21:00:57 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2012-10-22 21:58:03 +0200 |
commit | 4b81c9f3e31a5128d4c9f55696f684948e5ad3f1 (patch) | |
tree | fb411faf3fbdd6eb0b996cab0e10f1f65fb3a735 /xkbcommon | |
parent | 550cb24d3c0a27815f7dd48324208baed72cb281 (diff) |
Report which components of the state have changed
We add a return value to the xkb_state_update_key and
xkb_state_update_mask, which reports to the caller which of the state
components have changed as a result.
This restores the XKB functionality of the XkbStateNotify and
XkbIndicatorsStateNotify events. See:
http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Events
It is quite useful in some situations. For example, it allows an
application to avoid doing some work if nothing of relevance in the
state has changed. Say, a keyboard layout applet. Also useful for
debugging.
The deltas themselves are not provided, because I can't see a use case.
If needed, it should be possible to add some API for that.
In xkbcommon, keymaps are immutable, so all of the other *Notify events
from XKB are irrelevant.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'xkbcommon')
-rw-r--r-- | xkbcommon/xkbcommon.h | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h index 846b619..e9b324f 100644 --- a/xkbcommon/xkbcommon.h +++ b/xkbcommon/xkbcommon.h @@ -965,14 +965,49 @@ enum xkb_key_direction { }; /** + * Modifier and layout types for state objects. This enum is bitmaskable, + * e.g. (XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED) is valid to + * exclude locked modifiers. + * + * In XKB, the DEPRESSED states are also known as 'base'. + */ +enum xkb_state_component { + /** Depressed modifiers, i.e. a key is physically holding them. */ + XKB_STATE_MODS_DEPRESSED = (1 << 0), + /** Latched modifiers, i.e. will be unset after the next non-modifier + * key press. */ + XKB_STATE_MODS_LATCHED = (1 << 1), + /** Locked modifiers, i.e. will be unset after the key provoking the + * lock has been pressed again. */ + XKB_STATE_MODS_LOCKED = (1 << 2), + /** Effective modifiers, i.e. currently active and affect key + * processing (derived from the other state components). */ + XKB_STATE_MODS_EFFECTIVE = (1 << 3), + /** Depressed layout, i.e. a key is physically holding it. */ + XKB_STATE_LAYOUT_DEPRESSED = (1 << 4), + /** Latched layout, i.e. will be unset after the next non-modifier + * key press. */ + XKB_STATE_LAYOUT_LATCHED = (1 << 5), + /** Locked layout, i.e. will be unset after the key provoking the lock + * has been pressed again. */ + XKB_STATE_LAYOUT_LOCKED = (1 << 6), + /** Effective layout, i.e. currently active and affects key processing + * (derived from the other state components). */ + XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7), + /** LEDs (derived from the other state components). */ + XKB_STATE_LEDS = (1 << 8), +}; + +/** * Update the keyboard state to reflect a given key being pressed or * released. * - * @todo Explain. + * @returns A mask of state components that have changed as a result of + * the update. If nothing in the state has changed, returns 0. * * @memberof xkb_state */ -void +enum xkb_state_component xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key, enum xkb_key_direction direction); @@ -1101,40 +1136,6 @@ xkb_keymap_key_get_syms_by_level(struct xkb_keymap *keymap, const xkb_keysym_t **syms_out); /** - * Modifier and layout types for state objects. This enum is bitmaskable, - * e.g. (XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED) is valid to - * exclude locked modifiers. - * - * In XKB, the DEPRESSED states are also known as 'base'. - */ -enum xkb_state_component { - /** Depressed modifiers, i.e. a key is physically holding them. */ - XKB_STATE_MODS_DEPRESSED = (1 << 0), - /** Latched modifiers, i.e. will be unset after the next non-modifier - * key press. */ - XKB_STATE_MODS_LATCHED = (1 << 1), - /** Locked modifiers, i.e. will be unset after the key provoking the - * lock has been pressed again. */ - XKB_STATE_MODS_LOCKED = (1 << 2), - /** Effective modifiers, i.e. currently active and affect key - * processing (derived from the other state components). */ - XKB_STATE_MODS_EFFECTIVE = (1 << 3), - /** Depressed layout, i.e. a key is physically holding it. */ - XKB_STATE_LAYOUT_DEPRESSED = (1 << 4), - /** Latched layout, i.e. will be unset after the next non-modifier - * key press. */ - XKB_STATE_LAYOUT_LATCHED = (1 << 5), - /** Locked layout, i.e. will be unset after the key provoking the lock - * has been pressed again. */ - XKB_STATE_LAYOUT_LOCKED = (1 << 6), - /** Effective layout, i.e. currently active and affects key processing - * (derived from the other state components). */ - XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7), - /** LEDs (derived from the other state components). */ - XKB_STATE_LEDS = (1 << 8), -}; - -/** * Match flags for xkb_state_mod_indices_are_active and * xkb_state_mod_names_are_active, specifying how the conditions for a * successful match. XKB_STATE_MATCH_NON_EXCLUSIVE is bitmaskable with @@ -1167,11 +1168,16 @@ enum xkb_state_match { * * Please do not use this unless you fit the description above. * + * @returns A mask of state components that have changed as a result of + * the update. If nothing in the state has changed, returns 0. + * * @memberof xkb_state */ -void -xkb_state_update_mask(struct xkb_state *state, xkb_mod_mask_t base_mods, - xkb_mod_mask_t latched_mods, xkb_mod_mask_t locked_mods, +enum xkb_state_component +xkb_state_update_mask(struct xkb_state *state, + xkb_mod_mask_t base_mods, + xkb_mod_mask_t latched_mods, + xkb_mod_mask_t locked_mods, xkb_layout_index_t base_layout, xkb_layout_index_t latched_layout, xkb_layout_index_t locked_layout); |