summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-09 19:54:35 +0000
committersabetts <sabetts>2001-09-09 19:54:35 +0000
commit29fc0a0b61524c858128dd5cc25d797182dd8a36 (patch)
treeb3b7ba216d65b4894dd6f79f705b451f24a89770
parent52331f356b10796b8c8a3748f1bccd16d692571d (diff)
downloadratpoison-29fc0a0b61524c858128dd5cc25d797182dd8a36.zip
* src/bar.c (marked_message): use the screen_info fg_color and
bg_color to create the inverse GC. * src/actions.h (cmd_deffgcolor): new prototype (cmd_defbgcolor): new prototype * src/actions.c (cmd_defbartimeout): merge the 2 ifs. (cmd_defbartimeout): verify that the number is positive. (cmd_defborder): likewise (cmd_defwinname): gobble leading whitespace. Use strings as arguments, not numbers. (cmd_windows): Use the argument as a window format string in non-interactive mode. (cmd_windows): if data is NULL use the default format string. (user_commands): new commands deffgcolor, defbgcolor. (update_gc): new function (cmd_deffgcolor): likewise (cmd_defbgcolor): likewise
-rw-r--r--ChangeLog10
-rw-r--r--src/actions.c84
-rw-r--r--src/actions.h2
-rw-r--r--src/bar.c4
-rw-r--r--src/main.c4
5 files changed, 100 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 96f0139..c561f5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2001-09-09 shawn <sabetts@diggin.lamenet.tmp>
+ * src/bar.c (marked_message): use the screen_info fg_color and
+ bg_color to create the inverse GC.
+
+ * src/actions.h (cmd_deffgcolor): new prototype
+ (cmd_defbgcolor): new prototype
+
* src/actions.c (cmd_defbartimeout): merge the 2 ifs.
(cmd_defbartimeout): verify that the number is positive.
(cmd_defborder): likewise
@@ -8,6 +14,10 @@
(cmd_windows): Use the argument as a window format string in
non-interactive mode.
(cmd_windows): if data is NULL use the default format string.
+ (user_commands): new commands deffgcolor, defbgcolor.
+ (update_gc): new function
+ (cmd_deffgcolor): likewise
+ (cmd_defbgcolor): likewise
2001-09-08 shawn <sabetts@diggin.lamenet.tmp>
diff --git a/src/actions.c b/src/actions.c
index 2f748aa..91efce0 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -79,6 +79,8 @@ static user_command user_commands[] =
{"defwinfmt", cmd_defwinfmt, arg_STRING},
{"defwinname", cmd_defwinname, arg_STRING},
{"defwinpos", cmd_defwinpos, arg_STRING},
+ {"deffgcolor", cmd_deffgcolor, arg_STRING},
+ {"defbgcolor", cmd_defbgcolor, arg_STRING},
/* Commands to help debug ratpoison. */
#ifdef DEBUG
@@ -1682,3 +1684,85 @@ cmd_defwinname (int interactive, void *data)
return NULL;
}
+
+static void
+update_gc (screen_info *s)
+{
+ XGCValues gv;
+
+ gv.foreground = s->fg_color;
+ gv.background = s->bg_color;
+ gv.function = GXcopy;
+ gv.line_width = 1;
+ gv.subwindow_mode = IncludeInferiors;
+ gv.font = defaults.font->fid;
+ XFreeGC (dpy, s->normal_gc);
+ s->normal_gc = XCreateGC(dpy, s->root,
+ GCForeground | GCBackground
+ | GCFunction | GCLineWidth
+ | GCSubwindowMode | GCFont, &gv);
+}
+
+char *
+cmd_deffgcolor (int interactive, void *data)
+{
+ int i;
+ XColor color, junk;
+
+ if (data == NULL)
+ {
+ message (" deffgcolor: One argument required ");
+ return NULL;
+ }
+
+ for (i=0; i<num_screens; i++)
+ {
+ if (!XAllocNamedColor (dpy, screens[i].def_cmap, (char *)data, &color, &junk))
+ {
+ message (" deffgcolor: Unknown color ");
+ return NULL;
+ }
+
+ screens[i].fg_color = color.pixel;
+ update_gc (&screens[i]);
+ XSetWindowBorder (dpy, screens[i].bar_window, color.pixel);
+ XSetWindowBorder (dpy, screens[i].key_window, color.pixel);
+ XSetWindowBorder (dpy, screens[i].input_window, color.pixel);
+ XSetWindowBorder (dpy, screens[i].frame_window, color.pixel);
+ XSetWindowBorder (dpy, screens[i].help_window, color.pixel);
+ }
+
+ return NULL;
+}
+
+char *
+cmd_defbgcolor (int interactive, void *data)
+{
+ int i;
+ XColor color, junk;
+
+ if (data == NULL)
+ {
+ message (" defbgcolor: One argument required ");
+ return NULL;
+ }
+
+ for (i=0; i<num_screens; i++)
+ {
+ if (!XAllocNamedColor (dpy, screens[i].def_cmap, (char *)data, &color, &junk))
+ {
+ message (" defbgcolor: Unknown color ");
+ return NULL;
+ }
+
+ screens[i].bg_color = color.pixel;
+ update_gc (&screens[i]);
+ XSetWindowBackground (dpy, screens[i].bar_window, color.pixel);
+ XSetWindowBackground (dpy, screens[i].key_window, color.pixel);
+ XSetWindowBackground (dpy, screens[i].input_window, color.pixel);
+ XSetWindowBackground (dpy, screens[i].frame_window, color.pixel);
+ XSetWindowBackground (dpy, screens[i].help_window, color.pixel);
+ }
+
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index 1834fc0..2b85370 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -88,6 +88,8 @@ char * cmd_definputwidth (int interactive, void *data);
char * cmd_defwaitcursor (int interactive, void *data);
char * cmd_defwinfmt (int interactive, void *data);
char * cmd_defwinname (int interactive, void *data);
+char * cmd_deffgcolor (int interactive, void *data);
+char * cmd_defbgcolor (int interactive, void *data);
/* void cmd_xterm (void *data); */
diff --git a/src/bar.c b/src/bar.c
index 89df8d1..dc51c37 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -209,14 +209,14 @@ marked_message (char *msg, int mark_start, int mark_end)
PRINT_DEBUG ("%d %d strlen(%d)==> %d %d\n", mark_start, mark_end, strlen(msg), start, end);
- lgv.foreground = gv.foreground;
+ lgv.foreground = current_screen()->fg_color;
lgv.function = GXxor;
mask = GCForeground | GCFunction;
lgc = XCreateGC(dpy, s->root, mask, &lgv);
XFillRectangle (dpy, s->bar_window, lgc, start, 0, end, height);
- lgv.foreground = gv.background;
+ lgv.foreground = s->bg_color;
lgc = XCreateGC(dpy, s->root, mask, &lgv);
XFillRectangle (dpy, s->bar_window, lgc, start, 0, end, height);
diff --git a/src/main.c b/src/main.c
index 498029d..91ec293 100644
--- a/src/main.c
+++ b/src/main.c
@@ -68,8 +68,6 @@ int ignore_badwindow = 0;
char **myargv;
-XGCValues gv;
-
struct rp_key prefix_key;
struct modifier_info rp_modifier_info;
@@ -517,6 +515,8 @@ init_rat_cursor (screen_info *s)
static void
init_screen (screen_info *s, int screen_num)
{
+ XGCValues gv;
+
/* Select on some events on the root window, if this fails, then
there is already a WM running and the X Error handler will catch
it, terminating ratpoison. */