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
};
70 BColor l_text_focus
, l_text_unfocus
, b_pic_focus
,
72 BTexture f_focus
, f_unfocus
, t_focus
, t_unfocus
, l_focus
, l_unfocus
,
73 h_focus
, h_unfocus
, b_focus
, b_unfocus
, b_pressed
, g_focus
, g_unfocus
;
75 PixmapMask close_button
, max_button
, icon_button
, stick_button
;
81 void doJustify(const std::string
&text
, int &start_pos
,
82 unsigned int max_length
, unsigned int modifier
) const;
86 BColor l_text
, w_text
, c_text
, b_pic
;
87 BTexture toolbar
, label
, window
, button
, pressed
, clock
;
89 PixmapMask left_button
, right_button
; //these should probably be the same
95 void doJustify(const std::string
&text
, int &start_pos
,
96 unsigned int max_length
, unsigned int modifier
) const;
100 BColor t_text
, f_text
, h_text
, d_text
;
101 BTexture title
, frame
, hilite
;
103 PixmapMask bullet_image
, tick_image
;
105 BFont
*t_font
, *f_font
;
107 TextJustify t_justify
, f_justify
;
108 int bullet
, bullet_pos
;
111 class BScreen
: public ScreenInfo
{
113 bool root_colormap_installed
, managed
, geom_visible
;
119 BImageControl
*image_control
;
120 Configmenu
*configmenu
;
123 Configuration
*config
;
126 typedef std::list
<Rootmenu
*> RootmenuList
;
127 RootmenuList rootmenuList
;
129 typedef std::list
<Netizen
*> NetizenList
;
130 NetizenList netizenList
;
131 BlackboxWindowList iconList
, windowList
;
133 typedef std::vector
<Window
> WindowList
;
134 WindowList specialWindowList
, desktopWindowList
, systrayWindowList
;
138 Workspace
*current_workspace
;
139 Workspacemenu
*workspacemenu
;
141 unsigned int geom_w
, geom_h
;
142 unsigned long event_mask
;
146 RectList xineramaUsableArea
;
149 typedef std::list
<Strut
*> StrutList
;
151 typedef std::vector
<Workspace
*> WorkspaceList
;
152 WorkspaceList workspacesList
;
154 struct screen_resource
{
159 bool sloppy_focus
, auto_raise
, auto_edge_balance
, ordered_dither
,
160 opaque_move
, full_max
, focus_new
, focus_last
, click_raise
,
161 allow_scroll_lock
, hide_toolbar
, window_corner_snap
, aa_fonts
,
162 ignore_shaded
, ignore_maximized
, workspace_warping
, shadow_fonts
;
164 int snap_to_windows
, snap_to_edges
;
165 unsigned int snap_offset
;
169 unsigned int workspaces
;
170 int toolbar_placement
, toolbar_width_percent
, placement_policy
,
171 snap_threshold
, row_direction
, col_direction
, root_scroll
,
174 unsigned int handle_width
, bevel_width
, frame_width
, border_width
,
177 unsigned int root_menu_button
, workspace_menu_button
;
180 std::string strftime_format
;
181 #else // !HAVE_STRFTIME
184 #endif // HAVE_STRFTIME
187 std::string screenstr
;
189 BScreen(const BScreen
&);
190 BScreen
& operator=(const BScreen
&);
192 bool parseMenuFile(FILE *file
, Rootmenu
*menu
);
194 void readDatabaseMask(const string
&rname
,
195 PixmapMask
&pixmapMask
,
196 const Configuration
&style
);
197 BTexture
readDatabaseTexture(const std::string
&rname
,
198 const std::string
&default_color
,
199 const Configuration
&style
);
200 BColor
readDatabaseColor(const std::string
&rname
,
201 const std::string
&default_color
,
202 const Configuration
&style
);
203 BFont
*readDatabaseFont(const std::string
&rbasename
,
204 const Configuration
&style
);
207 void LoadStyle(void);
209 void updateWorkArea(void);
211 enum { WindowNoSnap
= 0, WindowSnap
, WindowResistance
};
212 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
213 UnderMousePlacement
, ClickMousePlacement
, LeftRight
, RightLeft
,
214 TopBottom
, BottomTop
, IgnoreShaded
, IgnoreMaximized
};
215 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
216 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
217 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
218 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
219 enum FocusModel
{ SloppyFocus
, ClickToFocus
};
220 enum RootScrollDirection
{ NoScroll
= 0, NormalScroll
, ReverseScroll
};
222 BScreen(Blackbox
*bb
, unsigned int scrn
);
225 inline bool isSloppyFocus(void) const { return resource
.sloppy_focus
; }
226 inline bool isRootColormapInstalled(void) const
227 { return root_colormap_installed
; }
228 inline bool doAutoRaise(void) const { return resource
.auto_raise
; }
229 inline bool doClickRaise(void) const { return resource
.click_raise
; }
230 inline bool isScreenManaged(void) const { return managed
; }
231 inline bool doShadowFonts(void) const { return resource
.shadow_fonts
; }
232 inline bool doAAFonts(void) const { return resource
.aa_fonts
; }
233 inline bool doImageDither(void) const { return image_control
->doDither(); }
234 inline bool doOrderedDither(void) const { return resource
.ordered_dither
; }
235 inline bool doOpaqueMove(void) const { return resource
.opaque_move
; }
236 inline bool doFullMax(void) const { return resource
.full_max
; }
237 inline bool doFocusNew(void) const { return resource
.focus_new
; }
238 inline bool doFocusLast(void) const { return resource
.focus_last
; }
239 inline bool doHideToolbar(void) const { return resource
.hide_toolbar
; }
240 inline int getWindowToWindowSnap(void) const
241 { return resource
.snap_to_windows
; }
242 inline int getWindowToEdgeSnap(void) const
243 { return resource
.snap_to_edges
; }
244 inline bool getWindowCornerSnap(void) const
245 { return resource
.window_corner_snap
; }
246 inline bool allowScrollLock(void) const { return resource
.allow_scroll_lock
; }
247 inline bool doWorkspaceWarping(void) const
248 { return resource
.workspace_warping
; }
249 inline int rootScrollDirection(void) const { return resource
.root_scroll
; }
250 inline unsigned int rootMenuButton(void) const
251 { return resource
.root_menu_button
; }
252 inline unsigned int workspaceMenuButton(void) const
253 { return resource
.workspace_menu_button
; }
255 inline const GC
&getOpGC(void) const { return opGC
; }
257 inline Blackbox
*getBlackbox(void) { return blackbox
; }
258 inline BColor
*getBorderColor(void) { return &resource
.border_color
; }
259 inline BImageControl
*getImageControl(void) { return image_control
; }
260 inline Rootmenu
*getRootmenu(void) { return rootmenu
; }
262 inline Slit
*getSlit(void) { return slit
; }
263 inline Toolbar
*getToolbar(void) { return toolbar
; }
265 Workspace
*getWorkspace(unsigned int index
);
267 inline Workspace
*getCurrentWorkspace(void) { return current_workspace
; }
269 inline Workspacemenu
*getWorkspacemenu(void) { return workspacemenu
; }
271 inline unsigned int getHandleWidth(void) const
272 { return resource
.handle_width
; }
273 inline unsigned int getBevelWidth(void) const
274 { return resource
.bevel_width
; }
275 inline unsigned int getFrameWidth(void) const
276 { return resource
.frame_width
; }
277 inline unsigned int getBorderWidth(void) const
278 { return resource
.border_width
; }
279 inline unsigned int getResizeZones(void) const
280 { return resource
.resize_zones
; }
281 inline bool getPlaceIgnoreShaded(void) const
282 { return resource
.ignore_shaded
; }
283 inline bool getPlaceIgnoreMaximized(void) const
284 { return resource
.ignore_maximized
; }
286 inline unsigned int getCurrentWorkspaceID(void) const
287 { return current_workspace
->getID(); }
288 inline unsigned int getWorkspaceCount(void) const
289 { return workspacesList
.size(); }
290 inline unsigned int getIconCount(void) const { return iconList
.size(); }
291 inline unsigned int getNumberOfWorkspaces(void) const
292 { return resource
.workspaces
; }
293 inline int getPlacementPolicy(void) const
294 { return resource
.placement_policy
; }
295 inline int getSnapOffset(void) const
296 { return resource
.snap_offset
; }
297 inline int getSnapThreshold(void) const
298 { return resource
.snap_threshold
; }
299 inline int getResistanceSize(void) const
300 { return resource
.resistance_size
; }
301 inline int getRowPlacementDirection(void) const
302 { return resource
.row_direction
; }
303 inline int getColPlacementDirection(void) const
304 { return resource
.col_direction
; }
306 void changeWorkspaceCount(unsigned int new_count
);
308 inline void setRootColormapInstalled(bool r
) { root_colormap_installed
= r
; }
309 void saveSloppyFocus(bool s
);
310 void saveAutoRaise(bool a
);
311 void saveClickRaise(bool c
);
312 void saveWorkspaces(unsigned int w
);
313 void savePlacementPolicy(int p
);
314 void saveRowPlacementDirection(int d
);
315 void saveColPlacementDirection(int d
);
316 void saveSnapThreshold(int t
);
317 void saveSnapOffset(int o
);
318 void saveResistanceSize(int s
);
319 void saveImageDither(bool d
);
320 void saveShadowFonts(bool f
);
321 void saveAAFonts(bool f
);
322 void saveOpaqueMove(bool o
);
323 void saveFullMax(bool f
);
324 void saveFocusNew(bool f
);
325 void saveFocusLast(bool f
);
326 void saveHideToolbar(bool h
);
327 void saveWindowToEdgeSnap(int s
);
328 void saveWindowToWindowSnap(int s
);
329 void saveWindowCornerSnap(bool s
);
330 void saveResizeZones(unsigned int z
);
331 void savePlaceIgnoreShaded(bool i
);
332 void savePlaceIgnoreMaximized(bool i
);
333 void saveAllowScrollLock(bool a
);
334 void saveWorkspaceWarping(bool w
);
335 void saveRootScrollDirection(int d
);
336 void saveRootMenuButton(unsigned int b
);
337 void saveWorkspaceMenuButton(unsigned int b
);
338 inline void iconUpdate(void) { iconmenu
->update(); }
341 inline const char *getStrftimeFormat(void)
342 { return resource
.strftime_format
.c_str(); }
343 void saveStrftimeFormat(const std::string
& format
);
344 #else // !HAVE_STRFTIME
345 inline int getDateFormat(void) { return resource
.date_format
; }
346 inline void saveDateFormat(int f
);
347 inline bool isClock24Hour(void) { return resource
.clock24hour
; }
348 inline void saveClock24Hour(bool c
);
349 #endif // HAVE_STRFTIME
351 inline WindowStyle
*getWindowStyle(void) { return &resource
.wstyle
; }
352 inline MenuStyle
*getMenuStyle(void) { return &resource
.mstyle
; }
353 inline ToolbarStyle
*getToolbarStyle(void) { return &resource
.tstyle
; }
355 BlackboxWindow
*getIcon(unsigned int index
);
357 // allAvailableAreas should be used whenever possible instead of this function
358 // as then Xinerama will work correctly.
359 const Rect
& availableArea(void) const;
361 const RectList
& allAvailableAreas(void) const;
363 void updateAvailableArea(void);
364 void addStrut(Strut
*strut
);
365 void removeStrut(Strut
*strut
);
367 unsigned int addWorkspace(void);
368 unsigned int removeLastWorkspace(void);
369 void changeWorkspaceID(unsigned int id
);
370 void saveWorkspaceNames(void);
372 void addNetizen(Netizen
*n
);
373 void removeNetizen(Window w
);
375 void addSystrayWindow(Window window
);
376 void removeSystrayWindow(Window window
);
378 void addIcon(BlackboxWindow
*w
);
379 void removeIcon(BlackboxWindow
*w
);
381 void updateClientList(void);
382 void updateStackingList(void);
383 void manageWindow(Window w
);
384 void unmanageWindow(BlackboxWindow
*w
, bool remap
);
385 void raiseWindows(Window
*workspace_stack
, unsigned int num
);
386 void lowerWindows(Window
*workspace_stack
, unsigned int num
);
387 void reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
389 void propagateWindowName(const BlackboxWindow
*bw
);
390 void prevFocus(void);
391 void nextFocus(void);
392 void raiseFocus(void);
395 void reconfigure(void);
396 void toggleFocusModel(FocusModel model
);
397 void rereadMenu(void);
399 void showPosition(int x
, int y
);
400 void showGeometry(unsigned int gx
, unsigned int gy
);
401 void hideGeometry(void);
403 void showWorkspaceMenu(int x
, int y
);
404 void showRootMenu(int x
, int y
);
406 void buttonPressEvent(const XButtonEvent
*xbutton
);
407 void propertyNotifyEvent(const XPropertyEvent
*pe
);
409 void updateNetizenCurrentWorkspace(void);
410 void updateNetizenWorkspaceCount(void);
411 void updateNetizenWindowFocus(void);
412 void updateNetizenWindowAdd(Window w
, unsigned long p
);
413 void updateNetizenWindowDel(Window w
);
414 void updateNetizenConfigNotify(XEvent
*e
);
415 void updateNetizenWindowRaise(Window w
);
416 void updateNetizenWindowLower(Window w
);
420 #endif // __Screen_hh