summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2012-12-17 18:34:06 +0000
committerokan <okan>2012-12-17 18:34:06 +0000
commitaf13c081080574a036565e2fa7c761b6e6233068 (patch)
tree4611b48a70693b368c7f843d991ed1ea38432609
parent82e8ec4245f44bd10c0fc5ed27640dafbb7beb44 (diff)
downloadcwm-af13c081080574a036565e2fa7c761b6e6233068.tar.gz
cwm-af13c081080574a036565e2fa7c761b6e6233068.tar.xz
cwm-af13c081080574a036565e2fa7c761b6e6233068.zip
stash the default screen visual and colormap in screen_ctx
-rw-r--r--calmwm.h2
-rw-r--r--font.c12
-rw-r--r--screen.c2
-rw-r--r--xutil.c3
4 files changed, 10 insertions, 9 deletions
diff --git a/calmwm.h b/calmwm.h
index 601ca8f..e54c06b 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -210,6 +210,8 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
 struct screen_ctx {
 	TAILQ_ENTRY(screen_ctx)	 entry;
 	u_int			 which;
+	Visual			*visual;
+	Colormap		 colormap;
 	Window			 rootwin;
 	Window			 menuwin;
 	struct color		 color[CWM_COLOR_MAX];
diff --git a/font.c b/font.c
index 6aecf97..44d4666 100644
--- a/font.c
+++ b/font.c
@@ -55,7 +55,7 @@ font_init(struct screen_ctx *sc, const char *name, const char **color)
 	XRenderColor	 c;
 
 	sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
-	    DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
+	    sc->visual, sc->colormap);
 	if (sc->xftdraw == NULL)
 		errx(1, "XftDrawCreate");
 
@@ -66,9 +66,8 @@ font_init(struct screen_ctx *sc, const char *name, const char **color)
 	for (i = 0; i < CWM_COLOR_MENU_MAX; i++) {
 		if (*color[i] == '\0')
 			break;
-		if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
-			DefaultColormap(X_Dpy, sc->which), color[i],
-		       	&sc->xftcolor[i]))
+		if (!XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
+			color[i], &sc->xftcolor[i]))
 			errx(1, "XftColorAllocName");
 	}
 	if (i == CWM_COLOR_MENU_MAX)
@@ -77,9 +76,8 @@ font_init(struct screen_ctx *sc, const char *name, const char **color)
 	xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG].color,
 		    sc->xftcolor[CWM_COLOR_MENU_FG].color, &c);
 	xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT].color, c, &c);
-	if (!XftColorAllocValue(X_Dpy, DefaultVisual(X_Dpy, sc->which),
-		DefaultColormap(X_Dpy, sc->which), &c,
-		&sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
+	if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap,
+		&c, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
 		errx(1, "XftColorAllocValue");
 }
 
diff --git a/screen.c b/screen.c
index a515adb..9515d91 100644
--- a/screen.c
+++ b/screen.c
@@ -41,6 +41,8 @@ screen_init(struct screen_ctx *sc, u_int which)
 	u_int			 nwins, i;
 
 	sc->which = which;
+	sc->visual = DefaultVisual(X_Dpy, sc->which);
+	sc->colormap = DefaultColormap(X_Dpy, sc->which);
 	sc->rootwin = RootWindow(X_Dpy, sc->which);
 
 	xu_ewmh_net_supported(sc);
diff --git a/xutil.c b/xutil.c
index 6e80379..b910906 100644
--- a/xutil.c
+++ b/xutil.c
@@ -422,8 +422,7 @@ xu_getcolor(struct screen_ctx *sc, char *name)
 {
 	XColor	 color, tmp;
 
-	if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
-	    name, &color, &tmp)) {
+	if (!XAllocNamedColor(X_Dpy, sc->colormap, name, &color, &tmp)) {
 		warnx("XAllocNamedColor error: '%s'", name);
 		return (0);
 	}