From 6ff3931470534f22415baa05817ae1bc8aa22d6c Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 17 Dec 2012 18:34:06 +0000 Subject: stash the default screen visual and colormap in screen_ctx --- calmwm.h | 4 +++- font.c | 14 ++++++-------- screen.c | 4 +++- xutil.c | 5 ++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/calmwm.h b/calmwm.h index 4540aca..e029dfd 100644 --- a/calmwm.h +++ b/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.169 2012/12/17 17:48:57 okan Exp $ + * $OpenBSD: calmwm.h,v 1.170 2012/12/17 18:34:06 okan Exp $ */ #ifndef _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 a8b962f..f2ed403 100644 --- a/font.c +++ b/font.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: font.c,v 1.23 2012/12/17 14:20:52 okan Exp $ + * $OpenBSD: font.c,v 1.24 2012/12/17 18:34:06 okan Exp $ */ #include @@ -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 bc37105..2f04911 100644 --- a/screen.c +++ b/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: screen.c,v 1.38 2012/11/29 03:54:46 okan Exp $ + * $OpenBSD: screen.c,v 1.39 2012/12/17 18:34:06 okan Exp $ */ #include @@ -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 53c191f..cdb7321 100644 --- a/xutil.c +++ b/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xutil.c,v 1.50 2012/12/17 02:28:45 okan Exp $ + * $OpenBSD: xutil.c,v 1.51 2012/12/17 18:34:06 okan Exp $ */ #include @@ -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); } -- cgit v1.2.3-2-gb3c3