Actual source code: wmap.c

petsc-3.3-p7 2013-05-11
  2: #include <../src/sys/draw/impls/x/ximpl.h>

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

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