summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
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