Initial revision
[wmaker-crm.git] / src / window.h
blobd750bd18e235f44e1ceefeea858754e66464e7c1
1 /*
2 * WindowMaker 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 } WProtocols;
135 * Stores client window information. Each client window has it's
136 * structure created when it's being first mapped.
138 typedef struct WWindow {
139 struct WWindow *prev; /* window focus list */
140 struct WWindow *next;
142 WScreen *screen_ptr; /* pointer to the screen structure */
143 WWindowAttributes window_flags; /* window attribute flags */
144 struct InspectorPanel *inspector; /* pointer to attribute editor panel */
146 struct WFrameWindow *frame; /* the frame window */
147 int frame_x, frame_y; /* position of the frame in root*/
149 struct {
150 int x, y;
151 unsigned int width, height; /* original geometry of the window */
152 } old_geometry; /* (before things like maximize) */
154 /* client window info */
155 short old_border_width; /* original border width of client_win*/
156 Window client_win; /* the window we're managing */
157 WObjDescriptor client_descriptor; /* dummy descriptor for client */
158 struct {
159 int x, y; /* position of *client* relative
160 * to root */
161 unsigned int width, height; /* size of the client window */
162 } client;
164 XSizeHints *normal_hints; /* WM_NORMAL_HINTS */
165 XWMHints *wm_hints; /* WM_HINTS (optional) */
166 char *wm_instance; /* instance of WM_CLASS */
167 char *wm_class; /* class of WM_CLASS */
168 GNUstepWMAttributes *wm_gnustep_attr;/* GNUstep window attributes */
170 int state; /* state as in ICCCM */
172 Window transient_for; /* WM_TRANSIENT_FOR */
173 Window group_id; /* the leader window of the group */
174 Window client_leader; /* WM_CLIENT_LEADER if not
175 internal_window */
177 Window main_window; /* main window for the application */
179 int cmap_window_no;
180 Window *cmap_windows;
182 /* protocols */
183 WProtocols protocols; /* accepted WM_PROTOCOLS */
185 FocusMode focus_mode; /* type of keyboard input focus */
187 struct {
188 /* state flags */
189 unsigned int mapped:1;
190 unsigned int focused:1;
191 unsigned int miniaturized:1;
192 unsigned int hidden:1;
193 unsigned int shaded:1;
194 unsigned int maximized:2;
196 unsigned int semi_focused:1;
197 /* window type flags */
198 unsigned int urgent:1; /* if wm_hints says this is urgent */
199 #ifdef SHAPE
200 unsigned int shaped:1;
201 #endif
203 /* info flags */
204 unsigned int buttons_dont_fit:1;
205 unsigned int rebuild_texture:1;/* the window was resized and
206 * gradients should be re-rendered */
207 unsigned int needs_full_repaint:1;/* does a full repaint of the
208 * window next time it's painted */
209 unsigned int icon_moved:1; /* icon for this window was moved
210 * by the user */
211 unsigned int ignore_next_unmap:1;
212 unsigned int selected:1; /* multiple window selection */
213 unsigned int skip_next_animation:1;
214 unsigned int internal_window:1;
215 unsigned int changing_workspace:1;
217 unsigned int inspector_open:1; /* attrib inspector is already open */
219 unsigned int destroyed:1; /* window was already destroyed */
220 } flags; /* state of the window */
222 char *icon_text;
223 struct WIcon *icon; /* icon info for the window */
224 int icon_x, icon_y; /* position of the icon */
225 } WWindow;
228 typedef struct WSavedState {
229 int workspace;
230 int miniaturized;
231 int shaded;
232 int hidden;
233 int use_geometry;
234 int x, y, w, h;
235 } WSavedState;
238 typedef struct WWindowState {
239 char *instance;
240 char *class;
241 char *command;
242 pid_t pid;
243 WSavedState *state;
244 struct WWindowState *next;
245 } WWindowState;
248 void wWindowDestroy(WWindow *wwin);
249 WWindow *wWindowCreate();
251 #ifdef SHAPE
252 void wWindowSetShape(WWindow *wwin);
253 #endif
255 WWindow *wManageWindow(WScreen *scr, Window window);
257 void wUnmanageWindow(WWindow *wwin, int restore);
259 void wWindowFocus(WWindow *wwin);
260 void wWindowUnfocus(WWindow *wwin);
261 void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
262 void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
263 int req_width, int req_height);
265 void wWindowMove(WWindow *wwin, int req_x, int req_y);
267 void wWindowSynthConfigureNotify(WWindow *wwin);
269 WWindow *wWindowFor(Window window);
272 void wWindowConfigureBorders(WWindow *wwin);
274 void wWindowUpdateButtonImages(WWindow *wwin);
276 void wWindowSaveState(WWindow *wwin);
278 void wWindowChangeWorkspace(WWindow *wwin, int workspace);
280 void wWindowSetKeyGrabs(WWindow *wwin);
282 void wWindowResetMouseGrabs(WWindow *wwin);
284 WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner,
285 char *title, int x, int y,
286 int width, int height);
288 void wWindowCheckAttributeSanity(WWindow *wwin, WWindowAttributes *flags);
290 void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr);
292 void wWindowMap(WWindow *wwin);
294 Bool wWindowCanReceiveFocus(WWindow *wwin);
296 #endif