2 * Window Maker window manager
4 * Copyright (c) 1997, 1998 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"
37 #include "winspector.h"
42 extern Atom _XA_WM_DELETE_WINDOW
;
43 extern Time LastTimestamp
;
44 extern int wScreenCount
;
47 static void wipeDesktop(WScreen
*scr
);
51 *----------------------------------------------------------------------
53 * Exits the window manager cleanly. If mode is WSLogoutMode,
54 * the whole X session will be closed, by killing all clients if
55 * no session manager is running or by asking a shutdown to
58 *----------------------------------------------------------------------
61 Shutdown(WShutdownMode mode
)
67 for (i
=0; i
<wScreenCount
; i
++) {
70 scr
= wScreenWithNumber(i
);
73 kill(scr
->helper_pid
, SIGKILL
);
76 wKWMShutdown(scr
, True
);
78 wScreenSaveState(scr
);
90 wSessionRequestShutdown();
96 for (i
=0; i
<wScreenCount
; i
++) {
99 scr
= wScreenWithNumber(i
);
102 kill(scr
->helper_pid
, SIGKILL
);
104 wKWMShutdown(scr
, True
);
106 wScreenSaveState(scr
);
115 case WSRestartPreparationMode
:
116 for (i
=0; i
<wScreenCount
; i
++) {
119 scr
= wScreenWithNumber(i
);
122 kill(scr
->helper_pid
, SIGKILL
);
124 wKWMShutdown(scr
, False
);
126 wScreenSaveState(scr
);
139 *----------------------------------------------------------------------
141 * Puts the desktop in a usable state when exiting.
144 * All frame windows are removed and windows are reparented
145 * back to root. Windows that are outside the screen are
146 * brought to a viable place.
148 *----------------------------------------------------------------------
151 RestoreDesktop(WScreen
*scr
)
155 if (scr
->helper_pid
) {
156 kill(scr
->helper_pid
, SIGTERM
);
161 wDestroyInspectorPanels();
163 /* reparent windows back to the root window, keeping the stacking order */
164 for (i
=0; i
<MAX_WINDOW_LEVELS
; i
++) {
165 WCoreWindow
*core
, *next
;
168 if (!scr
->stacking_list
[i
])
171 core
= scr
->stacking_list
[i
];
172 /* go to the end of the list */
173 while (core
->stacking
->under
)
174 core
= core
->stacking
->under
;
177 next
= core
->stacking
->above
;
179 if (core
->descriptor
.parent_type
==WCLASS_WINDOW
) {
180 wwin
= core
->descriptor
.parent
;
181 wwin
->flags
.mapped
=1;
182 wUnmanageWindow(wwin
, !wwin
->flags
.internal_window
);
189 XSetInputFocus(dpy
, PointerRoot
, RevertToParent
, CurrentTime
);
190 wColormapInstallForWindow(scr
, NULL
);
191 PropCleanUp(scr
->root_win
);
197 *----------------------------------------------------------------------
199 * Kills all windows in a screen. Send DeleteWindow to all windows
200 * that support it and KillClient on all windows that don't.
203 * All managed windows are closed.
205 * TODO: change to XQueryTree()
206 *----------------------------------------------------------------------
209 wipeDesktop(WScreen
*scr
)
213 wwin
= scr
->focused_window
;
215 if (wwin
->protocols
.DELETE_WINDOW
)
216 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);