summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2004-05-05 18:42:09 +0000
committersabetts <sabetts>2004-05-05 18:42:09 +0000
commit51a77419c1ba6470bcfe1144e3150835d432c512 (patch)
tree4d4da655e1fdb48c83493907d5d3a8c203bc6c6c /src
parentc9303ecfb30db08b3cc12137831ab352ac9b0812 (diff)
downloadratpoison-51a77419c1ba6470bcfe1144e3150835d432c512.zip
(grab_key): use keysym_to_keycode_mod to get the
keycode and modifier for the keysym. (keysym_to_keycode_mod): new function
Diffstat (limited to 'src')
-rw-r--r--src/input.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/input.c b/src/input.c
index 3b8a954..92f7b07 100644
--- a/src/input.c
+++ b/src/input.c
@@ -161,28 +161,37 @@ update_modifier_map ()
XFreeModifiermap (mods);
}
+/* we need a keycode + modifier to generate the proper keysym (such as
+ @). */
+static void
+keysym_to_keycode_mod (KeySym keysym, KeyCode *code, unsigned int *mod)
+{
+ KeySym lower, upper;
+
+ *mod = 0;
+ *code = XKeysymToKeycode (dpy, keysym);
+ lower = XKeycodeToKeysym (dpy, *code, 0);
+ upper = XKeycodeToKeysym (dpy, *code, 1);
+ if (upper == keysym)
+ *mod = ShiftMask;
+}
+
/* Grab the key while ignoring annoying modifier keys including
caps lock, num lock, and scroll lock. */
void
grab_key (KeySym keysym, unsigned int modifiers, Window grab_window)
{
- int keycode;
unsigned int mod_list[8];
int i;
KeySym upper, lower;
+ KeyCode keycode;
+ unsigned int mod;
/* Convert to a modifier mask that X Windows will understand. */
modifiers = rp_mask_to_x11_mask (modifiers);
-
- /* Make sure we grab the right sym. */
- XConvertCase (keysym, &lower, &upper);
- PRINT_DEBUG(("%ld %ld %ld", keysym, lower, upper));
- if (keysym != upper || keysym != lower)
- {
- if (keysym == upper)
- modifiers |= ShiftMask;
- keysym = lower;
- }
+ keysym_to_keycode_mod (keysym, &keycode, &mod);
+ PRINT_DEBUG (("keycode_mod: %ld %d %d\n", keysym, keycode, mod));
+ modifiers |= mod;
/* Create a list of all possible combinations of ignored
modifiers. Assumes there are only 3 ignored modifiers. */
@@ -195,8 +204,6 @@ grab_key (KeySym keysym, unsigned int modifiers, Window grab_window)
mod_list[6] = mod_list[2] | mod_list[4];
mod_list[7] = mod_list[1] | mod_list[2] | mod_list[4];
- keycode = XKeysymToKeycode (dpy, keysym);
-
/* Grab every combination of ignored modifiers. */
for (i=0; i<8; i++)
{