From: ian Date: Sat, 31 May 2008 21:31:24 +0000 (+0000) Subject: properly clear our window when we're embedded X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=19927e54883079cc06987e3b56ca8d8aae203208;p=trains.git properly clear our window when we're embedded --- diff --git a/hostside/gui-plan.c b/hostside/gui-plan.c index de3f45b..e764642 100644 --- a/hostside/gui-plan.c +++ b/hostside/gui-plan.c @@ -76,7 +76,7 @@ static SegState *state; static SegmovfeatState *states_head; static Display *d; static oop_source_sys *sys_events; -static Window w=None; +static Window w; static int redraw_needed_count, expose_count; static Pixmap bg_pixmap; static unsigned long train_pixel, owned_pixel; @@ -779,6 +779,7 @@ int main(int argc, const char *const *argv) { XpmAttributes mattribs; XWindowAttributes wattribs; int segment_ix, movfeat_ix, posn, invert, det, oor, infd; + Window wspec=None; XGCValues gcv; XColor colour; SegmovfeatState *fs; @@ -814,18 +815,20 @@ int main(int argc, const char *const *argv) { } else if (arg[0]=='-') { die("invalid option(s)"); } else { - errno=0; w= strtoul(arg,&ep,0); - if (errno || ep==arg || *ep || w==None) die("bad windowid"); + errno=0; wspec= strtoul(arg,&ep,0); + if (errno || ep==arg || *ep || wspec==None) die("bad windowid"); } } d= XOpenDisplay(0); if (!d) die("XOpenDisplay failed"); - if (w==None) { + if (wspec==None) { w= XCreateSimpleWindow(d, DefaultRootWindow(d), 0,0, ui_plan_data.xsz, ui_plan_data.ysz, 0,0, 0); if (w == None) diex("XCreateSimpleWindow", "initial"); + } else { + w= wspec; } XCALL( XGetWindowAttributes, 0, (d,w,&wattribs) ); @@ -922,7 +925,7 @@ int main(int argc, const char *const *argv) { XCALL( XSelectInput, 0, (d,w, ExposureMask) ); - if (arg) { + if (wspec!=None) { XCALL( XClearArea, "initial", (d,w, 0,0,0,0, True) ); } else { XCALL( XMapWindow, 0, (d,w) );