2
* Motif Tools Library, Version 3.1
5
* Written by David Flanagan.
6
* Copyright (c) 1992-2001 by David Flanagan.
7
* All Rights Reserved. See the file COPYRIGHT for details.
8
* This is open source software. See the file LICENSE for details.
9
* There is no warranty for this software. See NO_WARRANTY for details.
12
* Revision 1.1.1.1 2001/07/18 11:06:03 root
15
* Revision 1.2 2001/06/12 16:25:28 andre
16
* *** empty log message ***
25
* The following procedure is by David Brooks of the OSF and appears in
26
* the Motif FAQ list. It has been renamed for the Xmt library.
30
* This procedure will ensure that, if a dialog window is being mapped,
31
* its contents become visible before returning. It is intended to be
32
* used just before a bout of computing that doesn't service the display.
33
* You should still call XmUpdateDisplay() at intervals during this
34
* computing if possible.
36
* The monitoring of window states is necessary because attempts to map
37
* the dialog are redirected to the window manager (if there is one) and
38
* this introduces a significant delay before the window is actually mapped
39
* and exposed. This code works under mwm, twm, uwm, and no-wm. It
40
* doesn't work (but doesn't hang) with olwm if the mainwindow is iconified.
42
* The argument to ForceDialog is any widget in the dialog (often it
43
* will be the BulletinBoard child of a DialogShell).
46
#if NeedFunctionPrototypes
47
void XmtWaitUntilMapped(Widget w)
49
void XmtWaitUntilMapped(w)
53
Widget diashell, topshell;
54
Window diawindow, topwindow;
56
XWindowAttributes xwa;
60
for (diashell = w; !XtIsShell(diashell); diashell = XtParent(diashell)) ;
61
for (topshell = diashell;
62
!XtIsTopLevelShell(topshell);
63
topshell = XtParent(topshell));
65
if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
66
dpy = XtDisplay(topshell);
67
diawindow = XtWindow(diashell);
68
topwindow = XtWindow(topshell);
69
cxt = XtWidgetToApplicationContext(diashell);
71
/* Wait for the dialog to be mapped. */
72
while (XGetWindowAttributes(dpy, diawindow, &xwa),
73
xwa.map_state != IsViewable) {
76
* unless the primary is (or becomes) unviewable or unmapped, it's
77
* probably iconified, and nothing will happen.
78
* We make an exception to this case when topwindow==diawindow
80
if ((topwindow != diawindow) &&
81
(XGetWindowAttributes(dpy, topwindow, &xwa),
82
xwa.map_state != IsViewable))
86
* At this stage, we are guaranteed there will be
87
* an event of some kind. Beware; we are presumably
88
* in a callback, so this can recurse.
90
XtAppNextEvent(cxt, &event);
91
XtDispatchEvent(&event);
95
/* The next XSync() will get an expose event if the dialog was unmapped. */
96
XmUpdateDisplay(topshell);