- made deiconification not automatically focus window in sloppy focus
[wmaker-crm.git] / src / window.h
blobf89017864bc3cb2925646e20fabce205ddae720e
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 #include "texture.h"
30 #include "menu.h"
31 #include "application.h"
33 /* not defined in my X11 headers */
34 #ifndef UrgencyHint
35 #define UrgencyHint (1L << 8)
36 #endif
39 #define BORDER_TOP 1
40 #define BORDER_BOTTOM 2
41 #define BORDER_LEFT 4
42 #define BORDER_RIGHT 8
43 #define BORDER_ALL (1|2|4|8)
46 #define CLIENT_EVENTS (StructureNotifyMask | PropertyChangeMask\
47 | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \
48 | FocusChangeMask | VisibilityChangeMask)
50 typedef enum {
51 WFM_PASSIVE, WFM_NO_INPUT, WFM_LOCALLY_ACTIVE, WFM_GLOBALLY_ACTIVE
52 } FocusMode;
56 * window attribute flags.
58 * Note: attributes that should apply to the application as a
59 * whole should only access the flags from the app->main_window_desc->window_flags
60 * This is to make sure that the application doesn't have many different
61 * values for the same option. For example, imagine xfoo, which has
62 * foo.bar as leader and it a child window named foo.baz. If you set
63 * StartHidden YES for foo.bar and NO for foo.baz we must *always* guarantee
64 * that the value that will be used will be that of the leader foo.bar.
65 * The attributes inspector must always save application wide options
66 * in the name of the leader window, not the child.
70 * All flags must have their default values = 0
72 * New flag scheme:
74 * user_flags, defined_flags
75 * client_flags
77 * if defined window_flag then window_flag else client_flag
81 #define WFLAGP(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \
82 ? (wwin)->user_flags.FLAG \
83 : (wwin)->client_flags.FLAG)
85 #define WSETUFLAG(wwin, FLAG, VAL) (wwin)->user_flags.FLAG = (VAL),\
86 (wwin)->defined_user_flags.FLAG = 1
88 typedef struct {
89 /* OpenStep */
90 unsigned int no_titlebar:1; /* draw titlebar? */
91 unsigned int no_resizable:1;
92 unsigned int no_closable:1;
93 unsigned int no_miniaturizable:1;
95 /* decorations */
96 unsigned int no_resizebar:1; /* draw the bottom handle? */
97 unsigned int no_close_button:1; /* draw a close button? */
98 unsigned int no_miniaturize_button:1; /* draw an iconify button? */
100 unsigned int broken_close:1; /* is the close button broken? */
102 /* ours */
103 unsigned int kill_close:1; /* can't send WM_DELETE_WINDOW */
105 unsigned int no_shadeable:1;
106 unsigned int omnipresent:1;
107 unsigned int skip_window_list:1;
108 unsigned int floating:1; /* put in WMFloatingLevel */
109 unsigned int sunken:1; /* put in WMSunkenLevel */
110 unsigned int no_bind_keys:1; /* intercept wm kbd binds
111 * while window is focused */
112 unsigned int no_bind_mouse:1; /* intercept mouse events
113 * on client area while window
114 * is focused */
115 unsigned int no_hide_others:1; /* hide window when doing hideothers */
116 unsigned int no_appicon:1; /* make app icon */
118 unsigned int dont_move_off:1;
120 unsigned int no_focusable:1;
122 unsigned int always_user_icon:1; /* ignore client IconPixmap or
123 * IconWindow */
125 unsigned int start_miniaturized:1;
126 unsigned int start_hidden:1;
127 unsigned int start_maximized:1;
128 unsigned int dont_save_session:1; /* do not save app's state in session */
130 unsigned int full_maximize:1;
133 * emulate_app_icon must be automatically disabled for apps that can
134 * generate their own appicons and for apps that have no_appicon=1
136 unsigned int emulate_appicon:1;
138 /* toolkit specific attribute flags. These are unchangeable and
139 * unconfigurable and must not be saved as state. */
140 #ifdef OLWM_HINTS
141 unsigned int olwm_transient:1;
142 unsigned int olwm_warp_to_pin:1;
143 #endif
144 } WWindowAttributes;
149 * Window manager protocols that both the client as we understand.
151 typedef struct {
152 unsigned int TAKE_FOCUS:1;
153 unsigned int DELETE_WINDOW:1;
154 unsigned int SAVE_YOURSELF:1;
155 /* WindowMaker specific */
156 unsigned int MINIATURIZE_WINDOW:1;
157 #ifdef MONITOR_HEARTBEAT
158 unsigned int HEARTBEAT:1;
159 #endif
160 } WProtocols;
164 * Stores client window information. Each client window has it's
165 * structure created when it's being first mapped.
167 typedef struct WWindow {
168 struct WWindow *prev; /* window focus list */
169 struct WWindow *next;
171 WScreen *screen_ptr; /* pointer to the screen structure */
172 WWindowAttributes user_flags; /* window attribute flags set by user */
173 WWindowAttributes defined_user_flags;/* mask for user_flags */
174 WWindowAttributes client_flags; /* window attribute flags set by app
175 * initialized with global defaults */
177 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
179 struct WFrameWindow *frame; /* the frame window */
180 int frame_x, frame_y; /* position of the frame in root*/
182 struct {
183 int x, y;
184 unsigned int width, height; /* original geometry of the window */
185 } old_geometry; /* (before things like maximize) */
187 /* client window info */
188 short old_border_width; /* original border width of client_win*/
189 Window client_win; /* the window we're managing */
190 WObjDescriptor client_descriptor; /* dummy descriptor for client */
191 struct {
192 int x, y; /* position of *client* relative
193 * to root */
194 unsigned int width, height; /* size of the client window */
195 } client;
197 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
198 XWMHints *wm_hints; /* WM_HINTS (optional) */
199 char *wm_instance; /* instance of WM_CLASS */
200 char *wm_class; /* class of WM_CLASS */
201 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
203 int state; /* state as in ICCCM */
205 Window transient_for; /* WM_TRANSIENT_FOR */
206 Window group_id; /* the leader window of the group */
207 Window client_leader; /* WM_CLIENT_LEADER if not
208 internal_window */
210 Window main_window; /* main window for the application */
212 int cmap_window_no;
213 Window *cmap_windows;
215 /* protocols */
216 WProtocols protocols; /* accepted WM_PROTOCOLS */
218 FocusMode focus_mode; /* type of keyboard input focus */
220 #ifdef OLWM_HINTS_unfinished
221 struct WOLWindowState ol_window_state;
222 #endif
224 long event_mask; /* the event mask thats selected */
226 #ifdef MONITOR_HEARTBEAT
227 time_t last_beat;
228 #endif
229 struct {
230 /* state flags */
231 unsigned int mapped:1;
232 unsigned int focused:1;
233 unsigned int miniaturized:1;
234 unsigned int hidden:1;
235 unsigned int shaded:1;
236 unsigned int maximized:2;
237 unsigned int omnipresent:1;
239 unsigned int semi_focused:1;
240 /* window type flags */
241 unsigned int urgent:1; /* if wm_hints says this is urgent */
242 #ifdef SHAPE
243 unsigned int shaped:1;
244 #endif
246 /* info flags */
247 unsigned int buttons_dont_fit:1;
248 unsigned int rebuild_texture:1;/* the window was resized and
249 * gradients should be re-rendered */
250 unsigned int needs_full_repaint:1;/* does a full repaint of the
251 * window next time it's painted */
252 unsigned int icon_moved:1; /* icon for this window was moved
253 * by the user */
254 unsigned int selected:1; /* multiple window selection */
255 unsigned int skip_next_animation:1;
256 unsigned int internal_window:1;
257 unsigned int changing_workspace:1;
259 unsigned int inspector_open:1; /* attrib inspector is already open */
261 unsigned int destroyed:1; /* window was already destroyed */
263 unsigned int menu_open_for_me:1; /* window commands menu */
265 unsigned int waiting_save_ack:1; /* waiting for SAVE_YOURSELF ack */
267 unsigned int obscured:1; /* window is obscured */
269 unsigned int dragged_while_fmaximized;
271 unsigned int user_changed_width:1;
272 unsigned int user_changed_height:1;
273 unsigned int wm_name_changed:1;
275 #ifdef KWM_HINTS
276 unsigned int kwm_hidden_for_modules:1;
277 unsigned int kwm_managed:1;
278 unsigned int kwm_menubar:1;
279 #endif
280 #ifdef OLWM_HINTS
281 unsigned int olwm_push_pin_out:1;/* emulate pushpin behaviour */
282 unsigned int olwm_limit_menu:1;
283 #endif
284 } flags; /* state of the window */
286 struct WIcon *icon; /* icon info for the window */
287 int icon_x, icon_y; /* position of the icon */
288 } WWindow;
291 #define IS_OMNIPRESENT(w) ((w)->flags.omnipresent ^ WFLAGP(w, omnipresent))
293 #define WINDOW_LEVEL(w) ((w)->frame->core->stacking->window_level)
298 * Changes to this must update wWindowSaveState/getSavedState
301 typedef struct WSavedState {
302 int workspace;
303 int miniaturized;
304 int shaded;
305 int hidden;
306 int use_geometry;
307 int x;
308 int y;
309 unsigned int w;
310 unsigned int h;
311 unsigned window_shortcuts; /* mask like 1<<shortcut_number */
312 } WSavedState;
315 typedef struct WWindowState {
316 char *instance;
317 char *class;
318 char *command;
319 pid_t pid;
320 WSavedState *state;
321 struct WWindowState *next;
322 } WWindowState;
325 typedef void* WMagicNumber;
329 void wWindowDestroy(WWindow *wwin);
330 WWindow *wWindowCreate();
332 #ifdef SHAPE
333 void wWindowSetShape(WWindow *wwin);
334 void wWindowClearShape(WWindow *wwin);
335 #endif
337 WWindow *wManageWindow(WScreen *scr, Window window);
339 void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
341 void wWindowFocus(WWindow *wwin, WWindow *owin);
342 void wWindowUnfocus(WWindow *wwin);
343 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
344 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
345 int req_width, int req_height);
347 void wWindowMove(WWindow *wwin, int req_x, int req_y);
349 void wWindowSynthConfigureNotify(WWindow *wwin);
351 WWindow *wWindowFor(Window window);
354 void wWindowConfigureBorders(WWindow *wwin);
356 void wWindowUpdateButtonImages(WWindow *wwin);
358 void wWindowSaveState(WWindow *wwin);
360 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
362 void wWindowSetKeyGrabs(WWindow *wwin);
364 void wWindowResetMouseGrabs(WWindow *wwin);
366 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
367 char *title, int x, int y,
368 int width, int height);
370 void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace);
372 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
374 void wWindowMap(WWindow *wwin);
376 void wWindowUnmap(WWindow *wwin);
378 Bool wWindowCanReceiveFocus(WWindow *wwin);
380 void wWindowDeleteSavedStatesForPID(pid_t pid);
382 WMagicNumber wWindowAddSavedState(char *instance, char *class, char *command,
383 pid_t pid, WSavedState *state);
385 WMagicNumber wWindowGetSavedState(Window win);
387 void wWindowDeleteSavedState(WMagicNumber id);
389 Bool wWindowObscuresWindow(WWindow *wwin, WWindow *obscured);
391 #endif