Initial revision
[wmaker-crm.git] / src / shutdown.c
blob335208c5f07506828e6fdeb88829e0d88b9c36af
1 /*
2 * WindowMaker window manager
3 *
4 * Copyright (c) 1997, 1998 Alfredo K. Kojima
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
22 #include "wconfig.h"
24 #include <stdlib.h>
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <X11/Intrinsic.h>
30 #include "WindowMaker.h"
31 #include "window.h"
32 #include "client.h"
33 #include "funcs.h"
34 #include "properties.h"
35 #include "winspector.h"
38 extern Atom _XA_WM_DELETE_WINDOW;
39 extern Time LastTimestamp;
42 *----------------------------------------------------------------------
43 * RestoreDesktop--
44 * Puts the desktop in a usable state when exiting.
46 * Side effects:
47 * All frame windows are removed and windows are reparented
48 * back to root. Windows that are outside the screen are
49 * brought to a viable place.
51 *----------------------------------------------------------------------
53 void
54 RestoreDesktop(WScreen *scr)
56 int i;
58 XGrabServer(dpy);
59 wDestroyInspectorPanels();
61 /* reparent windows back to the root window, keeping the stacking order */
62 for (i=0; i<MAX_WINDOW_LEVELS; i++) {
63 WCoreWindow *core, *next;
64 WWindow *wwin;
66 if (!scr->stacking_list[i])
67 continue;
69 core = scr->stacking_list[i];
70 /* go to the end of the list */
71 while (core->stacking->under)
72 core = core->stacking->under;
74 while (core) {
75 next = core->stacking->above;
77 if (core->descriptor.parent_type==WCLASS_WINDOW) {
78 wwin = core->descriptor.parent;
79 wwin->flags.mapped=1;
80 wUnmanageWindow(wwin, !wwin->flags.internal_window);
82 core = next;
86 XUngrabServer(dpy);
87 XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);
88 wColormapInstallForWindow(scr, NULL);
89 PropCleanUp(scr->root_win);
90 XSync(dpy, 0);
95 *----------------------------------------------------------------------
96 * WipeDesktop--
97 * Kills all windows in a screen. Send DeleteWindow to all windows
98 * that support it and KillClient on all windows that don't.
100 * Side effects:
101 * All managed windows are closed.
103 * TODO: change to XQueryTree()
104 *----------------------------------------------------------------------
106 void
107 WipeDesktop(WScreen *scr)
109 WWindow *wwin;
111 wwin = scr->focused_window;
112 while (wwin) {
113 if (wwin->protocols.DELETE_WINDOW)
114 wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp);
115 else
116 wClientKill(wwin);
117 wwin = wwin->prev;
119 XSync(dpy, False);