rem: WWorkspaceState *ws_state;
context: StartUp(Bool defaultScreenOnly){    WWorkspaceState *ws_state;    struct sigaction sig_action;    int j, max;    Atom atom[sizeof(atomNames)/sizeof(char*)];    /*     * Ignore CapsLock in modifiers     */    ValidModMask = 0xff & ~LockMask;    getOffendingModifiers();    /*     * Ignore NumLock and ScrollLock too     */    ValidModMask &= ~(_NumLockMask|_ScrollLockMask);    memset(&wKeyBindings, 0, sizeof(wKeyBindings));    wWinContext = XUniqueContext();    wAppWinContext = XUniqueContext();    wStackContext = XUniqueContext();    wVEdgeContext = XUniqueContext();    /*    _XA_VERSION = XInternAtom(dpy, "VERSION", False);*/#ifdef HAVE_XINTERNATOMS    XInternAtoms(dpy, atomNames, sizeof(atomNames)/sizeof(char*),                 False, atom);#else    {        int i;        for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) {            atom[i] = XInternAtom(dpy, atomNames[i], False);        }    }#endif    _XA_WM_STATE = atom[0];    _XA_WM_CHANGE_STATE = atom[1];    _XA_WM_PROTOCOLS = atom[2];    _XA_WM_TAKE_FOCUS = atom[3];    _XA_WM_DELETE_WINDOW = atom[4];    _XA_WM_SAVE_YOURSELF = atom[5];    _XA_WM_CLIENT_LEADER = atom[6];    _XA_WM_COLORMAP_WINDOWS = atom[7];    _XA_WM_COLORMAP_NOTIFY = atom[8];    _XA_WINDOWMAKER_MENU = atom[9];    _XA_WINDOWMAKER_STATE = atom[10];    _XA_WINDOWMAKER_WM_PROTOCOLS = atom[11];    _XA_WINDOWMAKER_WM_FUNCTION = atom[12];    _XA_WINDOWMAKER_NOTICEBOARD = atom[13];    _XA_WINDOWMAKER_COMMAND = atom[14];    _XA_WINDOWMAKER_ICON_SIZE = atom[15];    _XA_WINDOWMAKER_ICON_TILE = atom[16];    _XA_GNUSTEP_WM_ATTR = atom[17];    _XA_GNUSTEP_WM_MINIATURIZE_WINDOW = atom[18];    _XA_GNUSTEP_TITLEBAR_STATE = atom[19];#ifdef OFFIX_DND    _XA_DND_SELECTION = XInternAtom(dpy, "DndSelection", False);    _XA_DND_PROTOCOL = XInternAtom(dpy, "DndProtocol", False);#endif#ifdef XDND    wXDNDInitializeAtoms();#endif    /* cursors */    wCursor[WCUR_NORMAL] = None; /* inherit from root */    wCursor[WCUR_ROOT] = XCreateFontCursor(dpy, XC_left_ptr);    wCursor[WCUR_ARROW] = XCreateFontCursor(dpy, XC_top_left_arrow);    wCursor[WCUR_MOVE] = XCreateFontCursor(dpy, XC_fleur);    wCursor[WCUR_RESIZE] = XCreateFontCursor(dpy, XC_sizing);    wCursor[WCUR_TOPLEFTRESIZE] = XCreateFontCursor(dpy, XC_top_left_corner);    wCursor[WCUR_TOPRIGHTRESIZE] = XCreateFontCursor(dpy, XC_top_right_corner);    wCursor[WCUR_BOTTOMLEFTRESIZE] = XCreateFontCursor(dpy, XC_bottom_left_corner);    wCursor[WCUR_BOTTOMRIGHTRESIZE] = XCreateFontCursor(dpy, XC_bottom_right_corner);    wCursor[WCUR_VERTICALRESIZE] = XCreateFontCursor(dpy, XC_sb_v_double_arrow);    wCursor[WCUR_HORIZONRESIZE] = XCreateFontCursor(dpy, XC_sb_h_double_arrow);    wCursor[WCUR_WAIT] = XCreateFontCursor(dpy, XC_watch);    wCursor[WCUR_QUESTION] = XCreateFontCursor(dpy, XC_question_arrow);    wCursor[WCUR_TEXT]     = XCreateFontCursor(dpy, XC_xterm); /* odd name???*/    wCursor[WCUR_SELECT] = XCreateFontCursor(dpy, XC_cross);    {        Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1);        GC gc = XCreateGC(dpy, cur, 0, NULL);        XColor black;        memset(&black, 0, sizeof(XColor));        XSetForeground(dpy, gc, 0);        XFillRectangle(dpy, cur, gc, 0, 0, 16, 16);        XFreeGC(dpy, gc);        wCursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0);        XFreePixmap(dpy, cur);    }    /* signal handler stuff that gets called when a signal is caught */    WMAddPersistentTimerHandler(500, delayedAction, NULL);    /* emergency exit... */    sig_action.sa_handler = handleSig;    sigemptyset(&sig_action.sa_mask);    sig_action.sa_flags = SA_RESTART;    sigaction(SIGQUIT, &sig_action, NULL);    sigaction(SIGSEGV, &sig_action, NULL);    sigaction(SIGBUS, &sig_action, NULL);    sigaction(SIGFPE, &sig_action, NULL);    sigaction(SIGABRT, &sig_action, NULL);    sig_action.sa_handler = handleExitSig;    /* Here we set SA_RESTART for safety, because SIGUSR1 may not be handled     * immediately. -Dan */    sig_action.sa_flags = SA_RESTART;    sigaction(SIGTERM, &sig_action, NULL);    sigaction(SIGINT, &sig_action, NULL);    sigaction(SIGHUP, &sig_action, NULL);    sigaction(SIGUSR1, &sig_action, NULL);    sigaction(SIGUSR2, &sig_action, NULL);    /* ignore dead pipe */    /* Because POSIX mandates that only signal with handlers are reset     * accross an exec*(), we do not want to propagate ignoring SIGPIPEs     * to children. Hence the dummy handler.     * Philippe Troin <phil@fifi.org>     */    sig_action.sa_handler = &dummyHandler;    sig_action.sa_flags = SA_RESTART;    sigaction(SIGPIPE, &sig_action, NULL);    /* handle dead children */    sig_action.sa_handler = buryChild;    sig_action.sa_flags = SA_NOCLDSTOP|SA_RESTART;    sigaction(SIGCHLD, &sig_action, NULL);    /* Now we unblock all signals, that may have been blocked by the parent     * who exec()-ed us. This can happen for example if Window Maker crashes     * and restarts itself or another window manager from the signal handler.     * In this case, the new proccess inherits the blocked signal mask and     * will no longer react to that signal, until unblocked.     * This is because the signal handler of the proccess who crashed (parent)     * didn't return, and the signal remained blocked. -Dan     */    sigfillset(&sig_action.sa_mask);    sigprocmask(SIG_UNBLOCK, &sig_action.sa_mask, NULL);    /* handle X shutdowns a such */    XSetIOErrorHandler(handleXIO);    /* set hook for out event dispatcher in WINGs event dispatcher */    WMHookEventHandler(DispatchEvent);    /* initialize defaults stuff */    WDWindowMaker = wDefaultsInitDomain("WindowMaker", True);    if (!WDWindowMaker->dictionary) {        wwarning(_("could not read domain \"%s\" from defaults database"),                 "WindowMaker");    }    /* read defaults that don't change until a restart and are     * screen independent */    wReadStaticDefaults(WDWindowMaker ? WDWindowMaker->dictionary : NULL);    /* check sanity of some values */    if (wPreferences.icon_size < 16) {        wwarning(_("icon size is configured to %i, but it's too small. Using 16, instead\n"),                 wPreferences.icon_size);        wPreferences.icon_size = 16;    }    /* init other domains */    WDRootMenu = wDefaultsInitDomain("WMRootMenu", False);    if (!WDRootMenu->dictionary) {        wwarning(_("could not read domain \"%s\" from defaults database"),                 "WMRootMenu");    }    wDefaultsMergeGlobalMenus(WDRootMenu);    WDWindowAttributes = wDefaultsInitDomain("WMWindowAttributes", True);    if (!WDWindowAttributes->dictionary) {        wwarning(_("could not read domain \"%s\" from defaults database"),                 "WMWindowAttributes");    }    XSetErrorHandler((XErrorHandler)catchXError);#ifdef SHAPE    /* ignore j */    wShapeSupported = XShapeQueryExtension(dpy, &wShapeEventBase, &j);#endif#ifdef KEEP_XKB_LOCK_STATUS    wXkbSupported = XkbQueryExtension(dpy, NULL, &wXkbEventBase, NULL, NULL, NULL);    if(wPreferences.modelock && !wXkbSupported) {        wwarning(_("XKB is not supported. KbdModeLock is automatically disabled."));        wPreferences.modelock = 0;    }#endif    if (defaultScreenOnly) {        max = 1;    } else {        max = ScreenCount(dpy);    }    wScreen = wmalloc(sizeof(WScreen*)*max);    wScreenCount = 0;    /* manage the screens */    for (j = 0; j < max; j++) {        if (defaultScreenOnly || max==1) {            wScreen[wScreenCount] = wScreenInit(DefaultScreen(dpy));            if (!wScreen[wScreenCount]) {                wfatal(_("it seems that there is already a window manager running"));                Exit(1);            }        } else {            wScreen[wScreenCount] = wScreenInit(j);            if (!wScreen[wScreenCount]) {                wwarning(_("could not manage screen %i"), j);                continue;            }        }        wScreenCount++;    }#ifndef LITE    InitializeSwitchMenu();#endif    /* initialize/restore state for the screens */    for (j = 0; j < wScreenCount; j++) {        int crashed;        /* restore workspace state */        if (!getWorkspaceState(wScreen[j]->root_win, &ws_state)) {            ws_state = NULL;        }        wScreenRestoreState(wScreen[j]);        /* manage all windows that were already here before us */        if (!wPreferences.flags.nodock && wScreen[j]->dock)            wScreen[j]->last_dock = wScreen[j]->dock;        if (ws_state && (ws_state->flags & WFLAGS_CRASHED)!=0)            crashed = 1;        else            crashed = 0;        manageAllWindows(wScreen[j], crashed);        /* restore saved menus */        wMenuRestoreState(wScreen[j]);        /* If we're not restarting restore session */        if (ws_state == NULL && !wPreferences.flags.norestore)            wSessionRestoreState(wScreen[j]);        if (!wPreferences.flags.noautolaunch) {            /* auto-launch apps */            if (!wPreferences.flags.nodock && wScreen[j]->dock) {                wScreen[j]->last_dock = wScreen[j]->dock;                wDockDoAutoLaunch(wScreen[j]->dock, 0);            }            /* auto-launch apps in clip */            if (!wPreferences.flags.noclip) {                int i;                for(i=0; i<wScreen[j]->workspace_count; i++) {                    if (wScreen[j]->workspaces[i]->clip) {                        wScreen[j]->last_dock = wScreen[j]->workspaces[i]->clip;                        wDockDoAutoLaunch(wScreen[j]->workspaces[i]->clip, i);                    }                }            }        }        /* go to workspace where we were before restart */        if (ws_state) {            wWorkspaceForceChange(wScreen[j], ws_state->workspace);            wfree(ws_state);        } else {            wSessionRestoreLastWorkspace(wScreen[j]);        }#ifdef KWM_HINTS        wKWMSetInitializedHint(wScreen[j]);#endif    }    if (wScreenCount == 0) {        wfatal(_("could not manage any screen"));        Exit(1);    }    if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) {        /* setup defaults file polling */        WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL);    }}