2 * Window Maker window manager
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,
34 #include "application.h"
36 /* not defined in my X11 headers */
38 #define UrgencyHint (1L << 8)
43 #define BORDER_BOTTOM 2
45 #define BORDER_RIGHT 8
46 #define BORDER_ALL (1|2|4|8)
49 #define CLIENT_EVENTS (StructureNotifyMask | PropertyChangeMask\
50 | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \
54 WFM_PASSIVE
, WFM_NO_INPUT
, WFM_LOCALLY_ACTIVE
, WFM_GLOBALLY_ACTIVE
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
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;
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? */
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
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
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;
122 * Window manager protocols that both the client as we understand.
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 #ifdef MONITOR_HEARTBEAT
132 unsigned int HEARTBEAT
:1;
138 * Stores client window information. Each client window has it's
139 * structure created when it's being first mapped.
141 typedef struct WWindow
{
142 struct WWindow
*prev
; /* window focus list */
143 struct WWindow
*next
;
145 WScreen
*screen_ptr
; /* pointer to the screen structure */
146 WWindowAttributes window_flags
; /* window attribute flags */
147 struct InspectorPanel
*inspector
; /* pointer to attribute editor panel */
149 struct WFrameWindow
*frame
; /* the frame window */
150 int frame_x
, frame_y
; /* position of the frame in root*/
154 unsigned int width
, height
; /* original geometry of the window */
155 } old_geometry
; /* (before things like maximize) */
157 /* client window info */
158 short old_border_width
; /* original border width of client_win*/
159 Window client_win
; /* the window we're managing */
160 WObjDescriptor client_descriptor
; /* dummy descriptor for client */
162 int x
, y
; /* position of *client* relative
164 unsigned int width
, height
; /* size of the client window */
167 XSizeHints
*normal_hints
; /* WM_NORMAL_HINTS */
168 XWMHints
*wm_hints
; /* WM_HINTS (optional) */
169 char *wm_instance
; /* instance of WM_CLASS */
170 char *wm_class
; /* class of WM_CLASS */
171 GNUstepWMAttributes
*wm_gnustep_attr
;/* GNUstep window attributes */
173 int state
; /* state as in ICCCM */
175 Window transient_for
; /* WM_TRANSIENT_FOR */
176 Window group_id
; /* the leader window of the group */
177 Window client_leader
; /* WM_CLIENT_LEADER if not
180 Window main_window
; /* main window for the application */
183 Window
*cmap_windows
;
186 WProtocols protocols
; /* accepted WM_PROTOCOLS */
188 FocusMode focus_mode
; /* type of keyboard input focus */
190 #ifdef KEEP_XKB_LOCK_STATUS
192 #endif /* KEEP_XKB_LOCK_STATUS */
194 #ifdef MONITOR_HEARTBEAT
199 unsigned int mapped
:1;
200 unsigned int focused
:1;
201 unsigned int miniaturized
:1;
202 unsigned int hidden
:1;
203 unsigned int shaded
:1;
204 unsigned int maximized
:2;
206 unsigned int semi_focused
:1;
207 /* window type flags */
208 unsigned int urgent
:1; /* if wm_hints says this is urgent */
210 unsigned int shaped
:1;
214 unsigned int buttons_dont_fit
:1;
215 unsigned int rebuild_texture
:1;/* the window was resized and
216 * gradients should be re-rendered */
217 unsigned int needs_full_repaint
:1;/* does a full repaint of the
218 * window next time it's painted */
219 unsigned int icon_moved
:1; /* icon for this window was moved
221 unsigned int ignore_next_unmap
:1;
222 unsigned int selected
:1; /* multiple window selection */
223 unsigned int skip_next_animation
:1;
224 unsigned int internal_window
:1;
225 unsigned int changing_workspace
:1;
227 unsigned int inspector_open
:1; /* attrib inspector is already open */
229 unsigned int destroyed
:1; /* window was already destroyed */
231 unsigned int menu_open_for_me
:1; /* window commands menu */
232 } flags
; /* state of the window */
234 struct WIcon
*icon
; /* icon info for the window */
235 int icon_x
, icon_y
; /* position of the icon */
240 * Changes to this must update wWindowSaveState/getSavedState
243 typedef struct WSavedState
{
256 typedef struct WWindowState
{
262 struct WWindowState
*next
;
266 typedef void* WMagicNumber
;
270 void wWindowDestroy(WWindow
*wwin
);
271 WWindow
*wWindowCreate();
274 void wWindowSetShape(WWindow
*wwin
);
275 void wWindowClearShape(WWindow
*wwin
);
278 WWindow
*wManageWindow(WScreen
*scr
, Window window
);
280 void wUnmanageWindow(WWindow
*wwin
, int restore
);
282 void wWindowFocus(WWindow
*wwin
);
283 void wWindowUnfocus(WWindow
*wwin
);
284 void wWindowConstrainSize(WWindow
*wwin
, int *nwidth
, int *nheight
);
285 void wWindowConfigure(WWindow
*wwin
, int req_x
, int req_y
,
286 int req_width
, int req_height
);
288 void wWindowMove(WWindow
*wwin
, int req_x
, int req_y
);
290 void wWindowSynthConfigureNotify(WWindow
*wwin
);
292 WWindow
*wWindowFor(Window window
);
295 void wWindowConfigureBorders(WWindow
*wwin
);
297 void wWindowUpdateButtonImages(WWindow
*wwin
);
299 void wWindowSaveState(WWindow
*wwin
);
301 void wWindowChangeWorkspace(WWindow
*wwin
, int workspace
);
303 void wWindowSetKeyGrabs(WWindow
*wwin
);
305 void wWindowResetMouseGrabs(WWindow
*wwin
);
307 WWindow
*wManageInternalWindow(WScreen
*scr
, Window window
, Window owner
,
308 char *title
, int x
, int y
,
309 int width
, int height
);
311 void wWindowCheckAttributeSanity(WWindow
*wwin
, WWindowAttributes
*flags
);
313 void wWindowUpdateGNUstepAttr(WWindow
*wwin
, GNUstepWMAttributes
*attr
);
315 void wWindowMap(WWindow
*wwin
);
317 Bool
wWindowCanReceiveFocus(WWindow
*wwin
);
319 void wWindowDeleteSavedStatesForPID(pid_t pid
);
321 WMagicNumber
wWindowAddSavedState(char *instance
, char *class, char *command
,
322 pid_t pid
, WSavedState
*state
);
324 WMagicNumber
wWindowGetSavedState(Window win
);
326 void wWindowDeleteSavedState(WMagicNumber id
);