1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Screen.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
30 #ifdef TIME_WITH_SYS_TIME
31 # include <sys/time.h>
33 #else // !TIME_WITH_SYS_TIME
34 # ifdef HAVE_SYS_TIME_H
35 # include <sys/time.h>
36 # else // !HAVE_SYS_TIME_H
38 # endif // HAVE_SYS_TIME_H
39 #endif // TIME_WITH_SYS_TIME
48 #include "Configmenu.hh"
49 #include "Iconmenu.hh"
51 #include "Rootmenu.hh"
53 #include "Workspace.hh"
54 #include "Workspacemenu.hh"
55 #include "blackbox.hh"
57 class Slit
; // forward reference
62 enum TextJustify
{ LeftJustify
= 1, RightJustify
, CenterJustify
};
69 #endif // BITMAPBUTTONS
72 BColor l_text_focus
, l_text_unfocus
, b_pic_focus
,
74 BTexture f_focus
, f_unfocus
, t_focus
, t_unfocus
, l_focus
, l_unfocus
,
75 h_focus
, h_unfocus
, b_focus
, b_unfocus
, b_pressed
, g_focus
, g_unfocus
;
78 PixmapMask close_button
, max_button
, icon_button
, stick_button
;
79 #endif // BITMAPBUTTONS
84 void doJustify(const std::string
&text
, int &start_pos
,
85 unsigned int max_length
, unsigned int modifier
) const;
89 BColor l_text
, w_text
, c_text
, b_pic
;
90 BTexture toolbar
, label
, window
, button
, pressed
, clock
;
93 PixmapMask left_button
, right_button
;
94 #endif // BITMAPBUTTONS
100 void doJustify(const std::string
&text
, int &start_pos
,
101 unsigned int max_length
, unsigned int modifier
) const;
105 BColor t_text
, f_text
, h_text
, d_text
;
106 BTexture title
, frame
, hilite
;
109 PixmapMask bullet_image
, tick_image
;
110 #endif // BITMAPBUTTONS
112 BFont
*t_font
, *f_font
;
114 TextJustify t_justify
, f_justify
;
115 int bullet
, bullet_pos
;
118 class BScreen
: public ScreenInfo
{
120 bool root_colormap_installed
, managed
, geom_visible
;
126 BImageControl
*image_control
;
127 Configmenu
*configmenu
;
130 Configuration
*config
;
133 typedef std::list
<Rootmenu
*> RootmenuList
;
134 RootmenuList rootmenuList
;
136 typedef std::list
<Netizen
*> NetizenList
;
137 NetizenList netizenList
;
138 BlackboxWindowList iconList
, windowList
;
140 typedef std::vector
<Window
> WindowList
;
141 WindowList specialWindowList
, desktopWindowList
, systrayWindowList
;
145 Workspace
*current_workspace
;
146 Workspacemenu
*workspacemenu
;
148 unsigned int geom_w
, geom_h
;
149 unsigned long event_mask
;
153 RectList xineramaUsableArea
;
156 typedef std::list
<Strut
*> StrutList
;
158 typedef std::vector
<Workspace
*> WorkspaceList
;
159 WorkspaceList workspacesList
;
161 struct screen_resource
{
166 bool sloppy_focus
, auto_raise
, auto_edge_balance
, ordered_dither
,
167 opaque_move
, full_max
, focus_new
, focus_last
, click_raise
,
168 allow_scroll_lock
, hide_toolbar
, window_corner_snap
, aa_fonts
,
169 ignore_shaded
, ignore_maximized
, workspace_warping
, shadow_fonts
;
171 int snap_to_windows
, snap_to_edges
;
172 unsigned int snap_offset
;
176 unsigned int workspaces
;
177 int toolbar_placement
, toolbar_width_percent
, placement_policy
,
178 snap_threshold
, row_direction
, col_direction
, root_scroll
,
181 unsigned int handle_width
, bevel_width
, frame_width
, border_width
,
184 unsigned int root_menu_button
, workspace_menu_button
;
187 std::string strftime_format
;
188 #else // !HAVE_STRFTIME
191 #endif // HAVE_STRFTIME
194 std::string screenstr
;
196 BScreen(const BScreen
&);
197 BScreen
& operator=(const BScreen
&);
199 bool parseMenuFile(FILE *file
, Rootmenu
*menu
);
202 void readDatabaseMask(const string
&rname
,
203 PixmapMask
&pixmapMask
,
204 const Configuration
&style
);
205 #endif // BITMAPBUTTONS
207 BTexture
readDatabaseTexture(const std::string
&rname
,
208 const std::string
&default_color
,
209 const Configuration
&style
);
210 BColor
readDatabaseColor(const std::string
&rname
,
211 const std::string
&default_color
,
212 const Configuration
&style
);
213 BFont
*readDatabaseFont(const std::string
&rbasename
,
214 const Configuration
&style
);
217 void LoadStyle(void);
219 void updateWorkArea(void);
221 enum { WindowNoSnap
= 0, WindowSnap
, WindowResistance
};
222 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
223 UnderMousePlacement
, ClickMousePlacement
, LeftRight
, RightLeft
,
224 TopBottom
, BottomTop
, IgnoreShaded
, IgnoreMaximized
};
225 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
226 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
227 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
228 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
229 enum FocusModel
{ SloppyFocus
, ClickToFocus
};
230 enum RootScrollDirection
{ NoScroll
= 0, NormalScroll
, ReverseScroll
};
232 BScreen(Blackbox
*bb
, unsigned int scrn
);
235 inline bool isSloppyFocus(void) const { return resource
.sloppy_focus
; }
236 inline bool isRootColormapInstalled(void) const
237 { return root_colormap_installed
; }
238 inline bool doAutoRaise(void) const { return resource
.auto_raise
; }
239 inline bool doClickRaise(void) const { return resource
.click_raise
; }
240 inline bool isScreenManaged(void) const { return managed
; }
241 inline bool doShadowFonts(void) const { return resource
.shadow_fonts
; }
242 inline bool doAAFonts(void) const { return resource
.aa_fonts
; }
243 inline bool doImageDither(void) const { return image_control
->doDither(); }
244 inline bool doOrderedDither(void) const { return resource
.ordered_dither
; }
245 inline bool doOpaqueMove(void) const { return resource
.opaque_move
; }
246 inline bool doFullMax(void) const { return resource
.full_max
; }
247 inline bool doFocusNew(void) const { return resource
.focus_new
; }
248 inline bool doFocusLast(void) const { return resource
.focus_last
; }
249 inline bool doHideToolbar(void) const { return resource
.hide_toolbar
; }
250 inline int getWindowToWindowSnap(void) const
251 { return resource
.snap_to_windows
; }
252 inline int getWindowToEdgeSnap(void) const
253 { return resource
.snap_to_edges
; }
254 inline bool getWindowCornerSnap(void) const
255 { return resource
.window_corner_snap
; }
256 inline bool allowScrollLock(void) const { return resource
.allow_scroll_lock
; }
257 inline bool doWorkspaceWarping(void) const
258 { return resource
.workspace_warping
; }
259 inline int rootScrollDirection(void) const { return resource
.root_scroll
; }
260 inline unsigned int rootMenuButton(void) const
261 { return resource
.root_menu_button
; }
262 inline unsigned int workspaceMenuButton(void) const
263 { return resource
.workspace_menu_button
; }
265 inline const GC
&getOpGC(void) const { return opGC
; }
267 inline Blackbox
*getBlackbox(void) { return blackbox
; }
268 inline BColor
*getBorderColor(void) { return &resource
.border_color
; }
269 inline BImageControl
*getImageControl(void) { return image_control
; }
270 inline Rootmenu
*getRootmenu(void) { return rootmenu
; }
272 inline Slit
*getSlit(void) { return slit
; }
273 inline Toolbar
*getToolbar(void) { return toolbar
; }
275 Workspace
*getWorkspace(unsigned int index
);
277 inline Workspace
*getCurrentWorkspace(void) { return current_workspace
; }
279 inline Workspacemenu
*getWorkspacemenu(void) { return workspacemenu
; }
281 inline unsigned int getHandleWidth(void) const
282 { return resource
.handle_width
; }
283 inline unsigned int getBevelWidth(void) const
284 { return resource
.bevel_width
; }
285 inline unsigned int getFrameWidth(void) const
286 { return resource
.frame_width
; }
287 inline unsigned int getBorderWidth(void) const
288 { return resource
.border_width
; }
289 inline unsigned int getResizeZones(void) const
290 { return resource
.resize_zones
; }
291 inline bool getPlaceIgnoreShaded(void) const
292 { return resource
.ignore_shaded
; }
293 inline bool getPlaceIgnoreMaximized(void) const
294 { return resource
.ignore_maximized
; }
296 inline unsigned int getCurrentWorkspaceID(void) const
297 { return current_workspace
->getID(); }
298 inline unsigned int getWorkspaceCount(void) const
299 { return workspacesList
.size(); }
300 inline unsigned int getIconCount(void) const { return iconList
.size(); }
301 inline unsigned int getNumberOfWorkspaces(void) const
302 { return resource
.workspaces
; }
303 inline int getPlacementPolicy(void) const
304 { return resource
.placement_policy
; }
305 inline int getSnapOffset(void) const
306 { return resource
.snap_offset
; }
307 inline int getSnapThreshold(void) const
308 { return resource
.snap_threshold
; }
309 inline int getResistanceSize(void) const
310 { return resource
.resistance_size
; }
311 inline int getRowPlacementDirection(void) const
312 { return resource
.row_direction
; }
313 inline int getColPlacementDirection(void) const
314 { return resource
.col_direction
; }
316 void changeWorkspaceCount(unsigned int new_count
);
318 inline void setRootColormapInstalled(bool r
) { root_colormap_installed
= r
; }
319 void saveSloppyFocus(bool s
);
320 void saveAutoRaise(bool a
);
321 void saveClickRaise(bool c
);
322 void saveWorkspaces(unsigned int w
);
323 void savePlacementPolicy(int p
);
324 void saveRowPlacementDirection(int d
);
325 void saveColPlacementDirection(int d
);
326 void saveSnapThreshold(int t
);
327 void saveSnapOffset(int o
);
328 void saveResistanceSize(int s
);
329 void saveImageDither(bool d
);
330 void saveShadowFonts(bool f
);
331 void saveAAFonts(bool f
);
332 void saveOpaqueMove(bool o
);
333 void saveFullMax(bool f
);
334 void saveFocusNew(bool f
);
335 void saveFocusLast(bool f
);
336 void saveHideToolbar(bool h
);
337 void saveWindowToEdgeSnap(int s
);
338 void saveWindowToWindowSnap(int s
);
339 void saveWindowCornerSnap(bool s
);
340 void saveResizeZones(unsigned int z
);
341 void savePlaceIgnoreShaded(bool i
);
342 void savePlaceIgnoreMaximized(bool i
);
343 void saveAllowScrollLock(bool a
);
344 void saveWorkspaceWarping(bool w
);
345 void saveRootScrollDirection(int d
);
346 void saveRootMenuButton(unsigned int b
);
347 void saveWorkspaceMenuButton(unsigned int b
);
348 inline void iconUpdate(void) { iconmenu
->update(); }
351 inline const char *getStrftimeFormat(void)
352 { return resource
.strftime_format
.c_str(); }
353 void saveStrftimeFormat(const std::string
& format
);
354 #else // !HAVE_STRFTIME
355 inline int getDateFormat(void) { return resource
.date_format
; }
356 inline void saveDateFormat(int f
);
357 inline bool isClock24Hour(void) { return resource
.clock24hour
; }
358 inline void saveClock24Hour(bool c
);
359 #endif // HAVE_STRFTIME
361 inline WindowStyle
*getWindowStyle(void) { return &resource
.wstyle
; }
362 inline MenuStyle
*getMenuStyle(void) { return &resource
.mstyle
; }
363 inline ToolbarStyle
*getToolbarStyle(void) { return &resource
.tstyle
; }
365 BlackboxWindow
*getIcon(unsigned int index
);
367 // allAvailableAreas should be used whenever possible instead of this function
368 // as then Xinerama will work correctly.
369 const Rect
& availableArea(void) const;
371 const RectList
& allAvailableAreas(void) const;
373 void updateAvailableArea(void);
374 void addStrut(Strut
*strut
);
375 void removeStrut(Strut
*strut
);
377 unsigned int addWorkspace(void);
378 unsigned int removeLastWorkspace(void);
379 void changeWorkspaceID(unsigned int id
);
380 void saveWorkspaceNames(void);
382 void addNetizen(Netizen
*n
);
383 void removeNetizen(Window w
);
385 void addSystrayWindow(Window window
);
386 void removeSystrayWindow(Window window
);
388 void addIcon(BlackboxWindow
*w
);
389 void removeIcon(BlackboxWindow
*w
);
391 void updateClientList(void);
392 void updateStackingList(void);
393 void manageWindow(Window w
);
394 void unmanageWindow(BlackboxWindow
*w
, bool remap
);
395 void raiseWindows(Window
*workspace_stack
, unsigned int num
);
396 void lowerWindows(Window
*workspace_stack
, unsigned int num
);
397 void reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
399 void propagateWindowName(const BlackboxWindow
*bw
);
400 void prevFocus(void);
401 void nextFocus(void);
402 void raiseFocus(void);
405 void reconfigure(void);
406 void toggleFocusModel(FocusModel model
);
407 void rereadMenu(void);
409 void showPosition(int x
, int y
);
410 void showGeometry(unsigned int gx
, unsigned int gy
);
411 void hideGeometry(void);
413 void showWorkspaceMenu(int x
, int y
);
414 void showRootMenu(int x
, int y
);
416 void buttonPressEvent(const XButtonEvent
*xbutton
);
417 void propertyNotifyEvent(const XPropertyEvent
*pe
);
419 void updateNetizenCurrentWorkspace(void);
420 void updateNetizenWorkspaceCount(void);
421 void updateNetizenWindowFocus(void);
422 void updateNetizenWindowAdd(Window w
, unsigned long p
);
423 void updateNetizenWindowDel(Window w
);
424 void updateNetizenConfigNotify(XEvent
*e
);
425 void updateNetizenWindowRaise(Window w
);
426 void updateNetizenWindowLower(Window w
);
430 #endif // __Screen_hh