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

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/Screen.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/ScreenP.h>
 
23
#include <Xmt/AppResP.h>
 
24
#include <Xmt/Hash.h>
 
25
#include <X11/IntrinsicP.h>
 
26
 
 
27
 
 
28
/* ARGSUSED */
 
29
#if NeedFunctionPrototypes
 
30
static void DestroyCallback(Widget w, XtPointer tag, XtPointer data)
 
31
#else
 
32
static void DestroyCallback(w, tag, data)
 
33
Widget w;
 
34
XtPointer tag;
 
35
XtPointer data;
 
36
#endif
 
37
{
 
38
    XmtPerScreenInfo *info = (XmtPerScreenInfo *)tag;
 
39
    XmtAppResources *app = XmtGetApplicationResources(w);
 
40
 
 
41
    /* remove the info structure from the per-screen hash table */
 
42
    XmtHashTableDelete(app->screen_table, (XtPointer)XtScreen(w));
 
43
 
 
44
    /*
 
45
     * Free array of dialogs.
 
46
     * The dialogs themselves will be destroyed by whatever destroyed
 
47
     * the shell.
 
48
     */
 
49
    XtFree((char *)info->help_dialog_cache.dialogs);
 
50
 
 
51
    /* free the info structure itself */
 
52
    XtFree((char *)info);
 
53
}
 
54
 
 
55
/*
 
56
 * We cache dialogs by appshell and by screen.
 
57
 * XXX a 2D hashtable would be nice here, so we don't do a double lookup.
 
58
 */
 
59
#if NeedFunctionPrototypes
 
60
XmtPerScreenInfo *XmtGetPerScreenInfo(Widget w)
 
61
#else
 
62
XmtPerScreenInfo *XmtGetPerScreenInfo(w)
 
63
Widget w;
 
64
#endif
 
65
{
 
66
    XmtAppResources *app = XmtGetApplicationResources(w);
 
67
    XmtPerScreenInfo *info;
 
68
    Screen *screen = XtScreenOfObject(w);
 
69
    Widget shell;
 
70
    Boolean status;
 
71
 
 
72
    status = XmtHashTableLookup(app->screen_table,
 
73
                                (XtPointer) screen,
 
74
                                (XtPointer *) &info);
 
75
 
 
76
    if (!status) {
 
77
        info = (XmtPerScreenInfo *) XtCalloc(1, sizeof(XmtPerScreenInfo));
 
78
        /*
 
79
         * the info->topmost_shell field is the highest level shell on this
 
80
         * screen within the widget hierarchy.  It might be the root shell or
 
81
         * it might not be.  I assert that the algorithm below always yields
 
82
         * a shell widget, but it doesn't really matter.
 
83
         */
 
84
        for(shell=NULL; w; shell = w, w = XtParent(w)) {
 
85
            if (!XtIsWidget(w)) continue;
 
86
            if (w->core.screen != screen) break;
 
87
        }
 
88
 
 
89
        info->topmost_shell = shell;
 
90
        XtAddCallback(shell, XtNdestroyCallback,
 
91
                      DestroyCallback, (XtPointer) info);
 
92
        XmtHashTableStore(app->screen_table,
 
93
                          (XtPointer) screen,
 
94
                          (XtPointer) info);
 
95
    }
 
96
 
 
97
    return info;
 
98
}