summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-02-02 16:29:04 +0000
committerokan <okan>2014-02-02 16:29:04 +0000
commitad1b78c6d1b466fbc2c11eec92ad5ce75bb44515 (patch)
tree91d65e39a19d7e601855d32779b62bac76b0a6f9
parent5f9c7a21c71d8386ae7eb7b03bdfb9c58dbe1b19 (diff)
downloadcwm-ad1b78c6d1b466fbc2c11eec92ad5ce75bb44515.tar.gz
cwm-ad1b78c6d1b466fbc2c11eec92ad5ce75bb44515.tar.xz
cwm-ad1b78c6d1b466fbc2c11eec92ad5ce75bb44515.zip
No need to store screen colormap and visual; rather just use the X
macros in the one place they are needed.
-rw-r--r--calmwm.c3
-rw-r--r--calmwm.h2
-rw-r--r--conf.c13
-rw-r--r--screen.c2
4 files changed, 9 insertions, 11 deletions
diff --git a/calmwm.c b/calmwm.c
index 0fca8ae..3656b48 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -162,7 +162,8 @@ x_teardown(void)
 
 	TAILQ_FOREACH(sc, &Screenq, entry) {
 		for (i = 0; i < CWM_COLOR_NITEMS; i++)
-			XftColorFree(X_Dpy, sc->visual, sc->colormap,
+			XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
+			    DefaultColormap(X_Dpy, sc->which),
 			    &sc->xftcolor[i]);
 		XftDrawDestroy(sc->xftdraw);
 		XftFontClose(X_Dpy, sc->xftfont);
diff --git a/calmwm.h b/calmwm.h
index ae5b1b5..aa77bc0 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -221,8 +221,6 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
 struct screen_ctx {
 	TAILQ_ENTRY(screen_ctx)	 entry;
 	int			 which;
-	Visual			*visual;
-	Colormap		 colormap;
 	Window			 rootwin;
 	Window			 menuwin;
 	int			 cycling;
diff --git a/conf.c b/conf.c
index 4ab762f..2177930 100644
--- a/conf.c
+++ b/conf.c
@@ -125,6 +125,8 @@ 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;
@@ -141,18 +143,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, sc->visual, sc->colormap,
+			if (!XftColorAllocValue(X_Dpy, visual, colormap,
 			    &xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
 				warnx("XftColorAllocValue: %s", Conf.color[i]);
 			break;
 		}
-		if (XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
+		if (XftColorAllocName(X_Dpy, visual, colormap,
 		    Conf.color[i], &xc)) {
 			sc->xftcolor[i] = xc;
-			XftColorFree(X_Dpy, sc->visual, sc->colormap, &xc);
+			XftColorFree(X_Dpy, visual, colormap, &xc);
 		} else {
 			warnx("XftColorAllocName: %s", Conf.color[i]);
-			XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
+			XftColorAllocName(X_Dpy, visual, colormap,
 			    color_binds[i], &sc->xftcolor[i]);
 		}
 	}
@@ -162,8 +164,7 @@ conf_screen(struct screen_ctx *sc)
 	    sc->xftcolor[CWM_COLOR_MENU_FG].pixel,
 	    sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
 
-	sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin,
-	    sc->visual, sc->colormap);
+	sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin, visual, colormap);
 	if (sc->xftdraw == NULL)
 		errx(1, "XftDrawCreate");
 
diff --git a/screen.c b/screen.c
index fa90f96..df19c08 100644
--- a/screen.c
+++ b/screen.c
@@ -44,8 +44,6 @@ screen_init(int which)
 	TAILQ_INIT(&sc->mruq);
 
 	sc->which = which;
-	sc->visual = DefaultVisual(X_Dpy, sc->which);
-	sc->colormap = DefaultColormap(X_Dpy, sc->which);
 	sc->rootwin = RootWindow(X_Dpy, sc->which);
 	conf_screen(sc);