~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/Wait.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Motif Tools Library, Version 3.1
 
3
 * $Id$
 
4
 * 
 
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.
 
10
 *
 
11
 * $Log$
 
12
 * Revision 1.1.1.1  2001/07/18 11:06:03  root
 
13
 * Initial checkin.
 
14
 *
 
15
 * Revision 1.2  2001/06/12 16:25:28  andre
 
16
 * *** empty log message ***
 
17
 *
 
18
 *
 
19
 */
 
20
 
 
21
#include <Xmt/Xmt.h>
 
22
#include <Xmt/Util.h>
 
23
 
 
24
/*
 
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.
 
27
 */
 
28
 
 
29
/*
 
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.
 
35
 *
 
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.
 
41
 *
 
42
 * The argument to ForceDialog is any widget in the dialog (often it
 
43
 * will be the BulletinBoard child of a DialogShell).
 
44
 */
 
45
 
 
46
#if NeedFunctionPrototypes
 
47
void XmtWaitUntilMapped(Widget w)
 
48
#else
 
49
void XmtWaitUntilMapped(w)
 
50
Widget w;
 
51
#endif
 
52
{
 
53
    Widget diashell, topshell;
 
54
    Window diawindow, topwindow;
 
55
    Display *dpy;
 
56
    XWindowAttributes xwa;
 
57
    XEvent event;
 
58
    XtAppContext cxt;
 
59
    
 
60
    for (diashell = w; !XtIsShell(diashell); diashell = XtParent(diashell)) ;
 
61
    for (topshell = diashell;
 
62
         !XtIsTopLevelShell(topshell);
 
63
         topshell = XtParent(topshell));
 
64
    
 
65
    if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
 
66
        dpy = XtDisplay(topshell);
 
67
        diawindow = XtWindow(diashell);
 
68
        topwindow = XtWindow(topshell);
 
69
        cxt = XtWidgetToApplicationContext(diashell);
 
70
        
 
71
        /* Wait for the dialog to be mapped. */
 
72
        while (XGetWindowAttributes(dpy, diawindow, &xwa),
 
73
               xwa.map_state != IsViewable) {
 
74
            
 
75
            /*
 
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
 
79
             */
 
80
            if ((topwindow != diawindow) &&
 
81
                (XGetWindowAttributes(dpy, topwindow, &xwa),
 
82
                 xwa.map_state != IsViewable))
 
83
                break;
 
84
 
 
85
            /*
 
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.
 
89
             */
 
90
            XtAppNextEvent(cxt, &event);
 
91
            XtDispatchEvent(&event);
 
92
        }
 
93
    }
 
94
    
 
95
    /* The next XSync() will get an expose event if the dialog was unmapped. */
 
96
    XmUpdateDisplay(topshell);
 
97
}