Commit b3f2396588a1e5f3f7570b0344eb7c43702d439b

Ran Benita 2014-02-06T01:48:32

keysym: add function to test if a keysym is for a modifier Needed for compose. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/keysym.c b/src/keysym.c
index 6f2075c..db0e973 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -223,6 +223,18 @@ xkb_keysym_is_keypad(xkb_keysym_t keysym)
     return keysym >= XKB_KEY_KP_Space && keysym <= XKB_KEY_KP_Equal;
 }
 
+
+bool
+xkb_keysym_is_modifier(xkb_keysym_t keysym)
+{
+    return
+        (keysym >= XKB_KEY_Shift_L && keysym <= XKB_KEY_Hyper_R) ||
+        /* libX11 only goes upto XKB_KEY_ISO_Level5_Lock. */
+        (keysym >= XKB_KEY_ISO_Lock && keysym <= XKB_KEY_ISO_Last_Group_Lock) ||
+        keysym == XKB_KEY_Mode_switch ||
+        keysym == XKB_KEY_Num_Lock;
+}
+
 static void
 XConvertCase(xkb_keysym_t sym, xkb_keysym_t *lower, xkb_keysym_t *upper);
 
diff --git a/src/keysym.h b/src/keysym.h
index e9374dc..ca2bd5e 100644
--- a/src/keysym.h
+++ b/src/keysym.h
@@ -59,6 +59,9 @@ xkb_keysym_is_upper(xkb_keysym_t keysym);
 bool
 xkb_keysym_is_keypad(xkb_keysym_t keysym);
 
+bool
+xkb_keysym_is_modifier(xkb_keysym_t keysym);
+
 xkb_keysym_t
 xkb_keysym_to_upper(xkb_keysym_t ks);