| @@ -80,12 +80,11 @@ void xft_alloc_color(const win_env_t *e, const char *name, XftColor *col) |
| 80 | 80 | | } |
| 81 | 81 | | #endif /* HAVE_LIBFONTS */ |
| 82 | 82 | | |
| 83 | | − | void win_alloc_color(const win_env_t *e, const char *name, unsigned long *pixel) |
| 83 | + | void win_alloc_color(const win_env_t *e, const char *name, XColor *col) |
| 84 | 84 | | { |
| 85 | | − | XColor screen, exact; |
| 86 | | − | if (!XAllocNamedColor(e->dpy, e->cmap, name, &screen, &exact)) |
| 85 | + | XColor screen; |
| 86 | + | if (!XAllocNamedColor(e->dpy, e->cmap, name, &screen, col)) |
| 87 | 87 | | error(EXIT_FAILURE, 0, "Error allocating color '%s'", name); |
| 88 | | − | *pixel = exact.pixel; |
| 89 | 88 | | } |
| 90 | 89 | | |
| 91 | 90 | | const char* win_res(XrmDatabase db, const char *name, const char *def) |
| @@ -112,9 +111,6 @@ void win_init(win_t *win) |
| 112 | 111 | | #endif |
| 113 | 112 | | char *res_man; |
| 114 | 113 | | XrmDatabase db; |
| 115 | | − | XVisualInfo vis; |
| 116 | | − | XWindowAttributes attr; |
| 117 | | − | Window parent; |
| 118 | 114 | | |
| 119 | 115 | | memset(win, 0, sizeof(win_t)); |
| 120 | 116 | | |
| @@ -125,19 +121,9 @@ void win_init(win_t *win) |
| 125 | 121 | | e->scr = DefaultScreen(e->dpy); |
| 126 | 122 | | e->scrw = DisplayWidth(e->dpy, e->scr); |
| 127 | 123 | | e->scrh = DisplayHeight(e->dpy, e->scr); |
| 128 | | − | |
| 129 | | − | parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); |
| 130 | | − | |
| 131 | | − | if (options->embed == 0) { |
| 132 | | − | e->depth = DefaultDepth(e->dpy, e->scr); |
| 133 | | − | } else { |
| 134 | | − | XGetWindowAttributes(e->dpy, parent, &attr); |
| 135 | | − | e->depth = attr.depth; |
| 136 | | − | } |
| 137 | | − | |
| 138 | | − | XMatchVisualInfo(e->dpy, e->scr, e->depth, TrueColor, &vis); |
| 139 | | − | e->vis = vis.visual; |
| 140 | | − | e->cmap = XCreateColormap(e->dpy, parent, e->vis, None); |
| 124 | + | e->depth = DefaultDepth(e->dpy, e->scr); |
| 125 | + | e->vis = DefaultVisual(e->dpy, e->scr); |
| 126 | + | e->cmap = DefaultColormap(e->dpy, e->scr); |
| 141 | 127 | | |
| 142 | 128 | | if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0) |
| 143 | 129 | | error(0, 0, "No locale support"); |
| @@ -197,6 +183,7 @@ void win_open(win_t *win) |
| 197 | 183 | | XWMHints hints; |
| 198 | 184 | | pid_t pid; |
| 199 | 185 | | char hostname[256]; |
| 186 | + | XSetWindowAttributes attrs; |
| 200 | 187 | | |
| 201 | 188 | | e = &win->env; |
| 202 | 189 | | parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); |
| @@ -238,8 +225,12 @@ void win_open(win_t *win) |
| 238 | 225 | | win->y = 0; |
| 239 | 226 | | } |
| 240 | 227 | | |
| 228 | + | attrs.colormap = e->cmap; |
| 229 | + | attrs.border_pixel = 0; |
| 230 | + | |
| 241 | 231 | | win->xwin = XCreateWindow(e->dpy, parent, win->x, win->y, win->w, win->h, 0, |
| 242 | | − | e->depth, InputOutput, e->vis, 0, NULL); |
| 232 | + | e->depth, InputOutput, e->vis, |
| 233 | + | CWColormap | CWBorderPixel, &attrs); |
| 243 | 234 | | if (win->xwin == None) |
| 244 | 235 | | error(EXIT_FAILURE, 0, "Error creating X window"); |
| 245 | 236 | | |
| @@ -317,7 +308,7 @@ void win_open(win_t *win) |
| 317 | 308 | | win->buf.h = e->scrh; |
| 318 | 309 | | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, win->buf.w, win->buf.h, e->depth); |
| 319 | 310 | | |
| 320 | | − | XSetForeground(e->dpy, gc, win->win_bg); |
| 311 | + | XSetForeground(e->dpy, gc, win->win_bg.pixel); |
| 321 | 312 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 322 | 313 | | XSetWindowBackgroundPixmap(e->dpy, win->xwin, win->buf.pm); |
| 323 | 314 | | XMapWindow(e->dpy, win->xwin); |
| @@ -398,7 +389,7 @@ void win_clear(win_t *win) |
| 398 | 389 | | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, |
| 399 | 390 | | win->buf.w, win->buf.h, e->depth); |
| 400 | 391 | | } |
| 401 | | − | XSetForeground(e->dpy, gc, win->win_bg); |
| 392 | + | XSetForeground(e->dpy, gc, win->win_bg.pixel); |
| 402 | 393 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 403 | 394 | | } |
| 404 | 395 | | |
| @@ -455,7 +446,7 @@ void win_draw_bar(win_t *win) |
| 455 | 446 | | XSetForeground(e->dpy, gc, win->bar_bg.pixel); |
| 456 | 447 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h); |
| 457 | 448 | | |
| 458 | | − | XSetForeground(e->dpy, gc, win->win_bg); |
| 449 | + | XSetForeground(e->dpy, gc, win->win_bg.pixel); |
| 459 | 450 | | XSetBackground(e->dpy, gc, win->bar_bg.pixel); |
| 460 | 451 | | |
| 461 | 452 | | if ((len = strlen(r->buf)) > 0) { |