rem: XSetErrorHandler((XErrorHandler)catchXError);
context: StartUp(Bool defaultScreenOnly){    WWorkspaceState *ws_state;    struct sigaction sig_action;    int j, max;    /*     * 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();    _XA_WM_STATE = XInternAtom(dpy, "WM_STATE", False);    _XA_WM_CHANGE_STATE = XInternAtom(dpy, "WM_CHANGE_STATE", False);    _XA_WM_PROTOCOLS = XInternAtom(dpy, "WM_PROTOCOLS", False);    _XA_WM_TAKE_FOCUS = XInternAtom(dpy, "WM_TAKE_FOCUS", False);    _XA_WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False);    _XA_WM_SAVE_YOURSELF = XInternAtom(dpy, "WM_SAVE_YOURSELF", False);        _XA_WM_CLIENT_LEADER = XInternAtom(dpy, "WM_CLIENT_LEADER", False);    _XA_WM_COLORMAP_WINDOWS = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);        _XA_GNUSTEP_WM_ATTR = XInternAtom(dpy, GNUSTEP_WM_ATTR_NAME, False);#ifdef MWM_HINTS    _XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);#endif    _XA_WINDOWMAKER_MENU = XInternAtom(dpy, "_WINDOWMAKER_MENU", False);    _XA_WINDOWMAKER_STATE = XInternAtom(dpy, "_WINDOWMAKER_STATE", False);    _XA_WINDOWMAKER_WM_PROTOCOLS =      XInternAtom(dpy, "_WINDOWMAKER_WM_PROTOCOLS", False);    _XA_WINDOWMAKER_WM_MINIATURIZE_WINDOW =       XInternAtom(dpy, WINDOWMAKER_WM_MINIATURIZE_WINDOW, False);        _XA_GNUSTEP_WM_RESIZEBAR =      XInternAtom(dpy, GNUSTEP_WM_RESIZEBAR, False);    _XA_WINDOWMAKER_WM_FUNCTION = XInternAtom(dpy, "_WINDOWMAKER_WM_FUNCTION",					  False);#ifdef OFFIX_DND    _XA_DND_SELECTION = XInternAtom(dpy, "DndSelection", False);    _XA_DND_PROTOCOL = XInternAtom(dpy, "DndProtocol", False);#endif    /* cursors */    wCursor[WCUR_NORMAL] = 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_WAIT] = XCreateFontCursor(dpy, XC_watch);    wCursor[WCUR_QUESTION] = XCreateFontCursor(dpy, XC_question_arrow);    wCursor[WCUR_TEXT]     = XCreateFontCursor(dpy, XC_xterm); /* odd name???*/        /* emergency exit... */    sig_action.sa_handler = handleSig;    sigemptyset(&sig_action.sa_mask);    /* Here we don't care about SA_RESTART since these signals will close     * wmaker anyway.     * -Dan */    sig_action.sa_flags = 0;    sigaction(SIGINT, &sig_action, NULL);    sigaction(SIGTERM, &sig_action, NULL);    sigaction(SIGQUIT, &sig_action, NULL);    sigaction(SIGSEGV, &sig_action, NULL);    sigaction(SIGBUS, &sig_action, NULL);    sigaction(SIGFPE, &sig_action, NULL);    /* Here we set SA_RESTART for safety, because SIGHUP may not be handled     * immediately.     * -Dan */    sig_action.sa_flags = SA_RESTART;    sigaction(SIGHUP, &sig_action, NULL);    /* ignore dead pipe */    sig_action.sa_handler = ignoreSig;    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);    /* 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");    }    WDWindowAttributes = wDefaultsInitDomain("WMWindowAttributes", True);    if (!WDWindowAttributes->dictionary) {	wwarning(_("could not read domain \"%s\" from defaults database"),		 "WMWindowAttributes");    }        /* Sound init */#ifdef WMSOUND    wSoundInit(dpy);#endif    XSetErrorHandler((XErrorHandler)catchXError);    if (defaultScreenOnly) {	max = 1;    } else {	max = ScreenCount(dpy);    }    wScreen = wmalloc(sizeof(WScreen*)*max);        for (j = 0; j < max; j++) {	if (defaultScreenOnly || max==1) {	    wScreen[j] = wScreenInit(DefaultScreen(dpy));	    if (!wScreen[j]) {		wfatal(_("it seems that there already is a window manager running"));		exit(1);	    }	} else {	    wScreen[j] = wScreenInit(j);	    if (!wScreen[j]) {		wwarning(_("could not manage screen %i"), j);		continue;	    }	}	wScreenCount++;	/* 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;		manageAllWindows(wScreen[j]);		/* restore saved menus */	wMenuRestoreState(wScreen[j]);		/* If we're not restarting restore session */	if (ws_state == NULL)	    wSessionRestoreState(wScreen[j]);			/* 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);	    XFree(ws_state);	} else {	    wSessionRestoreLastWorkspace(wScreen[j]);	}    }        if (wScreenCount == 0) {	wfatal(_("could not manage any screen"));	exit(1);    }    /* setup defaults file polling */    WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL);}