source: trunk/third/xmh/main.c @ 9658

Revision 9658, 4.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9657, which included commits to RCS files with non-trunk default branches.
Line 
1/* $XConsortium: main.c,v 2.28 91/07/22 21:50:02 converse Exp $
2 *
3 *
4 *                     COPYRIGHT 1987, 1989
5 *                 DIGITAL EQUIPMENT CORPORATION
6 *                     MAYNARD, MASSACHUSETTS
7 *                      ALL RIGHTS RESERVED.
8 *
9 * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
10 * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
11 * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR
12 * ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
13 *
14 * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
15 * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
16 * ADDITION TO THAT SET FORTH ABOVE.
17 *
18 * Permission to use, copy, modify, and distribute this software and its
19 * documentation for any purpose and without fee is hereby granted, provided
20 * that the above copyright notice appear in all copies and that both that
21 * copyright notice and this permission notice appear in supporting
22 * documentation, and that the name of Digital Equipment Corporation not be
23 * used in advertising or publicity pertaining to distribution of the software
24 * without specific, written prior permission.
25 */
26
27#define MAIN 1                  /* Makes global.h actually declare vars */
28#include "xmh.h"
29
30/*ARGSUSED*/
31static void NeedToCheckScans(client_data, id)
32    XtPointer client_data;
33    XtIntervalId *id;           /* unused */
34{
35    int i;
36    if (!subProcessRunning) {
37        DEBUG("[magic toc check ...")
38        for (i = 0; i < numScrns; i++) {
39            if (scrnList[i]->toc)
40                TocRecheckValidity(scrnList[i]->toc);
41            if (scrnList[i]->msg)
42                TocRecheckValidity(MsgGetToc(scrnList[i]->msg));
43        }
44        DEBUG(" done]\n")
45    }
46    (void) XtAppAddTimeOut((XtAppContext)client_data,
47                           (unsigned long) app_resources.rescan_interval,
48                           NeedToCheckScans, client_data);
49}
50
51/*ARGSUSED*/
52static void Checkpoint(client_data, id)
53    XtPointer client_data;
54    XtIntervalId *id;           /* unused */
55{
56    extern void XmhWMProtocols();
57
58    if (!subProcessRunning) {
59        Cardinal n = 1;
60        String params = "wm_save_yourself";
61        DEBUG("(Checkpointing...")
62        XmhWMProtocols(NULL, NULL, &params, &n);
63        DEBUG(" done)\n")
64    }
65    (void) XtAppAddTimeOut((XtAppContext)client_data,
66                           (unsigned long) app_resources.checkpoint_interval,
67                           Checkpoint, client_data);
68}
69
70/*ARGSUSED*/
71static void CheckMail(client_data, id)
72    XtPointer client_data;
73    XtIntervalId *id;           /* unused */
74{
75    extern void XmhCheckForNewMail();
76
77    if (!subProcessRunning) {
78        DEBUG("(Checking for new mail...")
79        XmhCheckForNewMail(NULL, NULL, NULL, NULL);
80        DEBUG(" done)\n")
81    }
82    (void) XtAppAddTimeOut((XtAppContext)client_data,
83                           (unsigned long) app_resources.mail_interval,
84                           CheckMail, client_data);
85}
86
87/* Main loop. */
88
89#ifdef DEBUG_CLEANUP
90Boolean ExitLoop = FALSE;
91#endif
92
93main(argc, argv)
94int argc;
95char **argv;
96{
97    XtAppContext appCtx;
98
99    InitializeWorld(argc, argv);
100    subProcessRunning = False;
101    appCtx = XtWidgetToApplicationContext(toplevel);
102    (void) XtAppSetWarningMsgHandler(appCtx, PopupWarningHandler);
103
104    if (app_resources.new_mail_check && app_resources.mail_interval > 0) {
105        app_resources.mail_interval *= 60000;
106        (void) XtAppAddTimeOut(appCtx, (unsigned long) 0,
107                               CheckMail, (XtPointer)appCtx);
108    }
109    if (app_resources.rescan_interval > 0) {
110        app_resources.rescan_interval *= 60000;
111        (void) XtAppAddTimeOut(appCtx,
112                               (unsigned long) app_resources.rescan_interval,
113                               NeedToCheckScans, (XtPointer)appCtx);
114    }
115    if (app_resources.make_checkpoints &&
116        app_resources.checkpoint_interval > 0) {
117        app_resources.checkpoint_interval *= 60000;
118        (void) XtAppAddTimeOut(appCtx, (unsigned long)
119                               app_resources.checkpoint_interval,
120                               Checkpoint, (XtPointer)appCtx);
121    }
122
123    lastInput.win = -1;         /* nothing mapped yet */
124#ifdef DEBUG_CLEANUP
125    while (!ExitLoop) {
126#else
127    for (;;) {
128#endif
129        XEvent ev;
130        XtAppNextEvent( appCtx, &ev );
131        if (ev.type == KeyPress) {
132            lastInput.win = ev.xany.window;
133            lastInput.x = ev.xkey.x_root;
134            lastInput.y = ev.xkey.y_root;
135        } else if (ev.type == ButtonPress) {
136            lastInput.win = ev.xany.window;
137            lastInput.x = ev.xbutton.x_root;
138            lastInput.y = ev.xbutton.y_root;
139        }
140        XtDispatchEvent( &ev );
141    }
142#ifdef DEBUG_CLEANUP
143    XtDestroyApplicationContext(appCtx);
144    exit(0);
145#endif   
146}
Note: See TracBrowser for help on using the repository browser.