summaryrefslogtreecommitdiff
path: root/xkbcommon
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2012-10-16 16:05:34 +0200
committerRan Benita <ran234@gmail.com>2012-10-16 21:29:09 +0200
commit7b3bd11f92f0bed76f25eab8c79c0eca21e037bc (patch)
tree006662df88956808da70985418e1e0f8025a298a /xkbcommon
parent5fff637e07d75b24f778210e7838ee9667810806 (diff)
Add xkb_keysym_from_name() flags argument for case-insensitive search
This adds a flags argument to xkb_keysym_from_name() so we can perform a case-insensitive search. This should really be supported as many keysyms have really weird capitalization-rules. However, as this may produce conflicts, users must be warned to only use this for fallback paths or error-recovery. This is also the reason why the internal XKB parsers still use the case-sensitive search. This also adds some test-cases so the expected results are really produced. The binary-size does _not_ change with this patch. However, case-sensitive search may be slightly slower with this patch. But this is barely measurable. [ran: use bool instead of int for icase, add a recommendation to the doc, and test a couple "thorny" cases.] Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Diffstat (limited to 'xkbcommon')
-rw-r--r--xkbcommon/xkbcommon.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index 5d6a295..ddc715c 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -319,18 +319,34 @@ struct xkb_rule_names {
int
xkb_keysym_get_name(xkb_keysym_t keysym, char *buffer, size_t size);
+/** Flags for xkb_keysym_from_name(). */
+enum xkb_keysym_flags {
+ /** Find keysym by case-insensitive search. */
+ XKB_KEYSYM_CASE_INSENSITIVE = (1 << 0),
+};
+
/**
* Get a keysym from its name.
*
* @param name The name of a keysym. See remarks in xkb_keysym_get_name();
* this function will accept any name returned by that function.
+ * @param flags A set of flags controlling how the search is done. If
+ * invalid flags are passed, this will fail with XKB_KEY_NoSymbol.
+ *
+ * If you use the XKB_KEYSYM_CASE_INSENSITIVE flag and two keysym names
+ * differ only by case, then the lower-case keysym is returned. For
+ * instance, for KEY_a and KEY_A, this function would return KEY_a for the
+ * case-insensitive search. If this functionality is needed, it is
+ * recommended to first call this function without this flag; and if that
+ * fails, only then to try with this flag, while possibly warning the user
+ * he had misspelled the name, and might get wrong results.
*
* @returns The keysym. If the name is invalid, returns XKB_KEY_NoSymbol.
*
* @sa xkb_keysym_t
*/
xkb_keysym_t
-xkb_keysym_from_name(const char *name);
+xkb_keysym_from_name(const char *name, enum xkb_keysym_flags flags);
/**
* Get the Unicode/UTF-8 representation of a keysym.