Fixed some focus related problems when switching workspaces, including the
[wmaker-crm.git] / src / window.h
blob2bd8963156205d1cb426976610f9d6e2de635cd1
1 /*
2 * Window Maker window manager
3 *
4 * Copyright (c) 1997-2002 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 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;
94 unsigned int no_border:1; /* 1 pixel border around window */
95 #ifdef XKB_BUTTON_HINT
96 unsigned int no_language_button:1;
97 #endif
99 /* decorations */
100 unsigned int no_resizebar:1; /* draw the bottom handle? */
101 unsigned int no_close_button:1; /* draw a close button? */
102 unsigned int no_miniaturize_button:1; /* draw an iconify button? */
104 unsigned int broken_close:1; /* is the close button broken? */
106 /* ours */
107 unsigned int kill_close:1; /* can't send WM_DELETE_WINDOW */
109 unsigned int no_shadeable:1;
110 unsigned int omnipresent:1;
111 unsigned int skip_window_list:1;
112 unsigned int floating:1; /* put in WMFloatingLevel */
113 unsigned int sunken:1; /* put in WMSunkenLevel */
114 unsigned int no_bind_keys:1; /* intercept wm kbd binds
115 * while window is focused */
116 unsigned int no_bind_mouse:1; /* intercept mouse events
117 * on client area while window
118 * is focused */
119 unsigned int no_hide_others:1; /* hide window when doing hideothers */
120 unsigned int no_appicon:1; /* make app icon */
122 unsigned int shared_appicon:1;
124 unsigned int dont_move_off:1;
126 unsigned int no_focusable:1;
128 unsigned int always_user_icon:1; /* ignore client IconPixmap or
129 * IconWindow */
131 unsigned int start_miniaturized:1;
132 unsigned int start_hidden:1;
133 unsigned int start_maximized:1;
134 unsigned int dont_save_session:1; /* do not save app's state in session */
136 unsigned int full_maximize:1;
139 * emulate_app_icon must be automatically disabled for apps that can
140 * generate their own appicons and for apps that have no_appicon=1
142 unsigned int emulate_appicon:1;
144 /* toolkit specific attribute flags. These are unchangeable and
145 * unconfigurable and must not be saved as state. */
146 #ifdef OLWM_HINTS
147 unsigned int olwm_transient:1;
148 unsigned int olwm_warp_to_pin:1;
149 #endif
150 } WWindowAttributes;
155 * Window manager protocols that both the client as we understand.
157 typedef struct {
158 unsigned int TAKE_FOCUS:1;
159 unsigned int DELETE_WINDOW:1;
160 unsigned int SAVE_YOURSELF:1;
161 /* WindowMaker specific */
162 unsigned int MINIATURIZE_WINDOW:1;
163 #ifdef MONITOR_HEARTBEAT
164 unsigned int HEARTBEAT:1;
165 #endif
166 } WProtocols;
170 * Structure used for storing fake window group information
172 typedef struct WFakeGroupLeader {
173 char *identifier;
174 Window leader;
175 Window origLeader;
176 int retainCount;
177 } WFakeGroupLeader;
181 * Stores client window information. Each client window has it's
182 * structure created when it's being first mapped.
184 typedef struct WWindow {
185 struct WWindow *prev; /* window focus list */
186 struct WWindow *next;
188 WScreen *screen_ptr; /* pointer to the screen structure */
189 WWindowAttributes user_flags; /* window attribute flags set by user */
190 WWindowAttributes defined_user_flags;/* mask for user_flags */
191 WWindowAttributes client_flags; /* window attribute flags set by app
192 * initialized with global defaults */
194 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
196 struct WFrameWindow *frame; /* the frame window */
197 int frame_x, frame_y; /* position of the frame in root*/
199 struct {
200 int x, y;
201 unsigned int width, height; /* original geometry of the window */
202 } old_geometry; /* (before things like maximize) */
204 /* client window info */
205 short old_border_width; /* original border width of client_win*/
206 Window client_win; /* the window we're managing */
207 WObjDescriptor client_descriptor; /* dummy descriptor for client */
208 struct {
209 int x, y; /* position of *client* relative
210 * to root */
211 unsigned int width, height; /* size of the client window */
212 } client;
214 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
215 XWMHints *wm_hints; /* WM_HINTS (optional) */
216 char *wm_instance; /* instance of WM_CLASS */
217 char *wm_class; /* class of WM_CLASS */
218 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
220 int state; /* state as in ICCCM */
222 Window transient_for; /* WM_TRANSIENT_FOR */
224 WFakeGroupLeader *fake_group; /* Fake group leader for grouping into
225 a single appicon */
226 Window group_id; /* the leader window of the group */
227 Window client_leader; /* WM_CLIENT_LEADER if not
228 internal_window */
230 Window main_window; /* main window for the application */
232 int cmap_window_no;
233 Window *cmap_windows;
235 /* protocols */
236 WProtocols protocols; /* accepted WM_PROTOCOLS */
238 FocusMode focus_mode; /* type of keyboard input focus */
240 #ifdef OLWM_HINTS_unfinished
241 struct WOLWindowState ol_window_state;
242 #endif
244 long event_mask; /* the event mask thats selected */
246 #ifdef MONITOR_HEARTBEAT
247 time_t last_beat;
248 #endif
249 struct {
250 /* state flags */
251 unsigned int mapped:1;
252 unsigned int focused:1;
253 unsigned int miniaturized:1;
254 unsigned int hidden:1;
255 unsigned int shaded:1;
256 unsigned int maximized:2;
257 unsigned int omnipresent:1;
259 unsigned int semi_focused:1;
260 /* window type flags */
261 unsigned int urgent:1; /* if wm_hints says this is urgent */
262 #ifdef SHAPE
263 unsigned int shaped:1;
264 #endif
266 /* info flags */
267 unsigned int is_gnustep:1; /* 1 if the window belongs to a GNUstep
268 app */
270 unsigned int buttons_dont_fit:1;
271 unsigned int rebuild_texture:1;/* the window was resized and
272 * gradients should be re-rendered */
273 unsigned int needs_full_repaint:1;/* does a full repaint of the
274 * window next time it's painted */
275 unsigned int icon_moved:1; /* icon for this window was moved
276 * by the user */
277 unsigned int selected:1; /* multiple window selection */
278 unsigned int skip_next_animation:1;
279 unsigned int internal_window:1;
280 unsigned int changing_workspace:1;
282 unsigned int inspector_open:1; /* attrib inspector is already open */
284 unsigned int destroyed:1; /* window was already destroyed */
286 unsigned int menu_open_for_me:1; /* window commands menu */
288 unsigned int waiting_save_ack:1; /* waiting for SAVE_YOURSELF ack */
290 unsigned int obscured:1; /* window is obscured */
292 unsigned int dragged_while_fmaximized;
294 unsigned int user_changed_width:1;
295 unsigned int user_changed_height:1;
296 unsigned int wm_name_changed:1;
298 #ifdef KWM_HINTS
299 unsigned int kwm_hidden_for_modules:1;
300 unsigned int kwm_managed:1;
301 unsigned int kwm_menubar:1;
302 #endif
303 #ifdef OLWM_HINTS
304 unsigned int olwm_push_pin_out:1;/* emulate pushpin behaviour */
305 unsigned int olwm_limit_menu:1;
306 #endif
307 #ifdef NET_HINTS
308 unsigned int net_state_from_client:1; /* state hint was set by client */
309 unsigned int net_skip_taskbar:1;
310 unsigned int net_skip_pager:1;
311 #endif
312 } flags; /* state of the window */
314 struct WIcon *icon; /* icon info for the window */
315 int icon_x, icon_y; /* position of the icon */
316 } WWindow;
319 #define IS_OMNIPRESENT(w) ((w)->flags.omnipresent ^ WFLAGP(w, omnipresent))
321 #define WINDOW_LEVEL(w) ((w)->frame->core->stacking->window_level)
326 * Changes to this must update wWindowSaveState/getSavedState
329 typedef struct WSavedState {
330 int workspace;
331 int miniaturized;
332 int shaded;
333 int hidden;
334 int maximized;
335 int x; /* original geometry of the */
336 int y; /* window if it's maximized */
337 unsigned int w;
338 unsigned int h;
339 unsigned window_shortcuts; /* mask like 1<<shortcut_number */
340 } WSavedState;
343 typedef struct WWindowState {
344 char *instance;
345 char *class;
346 char *command;
347 pid_t pid;
348 WSavedState *state;
349 struct WWindowState *next;
350 } WWindowState;
353 typedef void* WMagicNumber;
357 void wWindowDestroy(WWindow *wwin);
358 WWindow *wWindowCreate();
360 #ifdef SHAPE
361 void wWindowSetShape(WWindow *wwin);
362 void wWindowClearShape(WWindow *wwin);
363 #endif
365 WWindow *wManageWindow(WScreen *scr, Window window);
367 void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
369 void wWindowFocus(WWindow *wwin, WWindow *owin);
370 void wWindowUnfocus(WWindow *wwin);
372 void wWindowUpdateName(WWindow *wwin, char *newTitle);
373 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
374 void wWindowCropSize(WWindow *wwin, int maxw, int maxh,
375 int *nwidth, int *nheight);
376 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
377 int req_width, int req_height);
379 void wWindowMove(WWindow *wwin, int req_x, int req_y);
381 void wWindowSynthConfigureNotify(WWindow *wwin);
383 WWindow *wWindowFor(Window window);
386 void wWindowConfigureBorders(WWindow *wwin);
388 void wWindowUpdateButtonImages(WWindow *wwin);
390 void wWindowSaveState(WWindow *wwin);
392 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
394 void wWindowSetKeyGrabs(WWindow *wwin);
396 void wWindowResetMouseGrabs(WWindow *wwin);
398 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
399 char *title, int x, int y,
400 int width, int height);
402 void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace);
404 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
406 void wWindowMap(WWindow *wwin);
408 void wWindowUnmap(WWindow *wwin);
410 Bool wWindowCanReceiveFocus(WWindow *wwin);
412 void wWindowDeleteSavedStatesForPID(pid_t pid);
414 WMagicNumber wWindowAddSavedState(char *instance, char *class, char *command,
415 pid_t pid, WSavedState *state);
417 WMagicNumber wWindowGetSavedState(Window win);
419 void wWindowDeleteSavedState(WMagicNumber id);
421 Bool wWindowObscuresWindow(WWindow *wwin, WWindow *obscured);
423 void wWindowSetOmnipresent(WWindow *wwin, Bool flag);
425 #endif