- Added support for NET_WM_NAME/NET_WM_ICON_NAME
[wmaker-crm.git] / src / window.h
blob54afee81cf31208db198f6af6f3cd56532426e41
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 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
98 unsigned int no_movable:1;
100 /* decorations */
101 unsigned int no_resizebar:1; /* draw the bottom handle? */
102 unsigned int no_close_button:1; /* draw a close button? */
103 unsigned int no_miniaturize_button:1; /* draw an iconify button? */
105 unsigned int broken_close:1; /* is the close button broken? */
107 /* ours */
108 unsigned int kill_close:1; /* can't send WM_DELETE_WINDOW */
110 unsigned int no_shadeable:1;
111 unsigned int omnipresent:1;
112 unsigned int skip_window_list:1;
113 unsigned int floating:1; /* put in WMFloatingLevel */
114 unsigned int sunken:1; /* put in WMSunkenLevel */
115 unsigned int no_bind_keys:1; /* intercept wm kbd binds
116 * while window is focused */
117 unsigned int no_bind_mouse:1; /* intercept mouse events
118 * on client area while window
119 * is focused */
120 unsigned int no_hide_others:1; /* hide window when doing hideothers */
121 unsigned int no_appicon:1; /* make app icon */
123 unsigned int shared_appicon:1;
125 unsigned int dont_move_off:1;
127 unsigned int no_focusable:1;
129 unsigned int always_user_icon:1; /* ignore client IconPixmap or
130 * IconWindow */
132 unsigned int start_miniaturized:1;
133 unsigned int start_hidden:1;
134 unsigned int start_maximized:1;
135 unsigned int dont_save_session:1; /* do not save app's state in session */
137 unsigned int full_maximize:1;
139 #ifdef VIRTUAL_DESKTOP
140 unsigned int virtual_stick:1;
141 #endif
144 * emulate_app_icon must be automatically disabled for apps that can
145 * generate their own appicons and for apps that have no_appicon=1
147 unsigned int emulate_appicon:1;
149 } WWindowAttributes;
154 * Window manager protocols that both the client as we understand.
156 typedef struct {
157 unsigned int TAKE_FOCUS:1;
158 unsigned int DELETE_WINDOW:1;
159 unsigned int SAVE_YOURSELF:1;
160 /* WindowMaker specific */
161 unsigned int MINIATURIZE_WINDOW:1;
162 #ifdef MONITOR_HEARTBEAT
163 unsigned int HEARTBEAT:1;
164 #endif
165 } WProtocols;
169 * Structure used for storing fake window group information
171 typedef struct WFakeGroupLeader {
172 char *identifier;
173 Window leader;
174 Window origLeader;
175 int retainCount;
176 } WFakeGroupLeader;
180 * Stores client window information. Each client window has it's
181 * structure created when it's being first mapped.
183 typedef struct WWindow {
184 struct WWindow *prev; /* window focus list */
185 struct WWindow *next;
187 WScreen *screen_ptr; /* pointer to the screen structure */
188 WWindowAttributes user_flags; /* window attribute flags set by user */
189 WWindowAttributes defined_user_flags;/* mask for user_flags */
190 WWindowAttributes client_flags; /* window attribute flags set by app
191 * initialized with global defaults */
193 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
195 struct WFrameWindow *frame; /* the frame window */
196 int frame_x, frame_y; /* position of the frame in root*/
198 struct {
199 int x, y;
200 unsigned int width, height; /* original geometry of the window */
201 } old_geometry; /* (before things like maximize) */
203 struct {
204 int x, y;
205 unsigned int width, height; /* original geometry of the window */
206 } bfs_geometry; /* (before fullscreen) */
208 /* client window info */
209 short old_border_width; /* original border width of client_win*/
210 Window client_win; /* the window we're managing */
211 WObjDescriptor client_descriptor; /* dummy descriptor for client */
212 struct {
213 int x, y; /* position of *client* relative
214 * to root */
215 unsigned int width, height; /* size of the client window */
216 } client;
218 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
219 XWMHints *wm_hints; /* WM_HINTS (optional) */
220 char *wm_instance; /* instance of WM_CLASS */
221 char *wm_class; /* class of WM_CLASS */
222 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
224 int state; /* state as in ICCCM */
226 Window transient_for; /* WM_TRANSIENT_FOR */
228 WFakeGroupLeader *fake_group; /* Fake group leader for grouping into
229 a single appicon */
230 Window group_id; /* the leader window of the group */
231 Window client_leader; /* WM_CLIENT_LEADER if not
232 internal_window */
234 Window main_window; /* main window for the application */
236 Window orig_main_window; /* original main window of application.
237 used for the shared appicon thing */
239 int cmap_window_no;
240 Window *cmap_windows;
242 /* protocols */
243 WProtocols protocols; /* accepted WM_PROTOCOLS */
245 FocusMode focus_mode; /* type of keyboard input focus */
247 long event_mask; /* the event mask thats selected */
249 #ifdef MONITOR_HEARTBEAT
250 time_t last_beat;
251 #endif
252 struct {
253 /* state flags */
254 unsigned int mapped:1;
255 unsigned int focused:1;
256 unsigned int miniaturized:1;
257 unsigned int hidden:1;
258 unsigned int shaded:1;
259 unsigned int maximized:2;
260 unsigned int fullscreen:1;
261 unsigned int omnipresent:1;
263 unsigned int semi_focused:1;
264 /* window type flags */
265 unsigned int urgent:1; /* if wm_hints says this is urgent */
266 #ifdef SHAPE
267 unsigned int shaped:1;
268 #endif
270 /* info flags */
271 unsigned int is_gnustep:1; /* 1 if the window belongs to a GNUstep
272 app */
274 unsigned int buttons_dont_fit:1;
275 unsigned int rebuild_texture:1; /* the window was resized and
276 * gradients should be re-rendered */
277 unsigned int needs_full_repaint:1;/* does a full repaint of the
278 * window next time it's painted */
279 unsigned int icon_moved:1; /* icon for this window was moved
280 * by the user */
281 unsigned int selected:1; /* multiple window selection */
282 unsigned int skip_next_animation:1;
283 unsigned int internal_window:1;
284 unsigned int changing_workspace:1;
286 unsigned int inspector_open:1; /* attrib inspector is already open */
288 unsigned int destroyed:1; /* window was already destroyed */
290 unsigned int menu_open_for_me:1; /* window commands menu */
292 unsigned int waiting_save_ack:1; /* waiting for SAVE_YOURSELF ack */
294 unsigned int obscured:1; /* window is obscured */
296 unsigned int dragged_while_fmaximized;
298 unsigned int user_changed_width:1;
299 unsigned int user_changed_height:1;
300 unsigned int wm_name_changed:1;
302 #ifdef NETWM_HINTS
303 unsigned int net_state_from_client:1; /* state hint was set by client */
304 unsigned int net_skip_pager:1;
305 unsigned int net_handle_icon:1;
306 unsigned int net_show_desktop:1;
307 unsigned int net_has_title:1; /* use netwm version of WM_NAME */
308 unsigned int net_has_icon_title:1;
309 #endif
310 } flags; /* state of the window */
312 struct WIcon *icon; /* icon info for the window */
313 int icon_x, icon_y; /* position of the icon */
314 #ifdef NETWM_HINTS
315 int icon_w, icon_h;
316 RImage *net_icon_image;
317 Atom type;
318 #endif
319 } WWindow;
322 #define HAS_TITLEBAR(w) (!(WFLAGP((w), no_titlebar) || (w)->flags.fullscreen))
323 #define HAS_RESIZEBAR(w) (!(WFLAGP((w), no_resizebar) || (w)->flags.fullscreen))
324 #define HAS_BORDER(w) (!(WFLAGP((w), no_border) || (w)->flags.fullscreen))
325 #define IS_MOVABLE(w) (!(WFLAGP((w), no_movable) || (w)->flags.fullscreen))
326 #define IS_RESIZABLE(w) (!(WFLAGP((w), no_resizable) || (w)->flags.fullscreen))
328 #ifdef VIRTUAL_DESKTOP
329 # define IS_VSTUCK(w) (WFLAGP((w), virtual_stick) || (w)->flags.fullscreen)
330 #endif
332 /* XXX: CHECK THIS,.. IT SEEMED WEIRD TO ME!!! */
333 #define IS_OMNIPRESENT(w) ((w)->flags.omnipresent | WFLAGP(w, omnipresent))
335 #define WINDOW_LEVEL(w) ((w)->frame->core->stacking->window_level)
340 * Changes to this must update wWindowSaveState/getSavedState
343 typedef struct WSavedState {
344 int workspace;
345 int miniaturized;
346 int shaded;
347 int hidden;
348 int maximized;
349 int x; /* original geometry of the */
350 int y; /* window if it's maximized */
351 unsigned int w;
352 unsigned int h;
353 unsigned window_shortcuts; /* mask like 1<<shortcut_number */
354 } WSavedState;
357 typedef struct WWindowState {
358 char *instance;
359 char *class;
360 char *command;
361 pid_t pid;
362 WSavedState *state;
363 struct WWindowState *next;
364 } WWindowState;
367 typedef void* WMagicNumber;
371 void wWindowDestroy(WWindow *wwin);
372 WWindow *wWindowCreate();
374 #ifdef SHAPE
375 void wWindowSetShape(WWindow *wwin);
376 void wWindowClearShape(WWindow *wwin);
377 #endif
379 WWindow *wManageWindow(WScreen *scr, Window window);
381 void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
383 void wWindowFocus(WWindow *wwin, WWindow *owin);
384 void wWindowUnfocus(WWindow *wwin);
386 void wWindowUpdateName(WWindow *wwin, char *newTitle);
387 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
388 void wWindowCropSize(WWindow *wwin, int maxw, int maxh,
389 int *nwidth, int *nheight);
390 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
391 int req_width, int req_height);
393 void wWindowMove(WWindow *wwin, int req_x, int req_y);
395 void wWindowSynthConfigureNotify(WWindow *wwin);
397 WWindow *wWindowFor(Window window);
400 void wWindowConfigureBorders(WWindow *wwin);
402 void wWindowUpdateButtonImages(WWindow *wwin);
404 void wWindowSaveState(WWindow *wwin);
406 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
408 void wWindowSetKeyGrabs(WWindow *wwin);
410 void wWindowResetMouseGrabs(WWindow *wwin);
412 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
413 char *title, int x, int y,
414 int width, int height);
416 void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace);
418 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
420 void wWindowMap(WWindow *wwin);
422 void wWindowUnmap(WWindow *wwin);
424 Bool wWindowCanReceiveFocus(WWindow *wwin);
426 void wWindowDeleteSavedStatesForPID(pid_t pid);
428 WMagicNumber wWindowAddSavedState(char *instance, char *class, char *command,
429 pid_t pid, WSavedState *state);
431 WMagicNumber wWindowGetSavedState(Window win);
433 void wWindowDeleteSavedState(WMagicNumber id);
435 Bool wWindowObscuresWindow(WWindow *wwin, WWindow *obscured);
437 void wWindowSetOmnipresent(WWindow *wwin, Bool flag);
439 #endif