Add xkb_get_syms_by_level Which allows you to pass in a group and a level rather than a fully-formed state. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/src/map.c b/src/map.c
index beabbe6..c54f227 100644
--- a/src/map.c
+++ b/src/map.c
@@ -55,6 +55,7 @@
#include "xkbcommon/xkbcommon.h"
#include "XKBcommonint.h"
+#include "xkballoc.h"
#include <X11/X.h>
/**
@@ -119,6 +120,24 @@ xkb_key_get_group(struct xkb_desc *xkb, struct xkb_state *state,
}
/**
+ * As below, but takes an explicit group/level rather than state.
+ */
+unsigned int
+xkb_key_get_syms_by_level(struct xkb_desc *xkb, xkb_keycode_t key, unsigned int group,
+ unsigned int level, xkb_keysym_t **syms_out)
+{
+ *syms_out = &(XkbKeySymEntry(xkb, key, level, group));
+ if (**syms_out == NoSymbol)
+ goto err;
+
+ return 1;
+
+err:
+ *syms_out = NULL;
+ return 0;
+}
+
+/**
* Provides the symbols to use for the given key and state. Returns the
* number of symbols pointed to in syms_out.
*/
@@ -139,11 +158,7 @@ xkb_key_get_syms(struct xkb_desc *xkb, struct xkb_state *state,
if (level == -1)
goto err;
- *syms_out = &(XkbKeySymEntry(xkb, key, level, group));
- if (**syms_out == NoSymbol)
- goto err;
-
- return 1;
+ return xkb_key_get_syms_by_level(xkb, key, group, level, syms_out);
err:
*syms_out = NULL;
diff --git a/src/xkballoc.h b/src/xkballoc.h
index f5f3919..83f7857 100644
--- a/src/xkballoc.h
+++ b/src/xkballoc.h
@@ -72,4 +72,9 @@ XkbcFreeClientMap(struct xkb_desc * xkb);
extern void
XkbcFreeServerMap(struct xkb_desc * xkb);
+extern unsigned int
+xkb_key_get_syms_by_level(struct xkb_desc *xkb, xkb_keycode_t key,
+ unsigned int group, unsigned int level,
+ xkb_keysym_t **syms_out);
+
#endif /* _XKBALLOC_H_ */