From 6a94b122a4dde3e8f59d69f9a388e9a77c343326 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 22 Oct 2012 20:49:44 +0200 Subject: Split the mods, layout, leds parts of xkb_state_components Note first: This commits breaks the ABI somewhat. If an application is run against this commit without recompiling against the updated header, these break: - xkb_state_layout_*_is_active always retuns false. - xkb_state_serialize_mods always returns 0. So it might break layout switching in some applications. However, xkbcommon-compat.h provides the necessary fixes, so recompiling should work (though updating the application is even better). Split the enum to its individual components, which enables us to refer to them individually. We will use that later for reporting which components of the state have changed after update. Signed-off-by: Ran Benita --- xkbcommon/xkbcommon-compat.h | 10 ++++++ xkbcommon/xkbcommon.h | 78 +++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 23 deletions(-) (limited to 'xkbcommon') diff --git a/xkbcommon/xkbcommon-compat.h b/xkbcommon/xkbcommon-compat.h index 0142bca..f96e4c8 100644 --- a/xkbcommon/xkbcommon-compat.h +++ b/xkbcommon/xkbcommon-compat.h @@ -34,6 +34,16 @@ #define xkb_map_compile_flags xkb_keymap_compile_flags #define XKB_GROUP_INVALID XKB_LAYOUT_INVALID +#define XKB_STATE_DEPRESSED \ + (XKB_STATE_MODS_DEPRESSED | XKB_STATE_LAYOUT_DEPRESSED) +#define XKB_STATE_LATCHED \ + (XKB_STATE_MODS_LATCHED | XKB_STATE_LAYOUT_LATCHED) +#define XKB_STATE_LOCKED \ + (XKB_STATE_MODS_LOCKED | XKB_STATE_LAYOUT_LOCKED) +#define XKB_STATE_EFFECTIVE \ + (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED | \ + XKB_STATE_MODS_EFFECTIVE | XKB_STATE_LAYOUT_EFFECTIVE) + #define xkb_map_new_from_names(context, names, flags) \ xkb_keymap_new_from_names(context, names, flags) #define xkb_map_new_from_file(context, file, format, flags) \ diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h index 6387f92..846b619 100644 --- a/xkbcommon/xkbcommon.h +++ b/xkbcommon/xkbcommon.h @@ -1102,22 +1102,36 @@ xkb_keymap_key_get_syms_by_level(struct xkb_keymap *keymap, /** * Modifier and layout types for state objects. This enum is bitmaskable, - * e.g. (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED) is valid to exclude - * locked modifiers. + * 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 { - /** A key holding this modifier or layout is currently physically - * depressed; also known as 'base'. */ - XKB_STATE_DEPRESSED = (1 << 0), - /** Modifier or layout is latched, i.e. will be unset after the next - * non-modifier key press. */ - XKB_STATE_LATCHED = (1 << 1), - /** Modifier or layout is locked, i.e. will be unset after the key - * provoking the lock has been pressed again. */ - XKB_STATE_LOCKED = (1 << 2), - /** Combinatination of depressed, latched, and locked. */ - XKB_STATE_EFFECTIVE = - (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED), + /** 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), }; /** @@ -1163,30 +1177,48 @@ xkb_state_update_mask(struct xkb_state *state, xkb_mod_mask_t base_mods, xkb_layout_index_t locked_layout); /** - * The counterpart to xkb_state_update_mask, to be used on the server side - * of serialization. + * The counterpart to xkb_state_update_mask for modifiers, to be used on + * the server side of serialization. * - * @returns A xkb_mod_mask_t representing the given component(s) of the - * state. + * @param state The keyboard state. + * @param components A mask of the modifier state components to serialize. + * State components other than XKB_STATE_MODS_* are ignored. + * If XKB_STATE_MODS_EFFECTIVE is included, all other state components are + * ignored. + * + * @returns A xkb_mod_mask_t representing the given components of the + * modifier state. * * This function should not be used in regular clients; please use the - * xkb_state_mod_*_is_active or xkb_state_foreach_active_mod API instead. + * xkb_state_mod_*_is_active API instead. * * @memberof xkb_state */ xkb_mod_mask_t xkb_state_serialize_mods(struct xkb_state *state, - enum xkb_state_component component); + enum xkb_state_component components); /** - * The layout equivalent of xkb_state_serialize_mods. + * The counterpart to xkb_state_update_mask for layouts, to be used on + * the server side of serialization. + * + * @param state The keyboard state. + * @param components A mask of the layout state components to serialize. + * State components other than XKB_STATE_LAYOUT_* are ignored. + * If XKB_STATE_LAYOUT_EFFECTIVE is included, all other state components are + * ignored. + * + * @returns A xkb_layout_mask_t representing the given components of the + * layout state. + * + * This function should not be used in regular clients; please use the + * xkb_state_layout_*_is_active API instead. * - * @sa xkb_state_serialize_mods * @memberof xkb_state */ xkb_layout_index_t xkb_state_serialize_layout(struct xkb_state *state, - enum xkb_state_component component); + enum xkb_state_component components); /** * Test whether a modifier is active in a given keyboard state by name. -- cgit v1.2.3