Updating to version 0.20.2
[wmaker-crm.git] / src / window.h
blob4ae86b1b17c20d7f9755b8e0b146cfa3ef4b6ebf
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 NSFloatingWindowLevel */
95 unsigned int no_bind_keys:1; /* intercept wm kbd binds
96 * while window is focused */
97 unsigned int no_bind_mouse:1; /* intercept mouse events
98 * on client area while window
99 * is focused */
100 unsigned int no_hide_others:1; /* hide window when doing hideothers */
101 unsigned int no_appicon:1; /* make app icon */
103 unsigned int dont_move_off:1;
105 unsigned int no_focusable:1;
107 unsigned int always_user_icon:1; /* ignore client IconPixmap or
108 * IconWindow */
110 unsigned int start_miniaturized:1;
111 unsigned int start_hidden:1;
112 unsigned int dont_save_session:1; /* do not save app's state in session */
115 * emulate_app_icon must be automatically disabled for apps that can
116 * generate their own appicons and for apps that have no_appicon=1
118 unsigned int emulate_appicon:1;
119 } WWindowAttributes;
122 * Window manager protocols that both the client as we understand.
124 typedef struct {
125 unsigned int TAKE_FOCUS:1;
126 unsigned int SAVE_YOURSELF:1;
127 unsigned int DELETE_WINDOW:1;
129 /* WindowMaker specific */
130 unsigned int MINIATURIZE_WINDOW:1;
131 #ifdef MONITOR_HEARTBEAT
132 unsigned int HEARTBEAT:1;
133 #endif
134 } WProtocols;
138 * Stores client window information. Each client window has it's
139 * structure created when it's being first mapped.
141 typedef struct WWindow {
142 struct WWindow *prev; /* window focus list */
143 struct WWindow *next;
145 WScreen *screen_ptr; /* pointer to the screen structure */
146 WWindowAttributes window_flags; /* window attribute flags */
147 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
149 struct WFrameWindow *frame; /* the frame window */
150 int frame_x, frame_y; /* position of the frame in root*/
152 struct {
153 int x, y;
154 unsigned int width, height; /* original geometry of the window */
155 } old_geometry; /* (before things like maximize) */
157 /* client window info */
158 short old_border_width; /* original border width of client_win*/
159 Window client_win; /* the window we're managing */
160 WObjDescriptor client_descriptor; /* dummy descriptor for client */
161 struct {
162 int x, y; /* position of *client* relative
163 * to root */
164 unsigned int width, height; /* size of the client window */
165 } client;
167 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
168 XWMHints *wm_hints; /* WM_HINTS (optional) */
169 char *wm_instance; /* instance of WM_CLASS */
170 char *wm_class; /* class of WM_CLASS */
171 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
173 int state; /* state as in ICCCM */
175 Window transient_for; /* WM_TRANSIENT_FOR */
176 Window group_id; /* the leader window of the group */
177 Window client_leader; /* WM_CLIENT_LEADER if not
178 internal_window */
180 Window main_window; /* main window for the application */
182 int cmap_window_no;
183 Window *cmap_windows;
185 /* protocols */
186 WProtocols protocols; /* accepted WM_PROTOCOLS */
188 FocusMode focus_mode; /* type of keyboard input focus */
190 #ifdef MONITOR_HEARTBEAT
191 time_t last_beat;
192 #endif
193 struct {
194 /* state flags */
195 unsigned int mapped:1;
196 unsigned int focused:1;
197 unsigned int miniaturized:1;
198 unsigned int hidden:1;
199 unsigned int shaded:1;
200 unsigned int maximized:2;
202 unsigned int semi_focused:1;
203 /* window type flags */
204 unsigned int urgent:1; /* if wm_hints says this is urgent */
205 #ifdef SHAPE
206 unsigned int shaped:1;
207 #endif
209 /* info flags */
210 unsigned int buttons_dont_fit:1;
211 unsigned int rebuild_texture:1;/* the window was resized and
212 * gradients should be re-rendered */
213 unsigned int needs_full_repaint:1;/* does a full repaint of the
214 * window next time it's painted */
215 unsigned int icon_moved:1; /* icon for this window was moved
216 * by the user */
217 unsigned int ignore_next_unmap:1;
218 unsigned int selected:1; /* multiple window selection */
219 unsigned int skip_next_animation:1;
220 unsigned int internal_window:1;
221 unsigned int changing_workspace:1;
223 unsigned int inspector_open:1; /* attrib inspector is already open */
225 unsigned int destroyed:1; /* window was already destroyed */
226 } flags; /* state of the window */
228 struct WIcon *icon; /* icon info for the window */
229 int icon_x, icon_y; /* position of the icon */
230 } WWindow;
234 * Changes to this must update wWindowSaveState/getSavedState
237 typedef struct WSavedState {
238 int workspace;
239 int miniaturized;
240 int shaded;
241 int hidden;
242 int use_geometry;
243 int x;
244 int y;
245 unsigned int w;
246 unsigned int h;
247 } WSavedState;
250 typedef struct WWindowState {
251 char *instance;
252 char *class;
253 char *command;
254 pid_t pid;
255 WSavedState *state;
256 struct WWindowState *next;
257 } WWindowState;
260 typedef void* WMagicNumber;
264 void wWindowDestroy(WWindow *wwin);
265 WWindow *wWindowCreate();
267 #ifdef SHAPE
268 void wWindowSetShape(WWindow *wwin);
269 void wWindowClearShape(WWindow *wwin);
270 #endif
272 WWindow *wManageWindow(WScreen *scr, Window window);
274 void wUnmanageWindow(WWindow *wwin, int restore);
276 void wWindowFocus(WWindow *wwin);
277 void wWindowUnfocus(WWindow *wwin);
278 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
279 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
280 int req_width, int req_height);
282 void wWindowMove(WWindow *wwin, int req_x, int req_y);
284 void wWindowSynthConfigureNotify(WWindow *wwin);
286 WWindow *wWindowFor(Window window);
289 void wWindowConfigureBorders(WWindow *wwin);
291 void wWindowUpdateButtonImages(WWindow *wwin);
293 void wWindowSaveState(WWindow *wwin);
295 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
297 void wWindowSetKeyGrabs(WWindow *wwin);
299 void wWindowResetMouseGrabs(WWindow *wwin);
301 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
302 char *title, int x, int y,
303 int width, int height);
305 void wWindowCheckAttributeSanity(WWindow *wwin, WWindowAttributes *flags);
307 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
309 void wWindowMap(WWindow *wwin);
311 Bool wWindowCanReceiveFocus(WWindow *wwin);
313 void wWindowDeleteSavedStatesForPID(pid_t pid);
315 WMagicNumber wWindowAddSavedState(char *instance, char *class, char *command,
316 pid_t pid, WSavedState *state);
318 WMagicNumber wWindowGetSavedState(Window win);
320 void wWindowDeleteSavedState(WMagicNumber id);
323 #endif