Annotation of researchv9/X11/src/X.V11R1/clients/xmh/main.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char rcs_id[] = "$Header: main.c,v 1.13 87/09/11 08:18:11 toddb Exp $";
        !             3: #endif lint
        !             4: /*
        !             5:  *                       COPYRIGHT 1987
        !             6:  *                DIGITAL EQUIPMENT CORPORATION
        !             7:  *                    MAYNARD, MASSACHUSETTS
        !             8:  *                     ALL RIGHTS RESERVED.
        !             9:  *
        !            10:  * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
        !            11:  * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
        !            12:  * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR
        !            13:  * ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
        !            14:  *
        !            15:  * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS,
        !            16:  * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT
        !            17:  * SET FORTH ABOVE.
        !            18:  *
        !            19:  *
        !            20:  * Permission to use, copy, modify, and distribute this software and its
        !            21:  * documentation for any purpose and without fee is hereby granted, provided
        !            22:  * that the above copyright notice appear in all copies and that both that
        !            23:  * copyright notice and this permission notice appear in supporting documentation,
        !            24:  * and that the name of Digital Equipment Corporation not be used in advertising
        !            25:  * or publicity pertaining to distribution of the software without specific,
        !            26:  * written prior permission.
        !            27:  */
        !            28: 
        !            29: /* main.c */
        !            30: 
        !            31: #define MAIN 1                 /* Makes global.h actually declare vars */
        !            32: #include "xmh.h"
        !            33: #include <signal.h>
        !            34: 
        !            35: Boolean shouldcheckscans;      /* If it's time to check for rescanning */
        !            36: Boolean emptying = FALSE;      /* Whether we're currently in EmptyEventQueue. */
        !            37: 
        !            38: 
        !            39: /* Handle one event.  Will block if there are no events to handle. */
        !            40: 
        !            41: HandleEvent()
        !            42: {
        !            43:     XEvent event;
        !            44:     int     i;
        !            45:     static int lasttime, lastx, lasty;
        !            46:     static Window lastwin;
        !            47:     QXNextEvent(theDisplay, &event);
        !            48:     if (shouldcheckscans && !emptying) {
        !            49:        if (debug) {
        !            50:            (void) fprintf(stderr, "[magic toc check ...");
        !            51:            (void) fflush(stderr);
        !            52:        }
        !            53:        QXPutBackEvent(theDisplay, &event);
        !            54:        shouldcheckscans = FALSE;
        !            55:        for (i = 0; i < numScrns; i++) {
        !            56:            if (scrnList[i]->toc)
        !            57:                TocRecheckValidity(scrnList[i]->toc);
        !            58:            if (scrnList[i]->msg)
        !            59:                TocRecheckValidity(MsgGetToc(scrnList[i]->msg));
        !            60:        }
        !            61:        (void) alarm(5 * 60);
        !            62:        if (debug) {(void)fprintf(stderr, "done]\n");(void)fflush(stderr);}
        !            63:     }
        !            64:     else {
        !            65:        (void)XtDispatchEvent(&event);
        !            66: #ifdef X11
        !            67:        if (defDoubleClick) {
        !            68:            if (event.xany.type == ButtonPress && DoubleClickProc
        !            69:                && event.xbutton.window == lastwin
        !            70:                && event.xbutton.x == lastx && event.xbutton.y == lasty
        !            71:                && event.xbutton.time - lasttime <= 500) {
        !            72:                (*DoubleClickProc)(DoubleClickParam);
        !            73:                DoubleClickProc = NULL;
        !            74:            }
        !            75:            if (event.xany.type == ButtonRelease) {
        !            76:                lasttime = event.xbutton.time;
        !            77:                lastx = event.xbutton.x;
        !            78:                lasty = event.xbutton.y;
        !            79:                lastwin = event.xbutton.window;
        !            80:            } else DoubleClickProc = NULL;
        !            81:        }
        !            82: #endif X11
        !            83:        HandleConfirmEvent(&event);
        !            84:     }
        !            85: }
        !            86: 
        !            87: #ifdef X10
        !            88: EmptyEventQueue()
        !            89: {
        !            90:     XEvent event;
        !            91:     emptying = TRUE;
        !            92:     do {
        !            93:        while (XPending()) {
        !            94:            XPeekEvent(&event);
        !            95:            if (event.type & (KeyPressed | KeyReleased | MouseMoved |
        !            96:                              ButtonPressed | ButtonReleased))
        !            97:                XNextEvent(&event);
        !            98:            else
        !            99:                HandleEvent();
        !           100:        }
        !           101:        XSync(0);
        !           102:     } while (XPending());
        !           103:     emptying = FALSE;
        !           104: }
        !           105: #endif
        !           106: 
        !           107: 
        !           108: /* This gets called by the alarm clock every five minutes. */
        !           109: 
        !           110: NeedToCheckScans()
        !           111: {
        !           112:     shouldcheckscans = TRUE;
        !           113: }
        !           114: 
        !           115: 
        !           116: 
        !           117: #ifdef X11
        !           118: CheckMail(event)
        !           119: XEvent *event;
        !           120: {
        !           121:     static int count = 0;
        !           122:     int i;
        !           123:     if (event->type == ClientMessage &&
        !           124:            ((int)event->xclient.message_type) == XtTimerExpired) {
        !           125:        if (defNewMailCheck) {
        !           126: if (debug) {(void)fprintf(stderr, "(Checking for new mail..."); (void)fflush(stderr);}
        !           127:            TocCheckForNewMail();
        !           128: if (debug) (void)fprintf(stderr, "done)\n");
        !           129:        }
        !           130:        if (defMakeCheckpoints && count++ % 5 == 0) {
        !           131: if (debug) {(void)fprintf(stderr, "(Checkpointing..."); (void)fflush(stderr);}
        !           132:            for (i=0 ; i<numScrns ; i++)
        !           133:                if (scrnList[i]->msg) 
        !           134:                    MsgCheckPoint(scrnList[i]->msg);
        !           135: if (debug) (void)fprintf(stderr, "done)\n");
        !           136:        }
        !           137:     }
        !           138: }
        !           139: #endif X11
        !           140: 
        !           141: /* Main loop. */
        !           142: 
        !           143: main(argc, argv)
        !           144: int argc;
        !           145: char **argv;
        !           146: {
        !           147:     InitializeWorld(argc, argv);
        !           148:     shouldcheckscans = TRUE;
        !           149:     (void) signal(SIGALRM, NeedToCheckScans);
        !           150: #ifdef X11
        !           151:     if (defNewMailCheck)
        !           152:        TocCheckForNewMail();
        !           153:     if (defNewMailCheck || defMakeCheckpoints) {
        !           154:        XtSetEventHandler(theDisplay, DefaultRootWindow(theDisplay), CheckMail,
        !           155:                          StructureNotifyMask, (caddr_t)NULL);
        !           156:        XtSetTimeOut(DefaultRootWindow(theDisplay), (caddr_t)NULL, (int)60000);
        !           157:     }
        !           158: #endif X11
        !           159:     for (;;) {
        !           160:        HandleEvent();
        !           161:     }
        !           162: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.