No need to store screen colormap and visual; rather just use the X

macros in the one place they are needed.
This commit is contained in:
okan 2014-02-02 16:29:04 +00:00
parent 49f2f86dbd
commit 03847f1c2e
4 changed files with 13 additions and 15 deletions

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: calmwm.c,v 1.88 2014/02/01 00:25:04 okan Exp $ * $OpenBSD: calmwm.c,v 1.89 2014/02/02 16:29:04 okan Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -162,7 +162,8 @@ x_teardown(void)
TAILQ_FOREACH(sc, &Screenq, entry) { TAILQ_FOREACH(sc, &Screenq, entry) {
for (i = 0; i < CWM_COLOR_NITEMS; i++) 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]); &sc->xftcolor[i]);
XftDrawDestroy(sc->xftdraw); XftDrawDestroy(sc->xftdraw);
XftFontClose(X_Dpy, sc->xftfont); XftFontClose(X_Dpy, sc->xftfont);

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: calmwm.h,v 1.255 2014/02/02 15:46:05 okan Exp $ * $OpenBSD: calmwm.h,v 1.256 2014/02/02 16:29:04 okan Exp $
*/ */
#ifndef _CALMWM_H_ #ifndef _CALMWM_H_
@ -221,8 +221,6 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
struct screen_ctx { struct screen_ctx {
TAILQ_ENTRY(screen_ctx) entry; TAILQ_ENTRY(screen_ctx) entry;
int which; int which;
Visual *visual;
Colormap colormap;
Window rootwin; Window rootwin;
Window menuwin; Window menuwin;
int cycling; int cycling;

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: conf.c,v 1.171 2014/02/02 15:46:05 okan Exp $ * $OpenBSD: conf.c,v 1.172 2014/02/02 16:29:04 okan Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -125,6 +125,8 @@ conf_screen(struct screen_ctx *sc)
{ {
unsigned int i; unsigned int i;
XftColor xc; XftColor xc;
Colormap colormap = DefaultColormap(X_Dpy, sc->which);
Visual *visual = DefaultVisual(X_Dpy, sc->which);
sc->gap = Conf.gap; sc->gap = Conf.gap;
sc->snapdist = Conf.snapdist; sc->snapdist = Conf.snapdist;
@ -141,18 +143,18 @@ conf_screen(struct screen_ctx *sc)
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG], xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG],
sc->xftcolor[CWM_COLOR_MENU_FG], &xc); sc->xftcolor[CWM_COLOR_MENU_FG], &xc);
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT], xc, &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])) &xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
warnx("XftColorAllocValue: %s", Conf.color[i]); warnx("XftColorAllocValue: %s", Conf.color[i]);
break; break;
} }
if (XftColorAllocName(X_Dpy, sc->visual, sc->colormap, if (XftColorAllocName(X_Dpy, visual, colormap,
Conf.color[i], &xc)) { Conf.color[i], &xc)) {
sc->xftcolor[i] = xc; sc->xftcolor[i] = xc;
XftColorFree(X_Dpy, sc->visual, sc->colormap, &xc); XftColorFree(X_Dpy, visual, colormap, &xc);
} else { } else {
warnx("XftColorAllocName: %s", Conf.color[i]); warnx("XftColorAllocName: %s", Conf.color[i]);
XftColorAllocName(X_Dpy, sc->visual, sc->colormap, XftColorAllocName(X_Dpy, visual, colormap,
color_binds[i], &sc->xftcolor[i]); 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_FG].pixel,
sc->xftcolor[CWM_COLOR_MENU_BG].pixel); sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin, sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin, visual, colormap);
sc->visual, sc->colormap);
if (sc->xftdraw == NULL) if (sc->xftdraw == NULL)
errx(1, "XftDrawCreate"); errx(1, "XftDrawCreate");

View File

@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* $OpenBSD: screen.c,v 1.56 2014/02/02 16:13:50 okan Exp $ * $OpenBSD: screen.c,v 1.57 2014/02/02 16:29:04 okan Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -44,8 +44,6 @@ screen_init(int which)
TAILQ_INIT(&sc->mruq); TAILQ_INIT(&sc->mruq);
sc->which = which; sc->which = which;
sc->visual = DefaultVisual(X_Dpy, sc->which);
sc->colormap = DefaultColormap(X_Dpy, sc->which);
sc->rootwin = RootWindow(X_Dpy, sc->which); sc->rootwin = RootWindow(X_Dpy, sc->which);
conf_screen(sc); conf_screen(sc);