home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / 15771 < prev    next >
Encoding:
Text File  |  1992-08-27  |  2.5 KB  |  101 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!mcsun!Germany.EU.net!rrz.uni-koeln.de!risc3.mi.uni-koeln.de!mm
  3. From: mm@risc3.mi.uni-koeln.de (Martin Malich)
  4. Subject: Re: how to implement slow calback routines ?
  5. Message-ID: <1992Aug28.065258.161670@rrz.uni-koeln.de>
  6. Sender: news@rrz.uni-koeln.de (Usenet News System)
  7. Reply-To: mm@risc3.mi.uni-koeln.de (Martin Malich)
  8. Organization: Universit"at zu K"oln
  9. References: <1992Aug27.130557.6965@dxcern.cern.ch> <1992Aug27.172308.26372@sj.nec.com>
  10. Distribution: comp
  11. Date: Fri, 28 Aug 92 06:52:58 GMT
  12. Lines: 87
  13.  
  14.  
  15. The following code can be used to wait until a specific widget
  16. is displayed on the screen.
  17.  
  18. Call ForceWidget(msgbox) to solve your problem.
  19.  
  20.  
  21.  
  22. void ForceDialog(Widget w)
  23. {
  24.   Widget diashell, topshell;
  25.   Window diawindow, topwindow;
  26.   Display *dpy;
  27.   XWindowAttributes xwa;
  28.   XEvent event;
  29.   XtAppContext cxt;
  30.  
  31. /* Locate the shell we are interested in.  In a particular instance,
  32. you
  33.  * may know these shells already.
  34.  */
  35.  
  36.   for (diashell = w;
  37.        !XtIsShell(diashell);
  38.        diashell = XtParent(diashell))
  39.     ;
  40.  
  41. /* Locate its primary window's shell (which may be the same) */
  42.  
  43.   for (topshell = diashell;
  44.        !XtIsTopLevelShell(topshell);
  45.        topshell = XtParent(topshell))
  46.     ;
  47.  
  48.   if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
  49.     dpy = XtDisplay(topshell);
  50.     diawindow = XtWindow(diashell);
  51.     topwindow = XtWindow(topshell);
  52.     cxt = XtWidgetToApplicationContext(diashell);
  53.  
  54. /* Wait for the dialog to be mapped.  It's guaranteed to become so
  55. unless... */
  56.  
  57.     while (XGetWindowAttributes(dpy, diawindow, &xwa),
  58.            xwa.map_state != IsViewable) {
  59.  
  60. /* ...if the primary is (or becomes) unviewable or unmapped, it's
  61.    probably iconified, and nothing will happen. */
  62.  
  63.       if (XGetWindowAttributes(dpy, topwindow, &xwa),
  64.           xwa.map_state != IsViewable)
  65.         break;
  66.  
  67. /* At this stage, we are guaranteed there will be an event of some
  68. kind.
  69.    Beware; we are presumably in a callback, so this can recurse. */
  70.  
  71.       XtAppNextEvent(cxt, &event);
  72.       XtDispatchEvent(&event);
  73.     }
  74.   }
  75. /* The next XSync() will get an expose event if the dialog was
  76. unmapped. */
  77.  
  78.   XmUpdateDisplay(topshell);
  79. }
  80.  
  81.  
  82.  
  83. hope this will help.
  84.  
  85.  
  86.  
  87.  
  88. ----------------------------------------------------------------------
  89. -------
  90. Martin Malich (mm@risc3.mi.uni-koeln.de)
  91.  
  92. Universit"at zu K"oln
  93. Mathematisches Institut
  94. Lehrstuhl Prof.Dr.A.Bachem
  95. Weyertal 86-90
  96. 5000 K"oln 41
  97. Germany
  98. ----------------------------------------------------------------------
  99. -------
  100.  
  101.