aboutsummaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-03-18 19:47:55 +0100
committerWolfgang Müller2021-04-27 12:28:35 +0200
commit13377b4e34be6d298eeb41a55df939f39ee7f5a7 (patch)
tree6db3350aafcb6156361550436dfddb93c2f104d1 /client.c
parent5ff1dc2b8f6ec0ab2ebdd132ba1b56cebeb9626c (diff)
downloadcwm-13377b4e34be6d298eeb41a55df939f39ee7f5a7.tar.gz
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.
Diffstat (limited to 'client.c')
-rw-r--r--client.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/client.c b/client.c
index 676b40f..507478b 100644
--- a/client.c
+++ b/client.c
@@ -79,6 +79,7 @@ client_init(Window win, struct screen_ctx *sc)
cc->geom.w = wattr.width;
cc->geom.h = wattr.height;
cc->colormap = wattr.colormap;
+ cc->visual = wattr.visual;
cc->obwidth = wattr.border_width;
cc->bwidth = Conf.bwidth;
@@ -208,6 +209,10 @@ void
client_remove(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
+ unsigned int i;
+
+ for (i = 0; i < CWM_COLOR_NITEMS; i++)
+ XftColorFree(X_Dpy, cc->visual, cc->colormap, &cc->xftcolor[i]);
TAILQ_REMOVE(&sc->clientq, cc, entry);
@@ -566,26 +571,25 @@ client_urgency(struct client_ctx *cc)
void
client_draw_border(struct client_ctx *cc)
{
- struct screen_ctx *sc = cc->sc;
unsigned long pixel;
if (cc->flags & CLIENT_ACTIVE)
switch (cc->flags & CLIENT_HIGHLIGHT) {
case CLIENT_GROUP:
- pixel = sc->xftcolor[CWM_COLOR_BORDER_GROUP].pixel;
+ pixel = cc->xftcolor[CWM_COLOR_BORDER_GROUP].pixel;
break;
case CLIENT_UNGROUP:
- pixel = sc->xftcolor[CWM_COLOR_BORDER_UNGROUP].pixel;
+ pixel = cc->xftcolor[CWM_COLOR_BORDER_UNGROUP].pixel;
break;
default:
- pixel = sc->xftcolor[CWM_COLOR_BORDER_ACTIVE].pixel;
+ pixel = cc->xftcolor[CWM_COLOR_BORDER_ACTIVE].pixel;
break;
}
else
- pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
+ pixel = cc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
if (cc->flags & CLIENT_URGENCY)
- pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
+ pixel = cc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
XSetWindowBorderWidth(X_Dpy, cc->win, (unsigned int)cc->bwidth);
XSetWindowBorder(X_Dpy, cc->win, pixel);