mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
stash the default screen visual and colormap in screen_ctx
This commit is contained in:
2
calmwm.h
2
calmwm.h
@@ -210,6 +210,8 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
|||||||
struct screen_ctx {
|
struct screen_ctx {
|
||||||
TAILQ_ENTRY(screen_ctx) entry;
|
TAILQ_ENTRY(screen_ctx) entry;
|
||||||
u_int which;
|
u_int which;
|
||||||
|
Visual *visual;
|
||||||
|
Colormap colormap;
|
||||||
Window rootwin;
|
Window rootwin;
|
||||||
Window menuwin;
|
Window menuwin;
|
||||||
struct color color[CWM_COLOR_MAX];
|
struct color color[CWM_COLOR_MAX];
|
||||||
|
|||||||
12
font.c
12
font.c
@@ -55,7 +55,7 @@ font_init(struct screen_ctx *sc, const char *name, const char **color)
|
|||||||
XRenderColor c;
|
XRenderColor c;
|
||||||
|
|
||||||
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
|
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)
|
if (sc->xftdraw == NULL)
|
||||||
errx(1, "XftDrawCreate");
|
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++) {
|
for (i = 0; i < CWM_COLOR_MENU_MAX; i++) {
|
||||||
if (*color[i] == '\0')
|
if (*color[i] == '\0')
|
||||||
break;
|
break;
|
||||||
if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
|
if (!XftColorAllocName(X_Dpy, sc->visual, sc->colormap,
|
||||||
DefaultColormap(X_Dpy, sc->which), color[i],
|
color[i], &sc->xftcolor[i]))
|
||||||
&sc->xftcolor[i]))
|
|
||||||
errx(1, "XftColorAllocName");
|
errx(1, "XftColorAllocName");
|
||||||
}
|
}
|
||||||
if (i == CWM_COLOR_MENU_MAX)
|
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,
|
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG].color,
|
||||||
sc->xftcolor[CWM_COLOR_MENU_FG].color, &c);
|
sc->xftcolor[CWM_COLOR_MENU_FG].color, &c);
|
||||||
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT].color, c, &c);
|
xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT].color, c, &c);
|
||||||
if (!XftColorAllocValue(X_Dpy, DefaultVisual(X_Dpy, sc->which),
|
if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap,
|
||||||
DefaultColormap(X_Dpy, sc->which), &c,
|
&c, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
|
||||||
&sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
|
|
||||||
errx(1, "XftColorAllocValue");
|
errx(1, "XftColorAllocValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
screen.c
2
screen.c
@@ -41,6 +41,8 @@ screen_init(struct screen_ctx *sc, u_int which)
|
|||||||
u_int nwins, i;
|
u_int nwins, i;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
xu_ewmh_net_supported(sc);
|
xu_ewmh_net_supported(sc);
|
||||||
|
|||||||
3
xutil.c
3
xutil.c
@@ -422,8 +422,7 @@ xu_getcolor(struct screen_ctx *sc, char *name)
|
|||||||
{
|
{
|
||||||
XColor color, tmp;
|
XColor color, tmp;
|
||||||
|
|
||||||
if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
|
if (!XAllocNamedColor(X_Dpy, sc->colormap, name, &color, &tmp)) {
|
||||||
name, &color, &tmp)) {
|
|
||||||
warnx("XAllocNamedColor error: '%s'", name);
|
warnx("XAllocNamedColor error: '%s'", name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user