[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] [PATCH] improve(?) colormap handling
From: |
Andreas Seltenreich |
Subject: |
[RP] [PATCH] improve(?) colormap handling |
Date: |
Wed, 13 Dec 2006 13:23:20 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) |
Hi,
I'm currently low on colors, and it occasionally happens that the bar
or input window turns out unreadable (e.g., black foreground on dark
blue background) when a window has a custom colormap set.
I propose the following patch that makes ratpoison temporarily switch
to the default colormap to guarantee readability of its windows.
Thanks,
andreas
2006-12-13 Andreas Seltenreich <address@hidden>
* src/bar.c (show_bar, prepare_bar): Switch to default colormap.
(hide_bar): Possibly restore colormap.
* src/input.c (get_more_input): Temporarily install default
colormap.
* src/actions.c (cmd_help, cmd_license): Likewise.
* src/events.c (colormap_notify): Postpone installing colormap
when bar is raised.
Index: src/actions.c
===================================================================
RCS file: /sources/ratpoison/ratpoison/src/actions.c,v
retrieving revision 1.283
diff -u -r1.283 actions.c
--- src/actions.c 26 Nov 2006 23:54:36 -0000 1.283
+++ src/actions.c 13 Dec 2006 11:56:43 -0000
@@ -3135,6 +3135,11 @@
"[Press any key to end.] ",
NULL};
+ /* Switch to the default colormap. */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
+
XMapRaised (dpy, s->help_window);
XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync,
CurrentTime);
@@ -3171,6 +3176,13 @@
XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->help_window);
+ /* Possibly restore colormap. */
+ if (current_window())
+ {
+ XUninstallColormap (dpy, s->def_cmap);
+ XInstallColormap (dpy, current_window()->colormap);
+ }
+
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
redraw_last_message();
@@ -3199,6 +3211,11 @@
int drawing_keys = 1; /* 1 if we are drawing keys 0 if we
are drawing commands */
char *keysym_name;
+ /* Switch to the default colormap. */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
+
XMapRaised (dpy, s->help_window);
XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync,
CurrentTime);
@@ -3289,6 +3306,13 @@
XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->help_window);
+ /* Possibly restore colormap. */
+ if (current_window())
+ {
+ XUninstallColormap (dpy, s->def_cmap);
+ XInstallColormap (dpy, current_window()->colormap);
+ }
+
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
redraw_last_message();
Index: src/events.c
===================================================================
RCS file: /sources/ratpoison/ratpoison/src/events.c,v
retrieving revision 1.138
diff -u -r1.138 events.c
--- src/events.c 26 Nov 2006 23:54:36 -0000 1.138
+++ src/events.c 13 Dec 2006 11:56:43 -0000
@@ -660,7 +660,8 @@
XGetWindowAttributes (dpy, win->w, &attr);
win->colormap = attr.colormap;
- if (win == current_window())
+ if (win == current_window()
+ && !current_screen()->bar_is_raised)
{
XInstallColormap (dpy, win->colormap);
}
Index: src/bar.c
===================================================================
RCS file: /sources/ratpoison/ratpoison/src/bar.c,v
retrieving revision 1.60
diff -u -r1.60 bar.c
--- src/bar.c 18 Nov 2006 01:07:34 -0000 1.60
+++ src/bar.c 13 Dec 2006 11:56:43 -0000
@@ -62,6 +62,14 @@
{
s->bar_is_raised = 0;
XUnmapWindow (dpy, s->bar_window);
+
+ /* Possibly restore colormap. */
+ if (current_window())
+ {
+ XUninstallColormap (dpy, s->def_cmap);
+ XInstallColormap (dpy, current_window()->colormap);
+ }
+
return 1;
}
@@ -78,6 +86,11 @@
XMapRaised (dpy, s->bar_window);
update_window_names (s, fmt);
+ /* Switch to the default colormap */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
+
reset_alarm();
return 1;
}
@@ -381,6 +394,11 @@
{
s->bar_is_raised = BAR_IS_MESSAGE;
XMapRaised (dpy, s->bar_window);
+
+ /* Switch to the default colormap */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
}
XRaiseWindow (dpy, s->bar_window);
Index: src/input.c
===================================================================
RCS file: /sources/ratpoison/ratpoison/src/input.c,v
retrieving revision 1.53
diff -u -r1.53 input.c
--- src/input.c 24 May 2006 02:25:22 -0000 1.53
+++ src/input.c 13 Dec 2006 11:56:43 -0000
@@ -497,6 +497,11 @@
/* We don't want to draw overtop of the program bar. */
hide_bar (s);
+ /* Switch to the default colormap. */
+ if (current_window())
+ XUninstallColormap (dpy, current_window()->colormap);
+ XInstallColormap (dpy, s->def_cmap);
+
XMapWindow (dpy, s->input_window);
XRaiseWindow (dpy, s->input_window);
XClearWindow (dpy, s->input_window);
@@ -547,5 +552,12 @@
XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->input_window);
+ /* Possibly restore colormap. */
+ if (current_window())
+ {
+ XUninstallColormap (dpy, s->def_cmap);
+ XInstallColormap (dpy, current_window()->colormap);
+ }
+
return final_input;
}
- [RP] [PATCH] improve(?) colormap handling,
Andreas Seltenreich <=