Make sure a window has a visual before dereferencing it. Fixes issue #195.

This commit is contained in:
Kris Maglione 2010-06-21 10:29:51 -04:00
parent 0855f12de8
commit 2177aed027
2 changed files with 2 additions and 1 deletions

View File

@ -7,7 +7,7 @@ ulong
pixelvalue(Window *w, Color *c) { pixelvalue(Window *w, Color *c) {
XColor xc; XColor xc;
if(w->visual->class != TrueColor) { if(w->visual == nil || w->visual->class != TrueColor) {
if(c->pixel != ~0UL) if(c->pixel != ~0UL)
return c->pixel; return c->pixel;
xc.red = c->red; xc.red = c->red;

View File

@ -68,6 +68,7 @@ initdisplay(void) {
scr.depth = DefaultDepth(display, scr.screen); scr.depth = DefaultDepth(display, scr.screen);
scr.root.xid = RootWindow(display, scr.screen); scr.root.xid = RootWindow(display, scr.screen);
scr.root.visual = scr.visual;
scr.root.r = Rect(0, 0, scr.root.r = Rect(0, 0,
DisplayWidth(display, scr.screen), DisplayWidth(display, scr.screen),
DisplayHeight(display, scr.screen)); DisplayHeight(display, scr.screen));