keysym: add function to test if a keysym is for a modifier Needed for compose. Signed-off-by: Ran Benita <ran234@gmail.com>
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
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);