1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

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.
This commit is contained in:
Iain Patterson
2012-08-25 09:59:03 +01:00
committed by Carlos R. Mafra
parent 9ab2b642a6
commit b796928504
4 changed files with 37 additions and 2 deletions

View File

@@ -1863,7 +1863,10 @@ void wSelectWindow(WWindow *wwin, Bool flag)
if (flag) { if (flag) {
wwin->flags.selected = 1; 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)) { if (!HAS_BORDER(wwin)) {
XSetWindowBorderWidth(dpy, wwin->frame->core->window, FRAME_BORDER_WIDTH); XSetWindowBorderWidth(dpy, wwin->frame->core->window, FRAME_BORDER_WIDTH);
@@ -1874,7 +1877,10 @@ void wSelectWindow(WWindow *wwin, Bool flag)
WMAddToArray(scr->selected_windows, wwin); WMAddToArray(scr->selected_windows, wwin);
} else { } else {
wwin->flags.selected = 0; 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)) { if (!HAS_BORDER(wwin)) {
XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0); XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0);

View File

@@ -58,6 +58,27 @@ static void paintButton(WCoreWindow * button, WTexture * texture,
static void updateTitlebar(WFrameWindow * fwin); 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, WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
int width, int height, int *clearance, int width, int height, int *clearance,
int *title_min, int *title_max, int flags, 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->depth = depth;
fwin->visual = visual; fwin->visual = visual;
fwin->colormap = colormap; 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) fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER)
? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap); ? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap);
@@ -413,6 +436,9 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
} }
checkTitleSize(fwin); checkTitleSize(fwin);
if (fwin->border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel);
} }
void wFrameWindowDestroy(WFrameWindow * fwin) void wFrameWindowDestroy(WFrameWindow * fwin)

View File

@@ -150,6 +150,8 @@ typedef struct WFrameWindow {
int depth; int depth;
Visual *visual; Visual *visual;
Colormap colormap; Colormap colormap;
unsigned long *border_pixel;
unsigned long *selected_border_pixel;
} WFrameWindow; } WFrameWindow;

View File

@@ -344,6 +344,7 @@
#undef NO_MINIWINDOW_TITLES #undef NO_MINIWINDOW_TITLES
#define FRAME_BORDER_COLOR "black" #define FRAME_BORDER_COLOR "black"
#define FRAME_SELECTED_BORDER_COLOR "white"
/* for boxes with high mouse sampling rates (SGI) */ /* for boxes with high mouse sampling rates (SGI) */
#define DELAY_BETWEEN_MOUSE_SAMPLING 10 #define DELAY_BETWEEN_MOUSE_SAMPLING 10