chiark / gitweb /
properly clear our window when we're embedded
authorian <ian>
Sat, 31 May 2008 21:31:24 +0000 (21:31 +0000)
committerian <ian>
Sat, 31 May 2008 21:31:24 +0000 (21:31 +0000)
hostside/gui-plan.c

index de3f45b4ee25916ad85cb360bad85d299cff157c..e764642370c03155129731ef948938c4d2a64623 100644 (file)
@@ -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) );