diff options
author | Kipling Inscore <k@bijna.net> | 2008-08-03 11:40:42 -0700 |
---|---|---|
committer | Shawn <sabetts@juicebox.(none)> | 2008-10-10 13:07:47 -0700 |
commit | 497fb323835bbb3cceb39874e7555b565863c7e8 (patch) | |
tree | 5d2e5495b879cd1e4dfbbbd0b8913685adf86d55 /src | |
parent | b47008536843fe9dfa5790581228f42d5c83ee80 (diff) | |
download | ratpoison-497fb323835bbb3cceb39874e7555b565863c7e8.zip |
allow window border color to be set seperately for focused and unfocused windows
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 66 | ||||
-rw-r--r-- | src/data.h | 4 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/split.c | 5 | ||||
-rw-r--r-- | src/window.c | 7 |
6 files changed, 82 insertions, 4 deletions
diff --git a/src/actions.c b/src/actions.c index 4365679..0a1f4f1 100644 --- a/src/actions.c +++ b/src/actions.c @@ -64,6 +64,8 @@ static cmdret * set_winname (struct cmdarg **args); static cmdret * set_framefmt (struct cmdarg **args); static cmdret * set_fgcolor (struct cmdarg **args); static cmdret * set_bgcolor (struct cmdarg **args); +static cmdret * set_fwcolor (struct cmdarg **args); +static cmdret * set_bwcolor (struct cmdarg **args); static cmdret * set_barpadding (struct cmdarg **args); static cmdret * set_winliststyle (struct cmdarg **args); static cmdret * set_framesels (struct cmdarg **args); @@ -129,6 +131,8 @@ init_set_vars(void) add_set_var ("framefmt", set_framefmt, 1, "", arg_REST); add_set_var ("fgcolor", set_fgcolor, 1, "", arg_STRING); add_set_var ("bgcolor", set_bgcolor, 1, "", arg_STRING); + add_set_var ("fwcolor", set_fwcolor, 1, "", arg_STRING); + add_set_var ("bwcolor", set_bwcolor, 1, "", arg_STRING); add_set_var ("barpadding", set_barpadding, 2, "", arg_NUMBER, "", arg_NUMBER); add_set_var ("winliststyle", set_winliststyle, 1, "", arg_STRING); add_set_var ("framesels", set_framesels, 1, "", arg_STRING); @@ -3894,6 +3898,68 @@ set_bgcolor (struct cmdarg **args) return cmdret_new (RET_SUCCESS, NULL); } +static cmdret * +set_fwcolor (struct cmdarg **args) +{ + int i; + XColor color, junk; + rp_window *win = current_window(); + + if (args[0] == NULL) + return cmdret_new (RET_SUCCESS, "%s", defaults.fwcolor_string); + + for (i=0; i<num_screens; i++) + { + if (!XAllocNamedColor (dpy, screens[i].def_cmap, ARG_STRING(0), &color, &junk)) + return cmdret_new (RET_FAILURE, "deffwcolor: unknown color"); + + screens[i].fw_color = color.pixel; + update_gc (&screens[i]); + + free (defaults.fwcolor_string); + defaults.fwcolor_string = xstrdup (ARG_STRING(0)); + } + + /* Update current window. */ + if (win != NULL) + XSetWindowBorder (dpy, win->w, win->scr->fw_color); + + return cmdret_new (RET_SUCCESS, NULL); +} + +static cmdret * +set_bwcolor (struct cmdarg **args) +{ + int i; + XColor color, junk; + rp_window *win, *cur = current_window(); + + if (args[0] == NULL) + return cmdret_new (RET_SUCCESS, "%s", defaults.bwcolor_string); + + for (i=0; i<num_screens; i++) + { + if (!XAllocNamedColor (dpy, screens[i].def_cmap, ARG_STRING(0), &color, &junk)) + return cmdret_new (RET_FAILURE, "defbwcolor: unknown color"); + + screens[i].bw_color = color.pixel; + update_gc (&screens[i]); + + free (defaults.bwcolor_string); + defaults.bwcolor_string = xstrdup (ARG_STRING(0)); + } + + /* Update all the visible windows. */ + list_for_each_entry (win,&rp_mapped_window,node) + { + if (win != cur) + XSetWindowBorder (dpy, win->w, win->scr->bw_color); + } + + + return cmdret_new (RET_SUCCESS, NULL); +} + cmdret * cmd_setenv (int interactive, struct cmdarg **args) { @@ -155,7 +155,7 @@ struct rp_screen int xine_screen_num; /* Our screen number for the Xinerama extension */ Colormap def_cmap; Cursor rat; - unsigned long fg_color, bg_color; /* The pixel color. */ + unsigned long fg_color, bg_color, fw_color, bw_color; /* The pixel color. */ /* Here to abstract over the Xinerama vs X screens difference */ int left, top, width, height; @@ -235,6 +235,8 @@ struct rp_defaults char *fgcolor_string; char *bgcolor_string; + char *fwcolor_string; + char *bwcolor_string; int wait_for_key_cursor; @@ -548,6 +548,8 @@ init_defaults (void) defaults.fgcolor_string = xstrdup ("black"); defaults.bgcolor_string = xstrdup ("white"); + defaults.fwcolor_string = xstrdup ("black"); + defaults.bwcolor_string = xstrdup ("black"); defaults.wait_for_key_cursor = 1; diff --git a/src/screen.c b/src/screen.c index 88b95b7..71a8f50 100644 --- a/src/screen.c +++ b/src/screen.c @@ -301,6 +301,8 @@ init_screen (rp_screen *s, int screen_num) s->fg_color = BlackPixel (dpy, s->screen_num); s->bg_color = WhitePixel (dpy, s->screen_num); + s->fw_color = BlackPixel (dpy, s->screen_num); + s->bw_color = BlackPixel (dpy, s->screen_num); /* Setup the GC for drawing the font. */ gv.foreground = s->fg_color; diff --git a/src/split.c b/src/split.c index 9b1d41b..561e928 100644 --- a/src/split.c +++ b/src/split.c @@ -806,9 +806,10 @@ remove_frame (rp_frame *frame) the new frame size. */ if (cur->win_number != EMPTY) { - win = find_window_number (cur->win_number); + rp_window *new = find_window_number (cur->win_number); maximize_all_windows_in_frame (cur); - XRaiseWindow (dpy, win->w); + give_window_focus (new, win); + XRaiseWindow (dpy, new->w); } } else diff --git a/src/window.c b/src/window.c index bde03f6..889772c 100644 --- a/src/window.c +++ b/src/window.c @@ -411,7 +411,10 @@ give_window_focus (rp_window *win, rp_window *last_win) /* Warp the cursor to the window's saved position if last_win and win are different windows. */ if (last_win != NULL && win != last_win) - save_mouse_position (last_win); + { + save_mouse_position (last_win); + XSetWindowBorder (dpy, last_win->w, last_win->scr->bw_color); + } if (win == NULL) return; @@ -430,6 +433,8 @@ give_window_focus (rp_window *win, rp_window *last_win) if (last_win != NULL) XUninstallColormap (dpy, last_win->colormap); XInstallColormap (dpy, win->colormap); + XSetWindowBorder (dpy, win->w, win->scr->fw_color); + /* Finally, give the window focus */ rp_current_screen = win->scr->xine_screen_num; set_rp_window_focus (win); |