about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2018-02-13 15:43:15 +0000
committerokan <okan>2018-02-13 15:43:15 +0000
commitb1929b5ed6a33fa6d031912c9963ab5e113f81ea (patch)
treeb31ec8215f1a35d9486d1a76551e5d3de312c38f
parent13763662c9ba3c0fed9732b14fb81a63235a1f26 (diff)
downloadcwm-b1929b5ed6a33fa6d031912c9963ab5e113f81ea.tar.gz
cwm-b1929b5ed6a33fa6d031912c9963ab5e113f81ea.tar.xz
cwm-b1929b5ed6a33fa6d031912c9963ab5e113f81ea.zip
Store the screen's visual type and colormap.
-rw-r--r--calmwm.h2
-rw-r--r--conf.c13
-rw-r--r--screen.c2
3 files changed, 10 insertions, 7 deletions
diff --git a/calmwm.h b/calmwm.h
index a99ba02..e4dbe3a 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -223,6 +223,8 @@ struct screen_ctx {
 	struct region_q		 regionq;
 	struct group_q		 groupq;
 	struct group_ctx	*group_active;
+	Colormap		 colormap;
+	Visual			*visual;
 	struct {
 		Window		 win;
 		XftDraw		*xftdraw;
diff --git a/conf.c b/conf.c
index 5d85fdc..b77425c 100644
--- a/conf.c
+++ b/conf.c
@@ -451,8 +451,6 @@ conf_screen(struct screen_ctx *sc)
 {
 	unsigned int	 i;
 	XftColor	 xc;
-	Colormap	 colormap = DefaultColormap(X_Dpy, sc->which);
-	Visual		*visual = DefaultVisual(X_Dpy, sc->which);
 
 	sc->gap = Conf.gap;
 	sc->snapdist = Conf.snapdist;
@@ -469,18 +467,18 @@ conf_screen(struct screen_ctx *sc)
 			xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG],
 			    sc->xftcolor[CWM_COLOR_MENU_FG], &xc);
 			xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT], xc, &xc);
-			if (!XftColorAllocValue(X_Dpy, visual, colormap,
+			if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap,
 			    &xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
 				warnx("XftColorAllocValue: %s", Conf.color[i]);
 			break;
 		}
-		if (XftColorAllocName(X_Dpy, visual, colormap,
+		if (XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
 		    Conf.color[i], &xc)) {
 			sc->xftcolor[i] = xc;
-			XftColorFree(X_Dpy, visual, colormap, &xc);
+			XftColorFree(X_Dpy, sc->visual, sc->colormap, &xc);
 		} else {
 			warnx("XftColorAllocName: %s", Conf.color[i]);
-			XftColorAllocName(X_Dpy, visual, colormap,
+			XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
 			    color_binds[i], &sc->xftcolor[i]);
 		}
 	}
@@ -490,7 +488,8 @@ conf_screen(struct screen_ctx *sc)
 	    sc->xftcolor[CWM_COLOR_MENU_FG].pixel,
 	    sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
 
-	sc->menu.xftdraw = XftDrawCreate(X_Dpy, sc->menu.win, visual, colormap);
+	sc->menu.xftdraw = XftDrawCreate(X_Dpy, sc->menu.win,
+	    sc->visual, sc->colormap);
 	if (sc->menu.xftdraw == NULL)
 		errx(1, "%s: XftDrawCreate", __func__);
 
diff --git a/screen.c b/screen.c
index 8d05f25..845a323 100644
--- a/screen.c
+++ b/screen.c
@@ -50,6 +50,8 @@ screen_init(int which)
 
 	sc->which = which;
 	sc->rootwin = RootWindow(X_Dpy, sc->which);
+	sc->colormap = DefaultColormap(X_Dpy, sc->which);
+	sc->visual = DefaultVisual(X_Dpy, sc->which);
 	sc->cycling = 0;
 	sc->hideall = 0;