2
* Window Maker window manager
4
* Copyright (c) 1997-2003 Alfredo K. Kojima
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,
29
#include <X11/Xutil.h>
30
#include <X11/Intrinsic.h>
32
#include "WindowMaker.h"
36
#include "properties.h"
38
#include "winspector.h"
41
extern Atom _XA_WM_DELETE_WINDOW;
42
extern Time LastTimestamp;
43
extern int wScreenCount;
46
static void wipeDesktop(WScreen *scr);
50
*----------------------------------------------------------------------
52
* Exits the window manager cleanly. If mode is WSLogoutMode,
53
* the whole X session will be closed, by killing all clients if
54
* no session manager is running or by asking a shutdown to
57
*----------------------------------------------------------------------
60
Shutdown(WShutdownMode mode)
67
wSessionRequestShutdown();
74
/* if there is no session manager, send SAVE_YOURSELF to
78
if (!wSessionIsManaged())
80
for (i = 0; i < wScreenCount; i++) {
83
scr = wScreenWithNumber(i);
85
wSessionSendSaveYourself(scr);
89
for (i = 0; i < wScreenCount; i++) {
92
scr = wScreenWithNumber(i);
95
kill(scr->helper_pid, SIGKILL);
97
/* if the session is not being managed, save restart info */
99
if (!wSessionIsManaged())
101
wSessionSaveClients(scr);
103
wScreenSaveState(scr);
105
if (mode == WSKillMode)
115
case WSRestartPreparationMode:
116
for (i=0; i<wScreenCount; i++) {
119
scr = wScreenWithNumber(i);
122
kill(scr->helper_pid, SIGKILL);
123
wScreenSaveState(scr);
133
restoreWindows(WMBag *bag, WMBagIterator iter)
141
core = WMBagFirst(bag, &iter);
143
core = WMBagNext(bag, &iter);
149
restoreWindows(bag, iter);
151
/* go to the end of the list */
152
while (core->stacking->under)
153
core = core->stacking->under;
156
next = core->stacking->above;
158
if (core->descriptor.parent_type==WCLASS_WINDOW) {
161
wwin = core->descriptor.parent;
162
window = wwin->client_win;
163
wUnmanageWindow(wwin, !wwin->flags.internal_window, False);
164
XMapWindow(dpy, window);
172
*----------------------------------------------------------------------
174
* Puts the desktop in a usable state when exiting.
177
* All frame windows are removed and windows are reparented
178
* back to root. Windows that are outside the screen are
179
* brought to a viable place.
181
*----------------------------------------------------------------------
184
RestoreDesktop(WScreen *scr)
186
if (scr->helper_pid > 0) {
187
kill(scr->helper_pid, SIGTERM);
192
wDestroyInspectorPanels();
194
/* reparent windows back to the root window, keeping the stacking order */
195
restoreWindows(scr->stacking_list, NULL);
198
XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);
199
wColormapInstallForWindow(scr, NULL);
200
PropCleanUp(scr->root_win);
207
*----------------------------------------------------------------------
209
* Kills all windows in a screen. Send DeleteWindow to all windows
210
* that support it and KillClient on all windows that don't.
213
* All managed windows are closed.
215
* TODO: change to XQueryTree()
216
*----------------------------------------------------------------------
219
wipeDesktop(WScreen *scr)
223
wwin = scr->focused_window;
225
if (wwin->protocols.DELETE_WINDOW)
226
wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp);