This update includes the 0.20.3pre3 code
[wmaker-crm.git] / src / window.h
blob1ada3074b95ca648285abef6a0022f51467fbf9f
1 /*
2 * Window Maker window manager
3 *
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,
19 * USA.
22 #ifndef WMWINDOW_H_
23 #define WMWINDOW_H_
25 #include <wraster.h>
27 #include "wconfig.h"
28 #include "GNUstep.h"
29 #ifdef MWM_HINTS
30 # include "motif.h"
31 #endif
32 #include "texture.h"
33 #include "menu.h"
34 #include "application.h"
36 /* not defined in my X11 headers */
37 #ifndef UrgencyHint
38 #define UrgencyHint (1L << 8)
39 #endif
42 #define BORDER_TOP 1
43 #define BORDER_BOTTOM 2
44 #define BORDER_LEFT 4
45 #define BORDER_RIGHT 8
46 #define BORDER_ALL (1|2|4|8)
49 #define CLIENT_EVENTS (StructureNotifyMask | PropertyChangeMask\
50 | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \
51 | FocusChangeMask)
53 typedef enum {
54 WFM_PASSIVE, WFM_NO_INPUT, WFM_LOCALLY_ACTIVE, WFM_GLOBALLY_ACTIVE
55 } FocusMode;
59 * window attribute flags.
61 * Note: attributes that should apply to the application as a
62 * whole should only access the flags from the app->main_window_desc->window_flags
63 * This is to make sure that the application doesn't have many different
64 * values for the same option. For example, imagine xfoo, which has
65 * foo.bar as leader and it a child window named foo.baz. If you set
66 * StartHidden YES for foo.bar and NO for foo.baz we must *always* guarantee
67 * that the value that will be used will be that of the leader foo.bar.
68 * The attributes inspector must always save application wide options
69 * in the name of the leader window, not the child.
72 * All flags must have their default values = 0
74 typedef struct {
75 /* OpenStep */
76 unsigned int no_titlebar:1; /* draw titlebar? */
77 unsigned int no_resizable:1;
78 unsigned int no_closable:1;
79 unsigned int no_miniaturizable:1;
81 /* decorations */
82 unsigned int no_resizebar:1; /* draw the bottom handle? */
83 unsigned int no_close_button:1; /* draw a close button? */
84 unsigned int no_miniaturize_button:1; /* draw an iconify button? */
86 unsigned int broken_close:1; /* is the close button broken? */
88 /* ours */
89 unsigned int kill_close:1; /* can't send WM_DELETE_WINDOW */
91 unsigned int no_shadeable:1;
92 unsigned int omnipresent:1;
93 unsigned int skip_window_list:1;
94 unsigned int floating:1; /* put in WMFloatingLevel */
95 unsigned int sunken:1; /* put in WMSunkenLevel */
96 unsigned int no_bind_keys:1; /* intercept wm kbd binds
97 * while window is focused */
98 unsigned int no_bind_mouse:1; /* intercept mouse events
99 * on client area while window
100 * is focused */
101 unsigned int no_hide_others:1; /* hide window when doing hideothers */
102 unsigned int no_appicon:1; /* make app icon */
104 unsigned int dont_move_off:1;
106 unsigned int no_focusable:1;
108 unsigned int always_user_icon:1; /* ignore client IconPixmap or
109 * IconWindow */
111 unsigned int start_miniaturized:1;
112 unsigned int start_hidden:1;
113 unsigned int dont_save_session:1; /* do not save app's state in session */
116 * emulate_app_icon must be automatically disabled for apps that can
117 * generate their own appicons and for apps that have no_appicon=1
119 unsigned int emulate_appicon:1;
120 } WWindowAttributes;
123 * Window manager protocols that both the client as we understand.
125 typedef struct {
126 unsigned int TAKE_FOCUS:1;
127 unsigned int SAVE_YOURSELF:1;
128 unsigned int DELETE_WINDOW:1;
130 /* WindowMaker specific */
131 unsigned int MINIATURIZE_WINDOW:1;
132 #ifdef MONITOR_HEARTBEAT
133 unsigned int HEARTBEAT:1;
134 #endif
135 } WProtocols;
139 * Stores client window information. Each client window has it's
140 * structure created when it's being first mapped.
142 typedef struct WWindow {
143 struct WWindow *prev; /* window focus list */
144 struct WWindow *next;
146 WScreen *screen_ptr; /* pointer to the screen structure */
147 WWindowAttributes window_flags; /* window attribute flags */
148 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
150 struct WFrameWindow *frame; /* the frame window */
151 int frame_x, frame_y; /* position of the frame in root*/
153 struct {
154 int x, y;
155 unsigned int width, height; /* original geometry of the window */
156 } old_geometry; /* (before things like maximize) */
158 /* client window info */
159 short old_border_width; /* original border width of client_win*/
160 Window client_win; /* the window we're managing */
161 WObjDescriptor client_descriptor; /* dummy descriptor for client */
162 struct {
163 int x, y; /* position of *client* relative
164 * to root */
165 unsigned int width, height; /* size of the client window */
166 } client;
168 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
169 XWMHints *wm_hints; /* WM_HINTS (optional) */
170 char *wm_instance; /* instance of WM_CLASS */
171 char *wm_class; /* class of WM_CLASS */
172 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
174 int state; /* state as in ICCCM */
176 Window transient_for; /* WM_TRANSIENT_FOR */
177 Window group_id; /* the leader window of the group */
178 Window client_leader; /* WM_CLIENT_LEADER if not
179 internal_window */
181 Window main_window; /* main window for the application */
183 int cmap_window_no;
184 Window *cmap_windows;
186 /* protocols */
187 WProtocols protocols; /* accepted WM_PROTOCOLS */
189 FocusMode focus_mode; /* type of keyboard input focus */
191 #ifdef KEEP_XKB_LOCK_STATUS
192 int languagemode;
193 #endif /* KEEP_XKB_LOCK_STATUS */
195 #ifdef MONITOR_HEARTBEAT
196 time_t last_beat;
197 #endif
198 struct {
199 /* state flags */
200 unsigned int mapped:1;
201 unsigned int focused:1;
202 unsigned int miniaturized:1;
203 unsigned int hidden:1;
204 unsigned int shaded:1;
205 unsigned int maximized:2;
207 unsigned int semi_focused:1;
208 /* window type flags */
209 unsigned int urgent:1; /* if wm_hints says this is urgent */
210 #ifdef SHAPE
211 unsigned int shaped:1;
212 #endif
214 /* info flags */
215 unsigned int buttons_dont_fit:1;
216 unsigned int rebuild_texture:1;/* the window was resized and
217 * gradients should be re-rendered */
218 unsigned int needs_full_repaint:1;/* does a full repaint of the
219 * window next time it's painted */
220 unsigned int icon_moved:1; /* icon for this window was moved
221 * by the user */
222 unsigned int ignore_next_unmap:1;
223 unsigned int selected:1; /* multiple window selection */
224 unsigned int skip_next_animation:1;
225 unsigned int internal_window:1;
226 unsigned int changing_workspace:1;
228 unsigned int inspector_open:1; /* attrib inspector is already open */
230 unsigned int destroyed:1; /* window was already destroyed */
232 unsigned int menu_open_for_me:1; /* window commands menu */
233 } flags; /* state of the window */
235 struct WIcon *icon; /* icon info for the window */
236 int icon_x, icon_y; /* position of the icon */
237 } WWindow;
241 * Changes to this must update wWindowSaveState/getSavedState
244 typedef struct WSavedState {
245 int workspace;
246 int miniaturized;
247 int shaded;
248 int hidden;
249 int use_geometry;
250 int x;
251 int y;
252 unsigned int w;
253 unsigned int h;
254 } WSavedState;
257 typedef struct WWindowState {
258 char *instance;
259 char *class;
260 char *command;
261 pid_t pid;
262 WSavedState *state;
263 struct WWindowState *next;
264 } WWindowState;
267 typedef void* WMagicNumber;
271 void wWindowDestroy(WWindow *wwin);
272 WWindow *wWindowCreate();
274 #ifdef SHAPE
275 void wWindowSetShape(WWindow *wwin);
276 void wWindowClearShape(WWindow *wwin);
277 #endif
279 WWindow *wManageWindow(WScreen *scr, Window window);
281 void wUnmanageWindow(WWindow *wwin, int restore);
283 void wWindowFocus(WWindow *wwin);
284 void wWindowUnfocus(WWindow *wwin);
285 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
286 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
287 int req_width, int req_height);
289 void wWindowMove(WWindow *wwin, int req_x, int req_y);
291 void wWindowSynthConfigureNotify(WWindow *wwin);
293 WWindow *wWindowFor(Window window);
296 void wWindowConfigureBorders(WWindow *wwin);
298 void wWindowUpdateButtonImages(WWindow *wwin);
300 void wWindowSaveState(WWindow *wwin);
302 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
304 void wWindowSetKeyGrabs(WWindow *wwin);
306 void wWindowResetMouseGrabs(WWindow *wwin);
308 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
309 char *title, int x, int y,
310 int width, int height);
312 void wWindowCheckAttributeSanity(WWindow *wwin, WWindowAttributes *flags);
314 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
316 void wWindowMap(WWindow *wwin);
318 Bool wWindowCanReceiveFocus(WWindow *wwin);
320 void wWindowDeleteSavedStatesForPID(pid_t pid);
322 WMagicNumber wWindowAddSavedState(char *instance, char *class, char *command,
323 pid_t pid, WSavedState *state);
325 WMagicNumber wWindowGetSavedState(Window win);
327 void wWindowDeleteSavedState(WMagicNumber id);
330 #endif