summaryrefslogtreecommitdiff
path: root/src/keymap.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-03-01 21:48:02 +0200
committerDaniel Stone <daniel@fooishbar.org>2013-03-18 22:20:04 +0000
commit14842d6dc911db0a30afff8c75a89d34390de2e9 (patch)
tree3c7f9c19241564107db14e6251c49aa5d0d32401 /src/keymap.h
parentd1eae42ac58a334c5d299ef66342957deae4cd78 (diff)
downloadxorg-lib-libxkbcommon-14842d6dc911db0a30afff8c75a89d34390de2e9.tar.gz
keymap: abstract a bit over the keymap format
Make it a bit easier to experiment with other formats. Add a struct xkb_keymap_format_operations, which currently contains the keymap compilation and _get_as_string functions. Each format can implement whatever it wants from these. The current public entry points become wrappers which do some error reporting, allocation etc., and calling to the specific format. The wrappers are all moved to src/keymap.c, so there are no XKB_EXPORT's under src/xkbcomp/ anymore. The only format available now is normal text_v1. This is all not very KISS, and adds some indirection, but it is helpful and somewhat cleaner. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/keymap.h')
-rw-r--r--src/keymap.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/keymap.h b/src/keymap.h
index 1744b41..30733bf 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -78,8 +78,8 @@
* Dan Nicholson <dbn.lists@gmail.com>
*/
-#ifndef MAP_H
-#define MAP_H
+#ifndef KEYMAP_H
+#define KEYMAP_H
/* Don't use compat names in internal code. */
#define _XKBCOMMON_COMPAT_H
@@ -422,15 +422,21 @@ XkbKeyGroupWidth(const struct xkb_key *key, xkb_layout_index_t layout)
return key->groups[layout].type->num_levels;
}
-struct xkb_keymap *
-xkb_keymap_new(struct xkb_context *ctx,
- enum xkb_keymap_format format,
- enum xkb_keymap_compile_flags);
-
xkb_layout_index_t
wrap_group_into_range(int32_t group,
xkb_layout_index_t num_groups,
enum xkb_range_exceed_type out_of_range_group_action,
xkb_layout_index_t out_of_range_group_number);
+struct xkb_keymap_format_ops {
+ bool (*keymap_new_from_names)(struct xkb_keymap *keymap,
+ const struct xkb_rule_names *names);
+ bool (*keymap_new_from_string)(struct xkb_keymap *keymap,
+ const char *string);
+ bool (*keymap_new_from_file)(struct xkb_keymap *keymap, FILE *file);
+ char *(*keymap_get_as_string)(struct xkb_keymap *keymap);
+};
+
+extern const struct xkb_keymap_format_ops text_v1_keymap_format_ops;
+
#endif