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
49 #include "workspace.hh"
50 #include "blackbox.hh"
52 class Slit
; // forward reference
57 enum TextJustify
{ LeftJustify
= 1, RightJustify
, CenterJustify
};
64 #endif // BITMAPBUTTONS
67 BColor l_text_focus
, l_text_unfocus
, b_pic_focus
,
69 BTexture f_focus
, f_unfocus
, t_focus
, t_unfocus
, l_focus
, l_unfocus
,
70 h_focus
, h_unfocus
, b_focus
, b_unfocus
, b_pressed
, b_pressed_focus
,
71 b_pressed_unfocus
, g_focus
, g_unfocus
;
74 PixmapMask close_button
, max_button
, icon_button
, stick_button
;
75 #endif // BITMAPBUTTONS
80 void doJustify(const std::string
&text
, int &start_pos
,
81 unsigned int max_length
, unsigned int modifier
) const;
84 class BScreen
: public ScreenInfo
{
86 bool root_colormap_installed
, managed
, geom_visible
;
92 BImageControl
*image_control
;
93 Configuration
*config
;
96 BlackboxWindowList iconList
, windowList
;
98 typedef std::vector
<Window
> WindowList
;
99 WindowList specialWindowList
, desktopWindowList
, systrayWindowList
;
101 Workspace
*current_workspace
;
103 unsigned int geom_w
, geom_h
;
104 unsigned long event_mask
;
108 RectList xineramaUsableArea
;
111 typedef std::list
<Strut
*> StrutList
;
113 typedef std::vector
<Workspace
*> WorkspaceList
;
114 WorkspaceList workspacesList
;
116 struct screen_resource
{
119 bool sloppy_focus
, auto_raise
, auto_edge_balance
, ordered_dither
,
120 opaque_move
, full_max
, focus_new
, focus_last
, click_raise
,
121 allow_scroll_lock
, window_corner_snap
, aa_fonts
,
122 ignore_shaded
, ignore_maximized
, workspace_warping
, shadow_fonts
;
124 int snap_to_windows
, snap_to_edges
;
125 unsigned int snap_offset
;
129 unsigned int workspaces
;
130 int placement_policy
,
131 snap_threshold
, row_direction
, col_direction
, root_scroll
,
134 unsigned int handle_width
, bevel_width
, frame_width
, border_width
,
137 std::string strftime_format
;
140 std::string screenstr
;
142 BScreen(const BScreen
&);
143 BScreen
& operator=(const BScreen
&);
146 void readDatabaseMask(const std::string
&rname
,
147 PixmapMask
&pixmapMask
,
148 const Configuration
&style
);
149 #endif // BITMAPBUTTONS
151 BTexture
readDatabaseTexture(const std::string
&rname
,
152 const std::string
&default_color
,
153 const Configuration
&style
,
154 bool allowNoTexture
= false);
155 BColor
readDatabaseColor(const std::string
&rname
,
156 const std::string
&default_color
,
157 const Configuration
&style
);
158 BFont
*readDatabaseFont(const std::string
&rbasename
,
159 const Configuration
&style
);
161 void LoadStyle(void);
163 void updateWorkArea(void);
167 void updateNetizenWorkspaceCount();
168 void updateNetizenWindowFocus();
171 enum { WindowNoSnap
= 0, WindowSnap
, WindowResistance
};
172 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
173 UnderMousePlacement
, ClickMousePlacement
, LeftRight
, RightLeft
,
174 TopBottom
, BottomTop
, IgnoreShaded
, IgnoreMaximized
};
175 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
176 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
177 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
178 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
179 enum FocusModel
{ SloppyFocus
, ClickToFocus
};
180 enum RootScrollDirection
{ NoScroll
= 0, NormalScroll
, ReverseScroll
};
182 BScreen(Blackbox
*bb
, unsigned int scrn
);
185 inline bool isSloppyFocus(void) const { return resource
.sloppy_focus
; }
186 inline bool isRootColormapInstalled(void) const
187 { return root_colormap_installed
; }
188 inline bool doAutoRaise(void) const { return resource
.auto_raise
; }
189 inline bool doClickRaise(void) const { return resource
.click_raise
; }
190 inline bool isScreenManaged(void) const { return managed
; }
191 inline bool doShadowFonts(void) const { return resource
.shadow_fonts
; }
192 inline bool doAAFonts(void) const { return resource
.aa_fonts
; }
193 inline bool doImageDither(void) const { return image_control
->doDither(); }
194 inline bool doOrderedDither(void) const { return resource
.ordered_dither
; }
195 inline bool doOpaqueMove(void) const { return resource
.opaque_move
; }
196 inline bool doFullMax(void) const { return resource
.full_max
; }
197 inline bool doFocusNew(void) const { return resource
.focus_new
; }
198 inline bool doFocusLast(void) const { return resource
.focus_last
; }
199 inline int getWindowToWindowSnap(void) const
200 { return resource
.snap_to_windows
; }
201 inline int getWindowToEdgeSnap(void) const
202 { return resource
.snap_to_edges
; }
203 inline bool getWindowCornerSnap(void) const
204 { return resource
.window_corner_snap
; }
205 inline bool allowScrollLock(void) const { return resource
.allow_scroll_lock
; }
206 inline bool doWorkspaceWarping(void) const
207 { return resource
.workspace_warping
; }
208 inline int rootScrollDirection(void) const { return resource
.root_scroll
; }
210 inline const GC
&getOpGC(void) const { return opGC
; }
212 inline Blackbox
*getBlackbox(void) { return blackbox
; }
213 inline BColor
*getBorderColor(void) { return &resource
.border_color
; }
214 inline BImageControl
*getImageControl(void) { return image_control
; }
216 Workspace
*getWorkspace(unsigned int index
) const;
218 inline Workspace
*getCurrentWorkspace(void) { return current_workspace
; }
220 inline unsigned int getHandleWidth(void) const
221 { return resource
.handle_width
; }
222 inline unsigned int getBevelWidth(void) const
223 { return resource
.bevel_width
; }
224 inline unsigned int getFrameWidth(void) const
225 { return resource
.frame_width
; }
226 inline unsigned int getBorderWidth(void) const
227 { return resource
.border_width
; }
228 inline unsigned int getResizeZones(void) const
229 { return resource
.resize_zones
; }
230 inline bool getPlaceIgnoreShaded(void) const
231 { return resource
.ignore_shaded
; }
232 inline bool getPlaceIgnoreMaximized(void) const
233 { return resource
.ignore_maximized
; }
235 inline unsigned int getCurrentWorkspaceID(void) const
236 { return current_workspace
->getID(); }
237 inline unsigned int getWorkspaceCount(void) const
238 { return workspacesList
.size(); }
239 inline unsigned int getIconCount(void) const { return iconList
.size(); }
240 inline unsigned int getNumberOfWorkspaces(void) const
241 { return resource
.workspaces
; }
242 inline int getPlacementPolicy(void) const
243 { return resource
.placement_policy
; }
244 inline int getSnapOffset(void) const
245 { return resource
.snap_offset
; }
246 inline int getSnapThreshold(void) const
247 { return resource
.snap_threshold
; }
248 inline int getResistanceSize(void) const
249 { return resource
.resistance_size
; }
250 inline int getRowPlacementDirection(void) const
251 { return resource
.row_direction
; }
252 inline int getColPlacementDirection(void) const
253 { return resource
.col_direction
; }
255 void changeWorkspaceCount(unsigned int new_count
);
257 inline void setRootColormapInstalled(bool r
) { root_colormap_installed
= r
; }
258 void saveSloppyFocus(bool s
);
259 void saveAutoRaise(bool a
);
260 void saveClickRaise(bool c
);
261 void saveWorkspaces(unsigned int w
);
262 void savePlacementPolicy(int p
);
263 void saveRowPlacementDirection(int d
);
264 void saveColPlacementDirection(int d
);
265 void saveSnapThreshold(int t
);
266 void saveSnapOffset(int o
);
267 void saveResistanceSize(int s
);
268 void saveImageDither(bool d
);
269 void saveShadowFonts(bool f
);
270 void saveAAFonts(bool f
);
271 void saveOpaqueMove(bool o
);
272 void saveFullMax(bool f
);
273 void saveFocusNew(bool f
);
274 void saveFocusLast(bool f
);
275 void saveWindowToEdgeSnap(int s
);
276 void saveWindowToWindowSnap(int s
);
277 void saveWindowCornerSnap(bool s
);
278 void saveResizeZones(unsigned int z
);
279 void savePlaceIgnoreShaded(bool i
);
280 void savePlaceIgnoreMaximized(bool i
);
281 void saveAllowScrollLock(bool a
);
282 void saveWorkspaceWarping(bool w
);
283 void saveRootScrollDirection(int d
);
285 inline const char *getStrftimeFormat(void)
286 { return resource
.strftime_format
.c_str(); }
287 void saveStrftimeFormat(const std::string
& format
);
289 inline WindowStyle
*getWindowStyle(void) { return &resource
.wstyle
; }
291 BlackboxWindow
*getIcon(unsigned int index
);
293 // allAvailableAreas should be used whenever possible instead of this function
294 // as then Xinerama will work correctly.
295 const Rect
& availableArea(void) const;
297 const RectList
& allAvailableAreas(void) const;
299 void updateAvailableArea(void);
300 void addStrut(Strut
*strut
);
301 void removeStrut(Strut
*strut
);
303 unsigned int addWorkspace(void);
304 unsigned int removeLastWorkspace(void);
305 void changeWorkspaceID(unsigned int id
);
306 void saveWorkspaceNames(void);
308 void addSystrayWindow(Window window
);
309 void removeSystrayWindow(Window window
);
311 void addIcon(BlackboxWindow
*w
);
312 void removeIcon(BlackboxWindow
*w
);
314 void updateClientList(void);
315 void updateStackingList(void);
316 void manageWindow(Window w
);
317 void unmanageWindow(BlackboxWindow
*w
, bool remap
);
318 void raiseWindows(Window
*workspace_stack
, unsigned int num
);
319 void lowerWindows(Window
*workspace_stack
, unsigned int num
);
320 void reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
322 void propagateWindowName(const BlackboxWindow
*bw
);
323 void prevFocus(void) const;
324 void nextFocus(void) const;
325 void raiseFocus(void) const;
328 void reconfigure(void);
329 void toggleFocusModel(FocusModel model
);
331 void showPosition(int x
, int y
);
332 void showGeometry(unsigned int gx
, unsigned int gy
);
333 void hideGeometry(void);
335 void buttonPressEvent(const XButtonEvent
*xbutton
);
336 void propertyNotifyEvent(const XPropertyEvent
*pe
);
340 #endif // __Screen_hh