Actual source code: wmap.c

      1: #define PETSC_DLL

     3:  #include src/sys/src/draw/impls/x/ximpl.h

      5: /*
      6:     This routine waits until the window is actually created or destroyed
      7:     Returns 0 if window is mapped; 1 if window is destroyed.
      8:  */
     11: PetscErrorCode Xi_wait_map(PetscDraw_X *XiWin)
     12: {
     13:   XEvent  event;
     14:   int     w,h;

     17:   /*
     18:    This is a bug.  XSelectInput should be set BEFORE the window is mapped
     19:   */
     20:   /*
     21:   XSelectInput(XiWin->disp,XiWin->win,ExposureMask | StructureNotifyMask);
     22:   */
     23:   while (1) {
     24:     XMaskEvent(XiWin->disp,ExposureMask | StructureNotifyMask,&event);
     25:     if (event.xany.window != XiWin->win) {
     26:       break;
     27:       /* Bug for now */
     28:     } else {
     29:       switch (event.type) {
     30:         case ConfigureNotify:
     31:         /* window has been moved or resized */
     32:         w         = event.xconfigure.width  - 2 * event.xconfigure.border_width;
     33:         h         = event.xconfigure.height - 2 * event.xconfigure.border_width;
     34:         XiWin->w  = w;
     35:         XiWin->h  = h;
     36:         break;
     37:       case DestroyNotify:
     38:         PetscFunctionReturn(1);
     39:       case Expose:
     40:         return(0);
     41:       /* else ignore event */
     42:       }
     43:     }
     44:   }
     45:   return(0);
     46: }