Here's the patch for window borders having inconsistent colours
when a compositing manager is used.
From 5b6562f173e765522b5648562c7d7f8c3e06f1bc Mon Sep 17 00:00:00 2001
From: Iain Patterson <[email protected]>
Date: Sat, 25 Aug 2012 09:59:03 +0100
Subject: [PATCH 3/4] Draw window borders with correct colormap.
Using window-supplied depth, visual and colormap information has the
side effect of causing window borders to be draw using inconsistent
colormap entries. Allocate entries from each window's colormap when
drawing its border.
Force setting the border when the window is first created so it's
guaranteed to be drawn in a consistent state.
---
src/actions.c | 10 ++++++++--
src/framewin.c | 26 ++++++++++++++++++++++++++
src/framewin.h | 2 ++
src/wconfig.h.in | 1 +
4 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index 988e90a..0d4cff1 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1863,7 +1863,10 @@ void wSelectWindow(WWindow *wwin, Bool flag)
if (flag) {
wwin->flags.selected = 1;
- XSetWindowBorder(dpy, wwin->frame->core->window,
scr->white_pixel);
+ if (wwin->frame->selected_border_pixel)
+ XSetWindowBorder(dpy, wwin->frame->core->window,
*wwin->frame->selected_border_pixel);
+ else
+ XSetWindowBorder(dpy, wwin->frame->core->window,
scr->white_pixel);
if (!HAS_BORDER(wwin)) {
XSetWindowBorderWidth(dpy, wwin->frame->core->window,
FRAME_BORDER_WIDTH);
@@ -1874,7 +1877,10 @@ void wSelectWindow(WWindow *wwin, Bool flag)
WMAddToArray(scr->selected_windows, wwin);
} else {
wwin->flags.selected = 0;
- XSetWindowBorder(dpy, wwin->frame->core->window,
scr->frame_border_pixel);
+ if (wwin->frame->border_pixel)
+ XSetWindowBorder(dpy, wwin->frame->core->window,
*wwin->frame->border_pixel);
+ else
+ XSetWindowBorder(dpy, wwin->frame->core->window,
scr->frame_border_pixel);
if (!HAS_BORDER(wwin)) {
XSetWindowBorderWidth(dpy, wwin->frame->core->window,
0);
diff --git a/src/framewin.c b/src/framewin.c
index 448d204..2a26952 100644
--- a/src/framewin.c
+++ b/src/framewin.c
@@ -58,6 +58,27 @@ static void paintButton(WCoreWindow * button, WTexture *
texture,
static void updateTitlebar(WFrameWindow * fwin);
+static void allocFrameBorderPixel(Colormap colormap, char *color_name,
unsigned long **pixel);
+
+static void allocFrameBorderPixel(Colormap colormap, char *color_name,
unsigned long **pixel) {
+ XColor xcol;
+
+ *pixel = NULL;
+
+ if (!XParseColor(dpy, colormap, color_name, &xcol)) {
+ wwarning(_("could not parse color \"%s\""), color_name);
+ return;
+ }
+ if (!XAllocColor(dpy, colormap, &xcol)) {
+ wwarning(_("could not allocate color \"%s\""), color_name);
+ return;
+ }
+
+ *pixel = wmalloc(sizeof(unsigned long));
+ if (*pixel)
+ **pixel = xcol.pixel;
+}
+
WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
int width, int height, int *clearance,
int *title_min, int *title_max, int flags,
@@ -88,6 +109,8 @@ WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel,
int x, int y,
fwin->depth = depth;
fwin->visual = visual;
fwin->colormap = colormap;
+ allocFrameBorderPixel(fwin->colormap, FRAME_BORDER_COLOR,
&fwin->border_pixel);
+ allocFrameBorderPixel(fwin->colormap, FRAME_SELECTED_BORDER_COLOR,
&fwin->selected_border_pixel);
fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags &
WFF_BORDER)
? FRAME_BORDER_WIDTH : 0, fwin->depth,
fwin->visual, fwin->colormap);
@@ -413,6 +436,9 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int
flags)
}
checkTitleSize(fwin);
+
+ if (fwin->border_pixel)
+ XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel);
}
void wFrameWindowDestroy(WFrameWindow * fwin)
diff --git a/src/framewin.h b/src/framewin.h
index 27e6518..d893cd1 100644
--- a/src/framewin.h
+++ b/src/framewin.h
@@ -150,6 +150,8 @@ typedef struct WFrameWindow {
int depth;
Visual *visual;
Colormap colormap;
+ unsigned long *border_pixel;
+ unsigned long *selected_border_pixel;
} WFrameWindow;
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index 0046863..baef446 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -344,6 +344,7 @@
#undef NO_MINIWINDOW_TITLES
#define FRAME_BORDER_COLOR "black"
+#define FRAME_SELECTED_BORDER_COLOR "white"
/* for boxes with high mouse sampling rates (SGI) */
#define DELAY_BETWEEN_MOUSE_SAMPLING 10
--
1.7.11.4