Update Serbian translation from master branch
[wmaker-crm.git] / src / window.h
blob1e678f7b7f38aa340ee00bec166e78fab1127f8f
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef WMWINDOW_H_
22 #define WMWINDOW_H_
24 #include <wraster.h>
26 #include "wconfig.h"
27 #include "GNUstep.h"
28 #include "texture.h"
29 #include "menu.h"
30 #include "application.h"
32 /* not defined in my X11 headers */
33 #ifndef UrgencyHint
34 #define UrgencyHint (1L << 8)
35 #endif
38 #define BORDER_TOP 1
39 #define BORDER_BOTTOM 2
40 #define BORDER_LEFT 4
41 #define BORDER_RIGHT 8
42 #define BORDER_ALL (1|2|4|8)
45 #define CLIENT_EVENTS (StructureNotifyMask | PropertyChangeMask\
46 | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \
47 | FocusChangeMask | VisibilityChangeMask)
49 typedef enum {
50 WFM_PASSIVE, WFM_NO_INPUT, WFM_LOCALLY_ACTIVE, WFM_GLOBALLY_ACTIVE
51 } FocusMode;
55 * window attribute flags.
57 * Note: attributes that should apply to the application as a
58 * whole should only access the flags from app->main_window_desc->window_flags
59 * This is to make sure that the application doesn't have many different
60 * values for the same option. For example, imagine xfoo, which has
61 * foo.bar as leader and it a child window named foo.baz. If you set
62 * StartHidden YES for foo.bar and NO for foo.baz we must *always* guarantee
63 * that the value that will be used will be that of the leader foo.bar.
64 * The attributes inspector must always save application wide options
65 * in the name of the leader window, not the child.
69 * All flags must have their default values = 0
71 * New flag scheme:
73 * user_flags, defined_flags
74 * client_flags
76 * if defined window_flag then window_flag else client_flag
80 #define WFLAGP(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \
81 ? (wwin)->user_flags.FLAG \
82 : (wwin)->client_flags.FLAG)
84 #define WSETUFLAG(wwin, FLAG, VAL) (wwin)->user_flags.FLAG = (VAL),\
85 (wwin)->defined_user_flags.FLAG = 1
87 typedef struct {
88 /* OpenStep */
89 unsigned int no_titlebar:1; /* draw titlebar? */
90 unsigned int no_resizable:1;
91 unsigned int no_closable:1;
92 unsigned int no_miniaturizable:1;
93 unsigned int no_border:1; /* 1 pixel border around window */
94 #ifdef XKB_BUTTON_HINT
95 unsigned int no_language_button:1;
96 #endif
97 unsigned int no_movable:1;
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 skip_switchpanel: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;
128 unsigned int focus_across_wksp:1; /* let wmaker switch workspace to follow
129 * a focus request */
131 unsigned int always_user_icon:1; /* ignore client IconPixmap or
132 * IconWindow */
134 unsigned int start_miniaturized:1;
135 unsigned int start_hidden:1;
136 unsigned int start_maximized:1;
137 unsigned int dont_save_session:1; /* do not save app's state in session */
139 unsigned int full_maximize:1;
141 * emulate_app_icon must be automatically disabled for apps that can
142 * generate their own appicons and for apps that have no_appicon=1
144 unsigned int emulate_appicon:1;
145 /* Ignore any changes to the decoration elements (titlebar, etc) */
146 unsigned int ignore_decoration_changes:1;
148 } WWindowAttributes;
153 * Window manager protocols that both the client as we understand.
155 typedef struct {
156 unsigned int TAKE_FOCUS:1;
157 unsigned int DELETE_WINDOW:1;
158 unsigned int SAVE_YOURSELF:1;
159 /* WindowMaker specific */
160 unsigned int MINIATURIZE_WINDOW:1;
161 } WProtocols;
165 * Structure used for storing fake window group information
167 typedef struct WFakeGroupLeader {
168 char *identifier;
169 Window leader;
170 Window origLeader;
171 int retainCount;
172 } WFakeGroupLeader;
176 * Stores client window information. Each client window has its
177 * structure created when it's being first mapped.
179 typedef struct WWindow {
180 struct WWindow *prev; /* window focus list */
181 struct WWindow *next;
183 WScreen *screen_ptr; /* pointer to the screen structure */
184 WWindowAttributes user_flags; /* window attribute flags set by user */
185 WWindowAttributes defined_user_flags; /* mask for user_flags */
186 WWindowAttributes client_flags; /* window attribute flags set by app
187 * initialized with global defaults */
189 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
191 struct WFrameWindow *frame; /* the frame window */
192 int frame_x, frame_y; /* position of the frame in root*/
194 struct {
195 int x, y;
196 unsigned int width, height; /* original geometry of the window */
197 } old_geometry; /* (before things like maximize) */
199 struct {
200 int x, y;
201 unsigned int width, height; /* original geometry of the window */
202 } bfs_geometry; /* (before fullscreen) */
204 int maximus_x; /* size after Maximusizing */
205 int maximus_y;
207 /* client window info */
208 short old_border_width; /* original border width of client_win*/
209 Window client_win; /* the window we're managing */
210 WObjDescriptor client_descriptor; /* dummy descriptor for client */
211 struct {
212 int x, y; /* position of *client* relative
213 * to root */
214 unsigned int width, height; /* size of the client window */
215 } client;
217 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
218 XWMHints *wm_hints; /* WM_HINTS (optional) */
219 char *wm_instance; /* instance of WM_CLASS */
220 char *wm_class; /* class of WM_CLASS */
221 GNUstepWMAttributes *wm_gnustep_attr; /* GNUstep window attributes */
223 int state; /* state as in ICCCM */
225 Window transient_for; /* WM_TRANSIENT_FOR */
227 WFakeGroupLeader *fake_group; /* Fake group leader for grouping into
228 * a single appicon */
229 Window group_id; /* the leader window of the group */
230 Window client_leader; /* WM_CLIENT_LEADER if not
231 * internal_window */
233 Window main_window; /* main window for the application */
234 Window orig_main_window; /* original main window of application.
235 * used for the shared appicon thing */
237 int cmap_window_no;
238 Window *cmap_windows;
240 /* protocols */
241 WProtocols protocols; /* accepted WM_PROTOCOLS */
243 FocusMode focus_mode; /* type of keyboard input focus */
245 long event_mask; /* the event mask thats selected */
247 /* state flags */
248 struct {
249 unsigned int mapped:1;
250 unsigned int focused:1;
251 unsigned int miniaturized:1;
252 unsigned int hidden:1;
253 unsigned int shaded:1;
254 unsigned int maximized:10;
255 unsigned int old_maximized:10;
256 unsigned int fullscreen:1;
257 long fullscreen_monitors[4];
258 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 USE_XSHAPE
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 */
269 unsigned int is_dockapp:1; /* 1 if the window belongs to a DockApp */
271 unsigned int icon_moved:1; /* icon for this window was moved
272 * by the user */
273 unsigned int selected:1; /* multiple window selection */
274 unsigned int skip_next_animation:1;
275 unsigned int internal_window:1;
276 unsigned int changing_workspace:1;
278 unsigned int inspector_open:1; /* attrib inspector is already open */
280 unsigned int destroyed:1; /* window was already destroyed */
281 unsigned int menu_open_for_me:1;/* window commands menu */
282 unsigned int obscured:1; /* window is obscured */
284 unsigned int net_skip_pager:1;
285 unsigned int net_handle_icon:1;
286 unsigned int net_show_desktop:1;
287 unsigned int net_has_title:1; /* use netwm version of WM_NAME */
288 } flags; /* state of the window */
290 struct WIcon *icon; /* Window icon when miminized
291 * else is NULL! */
292 int icon_x, icon_y; /* position of the icon */
293 int icon_w, icon_h;
294 RImage *net_icon_image; /* Window Image */
295 Atom type;
296 } WWindow;
298 #define HAS_TITLEBAR(w) (!(WFLAGP((w), no_titlebar) || (w)->flags.fullscreen))
299 #define HAS_RESIZEBAR(w) (!(WFLAGP((w), no_resizebar) || (w)->flags.fullscreen))
300 #define HAS_BORDER(w) (!(WFLAGP((w), no_border) || (w)->flags.fullscreen))
301 #define IS_MOVABLE(w) (!(WFLAGP((w), no_movable) || (w)->flags.fullscreen))
302 #define IS_RESIZABLE(w) (!(WFLAGP((w), no_resizable) || (w)->flags.fullscreen))
303 #define IS_OMNIPRESENT(w) ((w)->flags.omnipresent | WFLAGP(w, omnipresent))
304 #define WINDOW_LEVEL(w) ((w)->frame->core->stacking->window_level)
307 * Changes to this must update wWindowSaveState/getSavedState
309 typedef struct WSavedState {
310 int workspace;
311 int miniaturized;
312 int maximized;
313 int shaded;
314 int hidden;
315 int x; /* original geometry of the */
316 int y; /* window if it's maximized */
317 unsigned int w;
318 unsigned int h;
319 unsigned window_shortcuts; /* mask like 1<<shortcut_number */
320 } WSavedState;
322 typedef struct WWindowState {
323 char *instance;
324 char *class;
325 char *command;
326 pid_t pid;
327 WSavedState *state;
328 struct WWindowState *next;
329 } WWindowState;
331 typedef void* WMagicNumber;
333 void wWindowDestroy(WWindow *wwin);
334 WWindow *wWindowCreate(void);
336 #ifdef USE_XSHAPE
337 void wWindowSetShape(WWindow *wwin);
338 void wWindowClearShape(WWindow *wwin);
339 #endif
341 WWindow *wManageWindow(WScreen *scr, Window window);
343 void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
345 void wWindowSingleFocus(WWindow *wwin);
346 void wWindowFocusPrev(WWindow *wwin, Bool inSameWorkspace);
347 void wWindowFocusNext(WWindow *wwin, Bool inSameWorkspace);
348 void wWindowFocus(WWindow *wwin, WWindow *owin);
349 void wWindowUnfocus(WWindow *wwin);
351 void wWindowUpdateName(WWindow *wwin, const char *newTitle);
352 void wWindowConstrainSize(WWindow *wwin, unsigned int *nwidth, unsigned int *nheight);
353 void wWindowCropSize(WWindow *wwin, unsigned int maxw, unsigned int maxh,
354 unsigned int *nwidth, unsigned int *nheight);
355 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
356 int req_width, int req_height);
358 void wWindowMove(WWindow *wwin, int req_x, int req_y);
360 void wWindowSynthConfigureNotify(WWindow *wwin);
362 WWindow *wWindowFor(Window window);
365 void wWindowConfigureBorders(WWindow *wwin);
367 void wWindowUpdateButtonImages(WWindow *wwin);
369 void wWindowSaveState(WWindow *wwin);
371 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
372 void wWindowChangeWorkspaceRelative(WWindow *wwin, int amount);
374 void wWindowSetKeyGrabs(WWindow *wwin);
376 void wWindowResetMouseGrabs(WWindow *wwin);
378 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
379 const char *title, int x, int y,
380 int width, int height);
382 void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace);
384 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
386 void wWindowMap(WWindow *wwin);
388 void wWindowUnmap(WWindow *wwin);
390 void wWindowDeleteSavedStatesForPID(pid_t pid);
392 WMagicNumber wWindowAddSavedState(const char *instance, const char *class, const char *command,
393 pid_t pid, WSavedState *state);
395 WMagicNumber wWindowGetSavedState(Window win);
397 void wWindowDeleteSavedState(WMagicNumber id);
399 Bool wWindowObscuresWindow(WWindow *wwin, WWindow *obscured);
401 void wWindowSetOmnipresent(WWindow *wwin, Bool flag);
402 #endif