diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 18 | ||||
-rw-r--r-- | src/data.h | 4 | ||||
-rw-r--r-- | src/input.c | 18 | ||||
-rw-r--r-- | src/input.h | 2 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/manage.c | 17 |
6 files changed, 48 insertions, 15 deletions
diff --git a/src/actions.c b/src/actions.c index cb80a4c..8a004d9 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2340,9 +2340,8 @@ set_font (char *data) { XFontStruct *font; - /* FIXME: return a useful string. */ if (data == NULL) - return xstrdup ("dummy"); + return xstrdup (defaults.font_string); font = XLoadQueryFont (dpy, data); if (font == NULL) @@ -2356,6 +2355,9 @@ set_font (char *data) defaults.font = font; update_all_gcs(); + free (defaults.font_string); + defaults.font_string = xstrdup (data); + return NULL; } @@ -2559,9 +2561,8 @@ set_fgcolor (char *data) int i; XColor color, junk; - /* FIXME: return a meaningful string. */ if (data == NULL) - return xstrdup ("dummy"); + return xstrdup (defaults.fgcolor_string); for (i=0; i<num_screens; i++) { @@ -2577,6 +2578,9 @@ set_fgcolor (char *data) XSetWindowBorder (dpy, screens[i].input_window, color.pixel); XSetWindowBorder (dpy, screens[i].frame_window, color.pixel); XSetWindowBorder (dpy, screens[i].help_window, color.pixel); + + free (defaults.fgcolor_string); + defaults.fgcolor_string = xstrdup (data); } return NULL; @@ -2588,9 +2592,8 @@ set_bgcolor (char *data) int i; XColor color, junk; - /* FIXME: return a meaningful string. */ if (data == NULL) - return xstrdup ("dummy"); + return xstrdup (defaults.bgcolor_string); for (i=0; i<num_screens; i++) { @@ -2606,6 +2609,9 @@ set_bgcolor (char *data) XSetWindowBackground (dpy, screens[i].input_window, color.pixel); XSetWindowBackground (dpy, screens[i].frame_window, color.pixel); XSetWindowBackground (dpy, screens[i].help_window, color.pixel); + + free (defaults.bgcolor_string); + defaults.bgcolor_string = xstrdup (data); } return NULL; @@ -213,6 +213,10 @@ struct rp_defaults int padding_bottom; XFontStruct *font; + char *font_string; + + char *fgcolor_string; + char *bgcolor_string; int wait_for_key_cursor; diff --git a/src/input.c b/src/input.c index 5b94c78..3b8a954 100644 --- a/src/input.c +++ b/src/input.c @@ -164,14 +164,26 @@ update_modifier_map () /* Grab the key while ignoring annoying modifier keys including caps lock, num lock, and scroll lock. */ void -grab_key (int keycode, unsigned int modifiers, Window grab_window) +grab_key (KeySym keysym, unsigned int modifiers, Window grab_window) { + int keycode; unsigned int mod_list[8]; int i; - + KeySym upper, lower; + /* 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; + } + /* Create a list of all possible combinations of ignored modifiers. Assumes there are only 3 ignored modifiers. */ mod_list[0] = 0; @@ -183,6 +195,8 @@ grab_key (int keycode, 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++) { diff --git a/src/input.h b/src/input.h index f8703e3..149979f 100644 --- a/src/input.h +++ b/src/input.h @@ -30,7 +30,7 @@ int read_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int le unsigned int x11_mask_to_rp_mask (unsigned int mask); unsigned int rp_mask_to_x11_mask (unsigned int mask); void update_modifier_map (); -void grab_key (int keycode, unsigned int modifiers, Window grab_window); +void grab_key (KeySym keysym, unsigned int modifiers, Window grab_window); void ring_bell (); @@ -483,6 +483,10 @@ init_defaults () fprintf (stderr, "ratpoison: Cannot load font %s.\n", "9x15bold"); exit (EXIT_FAILURE); } + defaults.font_string = xstrdup ("9x15bold"); + + defaults.fgcolor_string = xstrdup ("black"); + defaults.bgcolor_string = xstrdup ("white"); defaults.wait_for_key_cursor = 1; diff --git a/src/manage.c b/src/manage.c index 46e174e..b11dc4a 100644 --- a/src/manage.c +++ b/src/manage.c @@ -122,7 +122,7 @@ grab_top_level_keys (Window w) for (i=0; i<map->actions_last; i++) { PRINT_DEBUG(("%d\n", i)); - grab_key (XKeysymToKeycode (dpy, map->actions[i].key), map->actions[i].state, w); + grab_key (map->actions[i].key, map->actions[i].state, w); } #endif } @@ -130,23 +130,28 @@ grab_top_level_keys (Window w) void ungrab_top_level_keys (Window w) { -#ifdef HIDE_MOUSE -#else - rp_keymap *map = find_keymap (TOP_KEYMAP); + KeySym keysym, upper, lower; + rp_keymap *map; int i; + map = find_keymap (TOP_KEYMAP); + if (map == NULL) { PRINT_ERROR (("Unable to find " TOP_KEYMAP " keymap\n")); return; } + /* Make sure we ungrab the right sym. */ + for (i=0; i<map->actions_last; i++) { PRINT_DEBUG(("%d\n", i)); - XUngrabKey(dpy, XKeysymToKeycode (dpy, map->actions[i].key), AnyModifier, w); + keysym = map->actions[i].key; + XConvertCase (keysym, &lower, &upper); + keysym = lower; + XUngrabKey(dpy, XKeysymToKeycode (dpy, keysym), AnyModifier, w); } -#endif } void |