summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-19 06:47:42 +0000
committersabetts <sabetts>2001-04-19 06:47:42 +0000
commit9901676e3cd622efe29dbabcde0872de9d2be310 (patch)
tree6cd2c20695c78888539d9a56e8cb6625484bedb2 /src/input.c
parentc10e6d6fce6d4007e1ae75509921573173416888 (diff)
downloadratpoison-9901676e3cd622efe29dbabcde0872de9d2be310.zip
* src/input.c (keysym_to_string): handles control, meta, alt,
hyper, and super modifiers. Returns full keysym names. * src/actions.c (parse_keydesc): parses control, meta, alt, hyper, and super modifiers. (cmd_clock): sets the last character in msg to 0.
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/input.c b/src/input.c
index d64135f..1818f5d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -115,33 +115,24 @@ init_modifier_map ()
char *
keysym_to_string (KeySym keysym, unsigned int modifier)
{
- const unsigned int mod_table[] = {ControlMask,
- Mod1Mask,
- Mod2Mask,
- Mod3Mask,
- Mod4Mask,
- Mod5Mask};
- const unsigned char str_table[] = "CM2345";
+ struct sbuf *name;
+ char *tmp;
- unsigned char *name;
- int pos, i;
+ name = sbuf_new (0);
- name = xmalloc (15);
+ if (modifier & ControlMask) sbuf_concat (name, "C-");
+ if (modifier & rp_modifier_info.meta_mod_mask) sbuf_concat (name, "M-");
+ if (modifier & rp_modifier_info.alt_mod_mask) sbuf_concat (name, "A-");
+ if (modifier & rp_modifier_info.hyper_mod_mask) sbuf_concat (name, "H-");
+ if (modifier & rp_modifier_info.super_mod_mask) sbuf_concat (name, "S-");
+
+ sbuf_concat (name, XKeysymToString (keysym));
- for (pos = 0, i = 0; i < 6; i++)
- {
- if (modifier & mod_table[i])
- {
- name[pos] = str_table[i];
- name[pos+1] = '-';
- pos += 2;
- }
- }
-
- name[pos] = keysym;
- name[pos+1] = '\0';
+ /* Eat the nut and throw away the shells. */
+ tmp = sbuf_get (name);
+ free (name);
- return name;
+ return tmp;
}
/* Cooks a keycode + modifier into a keysym + modifier. This should be