From 13377b4e34be6d298eeb41a55df939f39ee7f5a7 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Wed, 18 Mar 2020 19:47:55 +0100 Subject: Calculate colors using the client's visual and colormap As cwm was using the screen's default visual and colormap to draw all client borders, borders for windows that had a depth of 32 bits were not rendered correctly. The same happened with text in the popup menus which were recently changed to be drawn in the context of the client. This commit introduces a Visual reference for each client, and allocates all potential colors for a client's specific visual and colormap in the client_ctx struct. These colors are then used to draw client borders and popup menus. Additionally, since we touch the drawing code anyway, borders are reintroduced to the popup menus for better contrast. --- conf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 6f66ba4..0d0a852 100644 --- a/conf.c +++ b/conf.c @@ -447,6 +447,8 @@ void conf_client(struct client_ctx *cc) { struct winname *wn; + unsigned int i; + XftColor xc; TAILQ_FOREACH(wn, &Conf.ignoreq, entry) { if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) { @@ -454,6 +456,25 @@ conf_client(struct client_ctx *cc) break; } } + + for (i = 0; i < nitems(color_binds); i++) { + if (i == CWM_COLOR_MENU_FONT_SEL && *Conf.color[i] == '\0') { + xu_xorcolor(cc->xftcolor[CWM_COLOR_MENU_BG], + cc->xftcolor[CWM_COLOR_MENU_FG], &xc); + xu_xorcolor(cc->xftcolor[CWM_COLOR_MENU_FONT], xc, &xc); + if (!XftColorAllocValue(X_Dpy, cc->visual, cc->colormap, + &xc.color, &cc->xftcolor[CWM_COLOR_MENU_FONT_SEL])) + warnx("XftColorAllocValue: %s", Conf.color[i]); + break; + } + if (!XftColorAllocName(X_Dpy, cc->visual, cc->colormap, + Conf.color[i], &cc->xftcolor[i])) { + warnx("XftColorAllocName: %s", Conf.color[i]); + XftColorAllocName(X_Dpy, cc->visual, cc->colormap, + color_binds[i], &cc->xftcolor[i]); + } + } + } void -- cgit v1.2.3-2-gb3c3