diff options
author | Ran Benita <ran234@gmail.com> | 2012-09-23 17:52:51 +0200 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2012-09-24 09:13:32 +1000 |
commit | 9a18b87251d1111987e98926a9aba9e72afc0259 (patch) | |
tree | 459f2e0b34c7ae96d030c395e1bfcb5aa93bf54d /xkbcommon | |
parent | 5d31b9e3e706df2256295d5c92b74935d1e9fbcd (diff) |
Add format argument to xkb_keymap_get_as_string
This function really needs a format argument, for symmetry with the
keymap creation functions. If we add new formats, we will almost
certainly want to add support for serializing it into a string. It would
also allow to convert from one format to another, etc.
The in the common case, the user would just want to use the format she
used to create the keymap; for that we add a special
XKB_KEYMAP_USE_ORIGINAL_FORMAT value, which will do that (it is defined
to -1 outside of the enum because I have a feeling we might want to use
0 for something else). To support this we need to keep the format inside
the keymap. While we're at it we also initialize keymap flags properly.
This changes the API, but the old xkb_map_get_as_string name works as
expected so this is the best time to do this.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'xkbcommon')
-rw-r--r-- | xkbcommon/xkbcommon-compat.h | 3 | ||||
-rw-r--r-- | xkbcommon/xkbcommon.h | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/xkbcommon/xkbcommon-compat.h b/xkbcommon/xkbcommon-compat.h index 2cd764f..0142bca 100644 --- a/xkbcommon/xkbcommon-compat.h +++ b/xkbcommon/xkbcommon-compat.h @@ -40,7 +40,8 @@ xkb_keymap_new_from_file(context, file, format, flags) #define xkb_map_new_from_string(context, string, format, flags) \ xkb_keymap_new_from_string(context, string, format, flags) -#define xkb_map_get_as_string(keymap) xkb_keymap_get_as_string(keymap) +#define xkb_map_get_as_string(keymap) \ + xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1) #define xkb_map_ref(keymap) xkb_keymap_ref(keymap) #define xkb_map_unref(keymap) xkb_keymap_unref(keymap) diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h index a26744c..1049ca5 100644 --- a/xkbcommon/xkbcommon.h +++ b/xkbcommon/xkbcommon.h @@ -558,11 +558,18 @@ xkb_keymap_ref(struct xkb_keymap *keymap); void xkb_keymap_unref(struct xkb_keymap *keymap); +/* See xkb_keymap_get_as_string(). */ +#define XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1) + /** * @brief Get the compiled keymap as a string. * - * @returns The compiled keymap as a NUL-terminated string, or NULL if - * unsuccessful. + * @param keymap The keymap to get as a string. + * @param format The keymap format to use for the string. You can pass + * in the special value XKB_KEYMAP_USE_ORIGINAL_FORMAT to use the format + * from which the keymap was originally created. + * + * @returns The keymap as a NUL-terminated string, or NULL if unsuccessful. * * The returned string may be fed back into xkb_map_new_from_string() to get * the exact same keymap (possibly in another process, etc.). @@ -571,7 +578,8 @@ xkb_keymap_unref(struct xkb_keymap *keymap); * by the caller. */ char * -xkb_keymap_get_as_string(struct xkb_keymap *keymap); +xkb_keymap_get_as_string(struct xkb_keymap *keymap, + enum xkb_keymap_format format); /** @} */ |