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.
25 #include "WindowMaker.h"
26 #include <sys/types.h>
28 #include <WINGs/WUtil.h>
30 #define PRINT_SCREEN 1
31 #define PRINT_WINDOW 2
32 #define PRINT_PARTIAL 3
36 int count
; /* screen count, 0 = inactive */
37 int primary_head
; /* main working screen */
42 /* an area of the screen reserved by some window */
43 typedef struct WReservedArea
{
46 struct WReservedArea
*next
;
50 typedef struct WAppIconChain
{
51 struct WAppIcon
*aicon
;
52 struct WAppIconChain
*next
;
56 /* Drawers, which are docks, really */
57 typedef struct WDrawerChain
{
58 struct WDock
*adrawer
;
59 struct WDrawerChain
*next
;
63 * each WScreen is saved into a context associated with its root window
65 typedef struct _WScreen
{
66 int screen
; /* screen number */
67 Window info_window
; /* for our window manager info stuff */
68 #ifdef USE_ICCCM_WMREPLACE
69 Atom sn_atom
; /* window manager selection */
72 int scr_width
; /* size of the screen */
75 Window root_win
; /* root window of screen */
76 int depth
; /* depth of the default visual */
77 Colormap colormap
; /* root colormap */
78 int root_colormap_install_count
;
79 struct WWindow
*original_cmap_window
; /* colormap before installing
80 * root colormap temporarily */
81 struct WWindow
*cmap_window
;
82 Colormap current_colormap
;
84 Window w_win
; /* window to use as drawable
85 * for new GCs, pixmaps etc. */
88 Colormap w_colormap
; /* our colormap */
90 WXineramaInfo xine_info
;
92 Window no_focus_win
; /* window to get focus when nobody
95 struct WWindow
*focused_window
; /* window that has the focus
96 * Use this list if you want to
97 * traverse the entire window list
99 struct WWindow
*bfs_focused_window
; /* window that had focus before
100 * another window entered fullscreen
103 WMArray
*selected_windows
;
105 WMArray
*fakeGroupLeaders
; /* list of fake window group ids */
107 struct WAppIcon
*app_icon_list
; /* list of all app-icons on screen */
109 struct WApplication
*wapp_list
; /* list of all aplications */
111 WMBag
*stacking_list
; /* bag of lists of windows
113 * Indexed by window level
114 * and each list on the array
115 * is ordered from the topmost to
119 int window_count
; /* number of windows in window_list */
121 int workspace_count
; /* number of workspaces */
123 struct WWorkspace
**workspaces
; /* workspace array */
125 int current_workspace
; /* current workspace number */
126 int last_workspace
; /* last used workspace number */
129 WReservedArea
*reservedAreas
; /* used to build totalUsableArea */
131 WArea
*usableArea
; /* area of the workspace where
132 * we can put windows on, as defined
133 * by other clients (not us) */
134 WArea
*totalUsableArea
; /* same as above, but including
135 * the dock and other stuff */
142 /* shortcuts for the pixels of the above colors. just for convenience */
148 Pixmap stipple_bitmap
;
149 Pixmap transp_stipple
; /* for making holes in icon masks for
150 * transparent icon simulation */
151 WMFont
*title_font
; /* default font for the titlebars */
152 WMFont
*menu_title_font
; /* font for menu titlebars */
153 WMFont
*menu_entry_font
; /* font for menu items */
154 WMFont
*icon_title_font
; /* for icon titles */
155 WMFont
*clip_title_font
; /* for clip titles */
156 WMFont
*info_text_font
; /* text on things like geometry
159 XFontStruct
*tech_draw_font
; /* font for tech draw style geom view
160 needs to be a core font so we can
161 use it with a XORing GC */
163 WMFont
*workspace_name_font
;
165 WMColor
*select_color
;
166 WMColor
*select_text_color
;
167 /* foreground colors */
168 WMColor
*window_title_color
[3]; /* window titlebar text (foc, unfoc, pfoc)*/
169 WMColor
*menu_title_color
[3]; /* menu titlebar text */
170 WMColor
*clip_title_color
[2]; /* clip title text */
171 WMColor
*mtext_color
; /* menu item text */
172 WMColor
*dtext_color
; /* disabled menu item text */
174 int frame_border_width
;
175 WMColor
*frame_border_color
;
176 WMColor
*frame_focused_border_color
;
177 WMColor
*frame_selected_border_color
;
180 WMPixel frame_border_pixel
; /* frame border */
181 WMPixel frame_focused_border_pixel
; /* frame border */
182 WMPixel frame_selected_border_pixel
;/* frame border */
185 union WTexture
*menu_title_texture
[3];/* menu titlebar texture (tex, -, -) */
186 union WTexture
*window_title_texture
[3]; /* win textures (foc, unfoc, pfoc) */
187 union WTexture
*resizebar_texture
[3];/* window resizebar texture (tex, -, -) */
189 union WTexture
*menu_item_texture
; /* menu item texture */
191 struct WTexSolid
*menu_item_auxtexture
; /* additional texture to draw menu
193 struct WTexSolid
*icon_title_texture
;/* icon titles */
195 struct WTexSolid
*widget_texture
;
197 struct WTexSolid
*icon_back_texture
; /* icon back color for shadowing */
200 WMColor
*icon_title_color
; /* icon title color */
204 GC frame_gc
; /* gc for resize/move frame (root) */
205 GC line_gc
; /* gc for drawing XORed lines (root) */
206 GC copy_gc
; /* gc for XCopyArea() */
207 GC stipple_gc
; /* gc for stippled filling */
208 GC draw_gc
; /* gc for drawing misc things */
209 GC mono_gc
; /* gc for 1 bit drawables */
211 struct WPixmap
*b_pixmaps
[PRED_BPIXMAPS
]; /* internal pixmaps for buttons*/
212 struct WPixmap
*menu_radio_indicator
;/* left menu indicator */
213 struct WPixmap
*menu_check_indicator
;/* left menu indicator for checkmark */
214 struct WPixmap
*menu_mini_indicator
; /* for miniwindow */
215 struct WPixmap
*menu_hide_indicator
; /* for hidden window */
216 struct WPixmap
*menu_shade_indicator
; /* for shaded window */
217 struct WPixmap
*menu_snap_vertically_indicator
; /* for vertically snap window */
218 struct WPixmap
*menu_snap_horizontally_indicator
; /* for horizontally snap window */
219 struct WPixmap
*menu_snap_rh_indicator
; /* for righ half snap window */
220 struct WPixmap
*menu_snap_lh_indicator
; /* for left half snap window */
221 struct WPixmap
*menu_snap_th_indicator
; /* for top half snap window */
222 struct WPixmap
*menu_snap_bh_indicator
; /* for bottom half snap window */
223 struct WPixmap
*menu_snap_tl_indicator
; /* for top left snap window */
224 struct WPixmap
*menu_snap_tr_indicator
; /* for top rigt snap window */
225 struct WPixmap
*menu_snap_bl_indicator
; /* for bottom left snap window */
226 struct WPixmap
*menu_snap_br_indicator
; /* for bottom right snap window */
227 struct WPixmap
*menu_snap_tiled_indicator
; /* for tiled window */
229 int app_menu_x
, app_menu_y
; /* position for application menus */
231 struct WMenu
*root_menu
; /* root window menu */
232 struct WMenu
*switch_menu
; /* window list menu */
233 struct WMenu
*workspace_menu
; /* workspace operation */
234 struct WMenu
*window_menu
; /* window command menu */
235 struct WMenu
*icon_menu
; /* icon/appicon menu */
236 struct WMenu
*workspace_submenu
; /* workspace list for window_menu */
238 struct WDock
*dock
; /* the application dock */
239 struct WMenu
*dock_pos_menu
; /* Dock position menu */
240 struct WPixmap
*dock_dots
; /* 3 dots for the Dock */
241 Window dock_shadow
; /* shadow for dock buttons */
242 struct WAppIcon
*clip_icon
; /* The clip main icon, or the dock's, if they are merged */
243 struct WMenu
*clip_menu
; /* Menu for clips */
244 struct WMenu
*clip_submenu
; /* Workspace list for clips */
245 struct WMenu
*clip_options
; /* Options for Clip */
246 struct WMenu
*clip_ws_menu
; /* workspace menu for clip */
247 struct WMenu
*drawer_menu
; /* Menu for drawers */
248 struct WDock
*last_dock
;
249 WAppIconChain
*global_icons
; /* for omnipresent icons chain in clip */
250 int global_icon_count
; /* How many global icons do we have */
251 WDrawerChain
*drawers
; /* Chain of drawers */
252 /* Cache the following two informations, as they are used quite a lot */
253 int drawer_count
; /* Nb of drawers that */
254 struct WDock
*attracting_drawer
; /* The drawer that auto-attracts icons, or NULL */
256 struct RContext
*rcontext
; /* wrlib context */
258 WMScreen
*wmscreen
; /* for widget library */
260 struct RImage
*icon_tile
;
261 struct RImage
*clip_tile
; /* tile with arrows to change workspace */
262 struct RImage
*drawer_tile
; /* tile for a drawer (tile + arrow) */
263 Pixmap icon_tile_pixmap
; /* For app supplied icons */
265 struct RImage
*def_icon_rimage
; /* Default RImage icon */
267 struct WDialogData
*dialog_data
;
269 struct W_GeometryView
*gview
; /* size/position view */
271 /* state and other informations */
272 short cascade_index
; /* for cascade window placement */
274 WMPropList
*session_state
;
276 /* for double-click detection */
277 Time last_click_time
;
278 Window last_click_window
;
279 int last_click_button
;
281 /* balloon help data */
282 struct _WBalloon
*balloon
;
284 /* workspace name data */
285 Window workspace_name
;
286 WMHandlerID
*workspace_name_timer
;
287 struct WorkspaceNameData
*workspace_name_data
;
289 /* mini screenshot data */
290 Window mini_screenshot
;
291 time_t mini_screenshot_timeout
;
292 WMHandlerID
*mini_screenshot_timer
;
294 /* for raise-delay */
295 WMHandlerID
*autoRaiseTimer
;
296 Window autoRaiseWindow
; /* window that is scheduled to be
298 /* for hot-corners delay */
299 WMHandlerID
*hot_corner_timer
;
301 /* for window shortcuts */
302 WMArray
*shortcutWindows
[MAX_WINDOW_SHORTCUTS
];
308 struct NetData
*netdata
;
314 unsigned int startup
:1; /* during window manager startup */
315 unsigned int regenerate_icon_textures
:1;
316 unsigned int dnd_data_convertion_status
:1;
317 unsigned int root_menu_changed_shortcuts
:1;
318 unsigned int added_workspace_menu
:1;
319 unsigned int added_windows_menu
:1;
320 unsigned int startup2
:1; /* startup phase 2 */
321 unsigned int next_click_is_not_double
:1;
322 unsigned int backimage_helper_launched
:1;
323 /* some client has issued a WM_COLORMAP_NOTIFY */
324 unsigned int colormap_stuff_blocked
:1;
325 unsigned int doing_alt_tab
:1;
326 unsigned int jump_back_pending
:1;
327 unsigned int ignore_focus_events
:1;
328 unsigned int in_hot_corner
:3;
334 WScreen
*wScreenInit(int screen_number
);
335 void wScreenSaveState(WScreen
*scr
);
336 void wScreenRestoreState(WScreen
*scr
);
338 int wScreenBringInside(WScreen
*scr
, int *x
, int *y
, int width
, int height
);
339 int wScreenKeepInside(WScreen
*scr
, int *x
, int *y
, int width
, int height
);
340 void ScreenCapture(WScreen
*scr
, int mode
);
343 WScreen
*wScreenWithNumber(int i
);
344 WScreen
*wScreenForRootWindow(Window window
); /* window must be valid */
345 WScreen
*wScreenForWindow(Window window
); /* slower than above functions */
347 void wScreenFinish(WScreen
*scr
);
348 void wScreenUpdateUsableArea(WScreen
*scr
);
350 void create_logo_image(WScreen
*scr
);