Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Motif FAQ (Part 6 of 9)
Section - 223) How can I force a dialog window to display?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Property taxes ]


Top Document: Motif FAQ (Part 6 of 9)
Previous Document: 222) Why do dialog title bars have "_popup" or "<-popup"
Next Document: 224) How can I control placement of a popup widget? Each time a
See reader questions & answers on this topic! - Help others by sharing your knowledge

I manage a "working" dialog, and do some computing, but the dialog window
appears blank until the work has finished.  How can I force it to be
displayed?
[Last modified: Dec '94]

Answer: David Brooks <dbrooks@ics.com> writes: The dialog window won't get
expose events until the window manager has fielded the map request, done the
reparenting with all that entails, and finally convinced the server that the
window is for real.  The safe way of doing it is [below].

Use this.  (David Brooks, Systems Engineering, Open Software Foundation)

/*
* This procedure will ensure that, if a dialog window is being mapped,
* its contents become visible before returning.  It is intended to be
* used just before a bout of computing that doesn't service the display.
* You should still call XmUpdateDisplay() at intervals during this
* computing if possible.
*
* The monitoring of window states is necessary because attempts to map
* the dialog are redirected to the window manager (if there is one) and
* this introduces a significant delay before the window is actually mapped
* and exposed.  This code works under mwm, twm, uwm, and no-wm.  It
* doesn't work (but doesn't hang) with olwm if the mainwindow is iconified.
*
* The argument to ForceDialog is any widget in the dialog (often it
* will be the BulletinBoard child of a DialogShell).
*/

ForceDialog(w)
Widget w;
{
Widget diashell, topshell;
Window diawindow, topwindow;
Display *dpy;
XWindowAttributes xwa;
XEvent event;
XtAppContext cxt;

/* Locate the shell we are interested in.  In a particular instance, you
* may know these shells already.
*/

for (diashell = w;
!XtIsShell(diashell);
diashell = XtParent(diashell))
;

/* Locate its primary window's shell (which may be the same) */

for (topshell = diashell;
!XtIsTopLevelShell(topshell);
topshell = XtParent(topshell))
;

if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
dpy = XtDisplay(topshell);
diawindow = XtWindow(diashell);
topwindow = XtWindow(topshell);
cxt = XtWidgetToApplicationContext(diashell);

/* Wait for the dialog to be mapped.  It's guaranteed to become so unless... */

while (XGetWindowAttributes(dpy, diawindow, &xwa),
   xwa.map_state != IsViewable) {

/* ...if the primary is (or becomes) unviewable or unmapped, it's
probably iconified, and nothing will happen. */

if (XGetWindowAttributes(dpy, topwindow, &xwa),
  xwa.map_state != IsViewable)
break;

/* At this stage, we are guaranteed there will be an event of some kind.
Beware; we are presumably in a callback, so this can recurse. */

XtAppNextEvent(cxt, &event);
XtDispatchEvent(&event);
}
}

/* The next XSync() will get an expose event if the dialog was unmapped. */

XmUpdateDisplay(topshell);
}


User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: Motif FAQ (Part 6 of 9)
Previous Document: 222) Why do dialog title bars have "_popup" or "<-popup"
Next Document: 224) How can I control placement of a popup widget? Each time a

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
kenton@rahul.net (Ken Lee)





Last Update March 27 2014 @ 02:11 PM