1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
8 #ifdef TIME_WITH_SYS_TIME
11 #else // !TIME_WITH_SYS_TIME
12 # ifdef HAVE_SYS_TIME_H
13 # include <sys/time.h>
14 # else // !HAVE_SYS_TIME_H
16 # endif // HAVE_SYS_TIME_H
17 #endif // TIME_WITH_SYS_TIME
23 #include "otk/color.hh"
24 #include "otk/font.hh"
25 #include "otk/texture.hh"
26 #include "otk/image.hh"
28 #include "workspace.hh"
29 #include "blackbox.hh"
36 enum TextJustify
{ LeftJustify
= 1, RightJustify
, CenterJustify
};
44 otk::BColor l_text_focus
, l_text_unfocus
, b_pic_focus
,
46 otk::BTexture f_focus
, f_unfocus
, t_focus
, t_unfocus
, l_focus
, l_unfocus
,
47 h_focus
, h_unfocus
, b_focus
, b_unfocus
, b_pressed
, b_pressed_focus
,
48 b_pressed_unfocus
, g_focus
, g_unfocus
;
50 PixmapMask close_button
, max_button
, icon_button
, stick_button
;
55 void doJustify(const std::string
&text
, int &start_pos
,
56 unsigned int max_length
, unsigned int modifier
) const;
59 class BScreen
: public otk::ScreenInfo
{
61 bool root_colormap_installed
, managed
, geom_visible
;
67 otk::BImageControl
*image_control
;
68 Configuration
*config
;
71 BlackboxWindowList iconList
, windowList
;
73 typedef std::vector
<Window
> WindowList
;
74 WindowList specialWindowList
, desktopWindowList
, systrayWindowList
;
76 Workspace
*current_workspace
;
78 unsigned int geom_w
, geom_h
;
79 unsigned long event_mask
;
83 RectList xineramaUsableArea
;
86 typedef std::list
<Strut
*> StrutList
;
88 typedef std::vector
<Workspace
*> WorkspaceList
;
89 WorkspaceList workspacesList
;
91 struct screen_resource
{
94 bool sloppy_focus
, auto_raise
, auto_edge_balance
, ordered_dither
,
95 opaque_move
, full_max
, focus_new
, focus_last
, click_raise
,
96 allow_scroll_lock
, window_corner_snap
, aa_fonts
,
97 ignore_shaded
, ignore_maximized
, workspace_warping
, shadow_fonts
;
99 int snap_to_windows
, snap_to_edges
;
100 unsigned int snap_offset
;
102 otk::BColor border_color
;
104 unsigned int workspaces
;
105 int placement_policy
,
106 snap_threshold
, row_direction
, col_direction
, root_scroll
,
109 unsigned int handle_width
, bevel_width
, frame_width
, border_width
,
112 std::string strftime_format
;
115 std::string screenstr
;
117 BScreen(const BScreen
&);
118 BScreen
& operator=(const BScreen
&);
120 void readDatabaseMask(const std::string
&rname
,
121 PixmapMask
&pixmapMask
,
122 const Configuration
&style
);
124 otk::BTexture
readDatabaseTexture(const std::string
&rname
,
125 const std::string
&default_color
,
126 const Configuration
&style
,
127 bool allowNoTexture
= false);
128 otk::BColor
readDatabaseColor(const std::string
&rname
,
129 const std::string
&default_color
,
130 const Configuration
&style
);
131 otk::BFont
*readDatabaseFont(const std::string
&rbasename
,
132 const Configuration
&style
);
134 void LoadStyle(void);
136 void updateWorkArea(void);
140 void updateNetizenWorkspaceCount();
141 void updateNetizenWindowFocus();
144 enum { WindowNoSnap
= 0, WindowSnap
, WindowResistance
};
145 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
146 UnderMousePlacement
, ClickMousePlacement
, LeftRight
, RightLeft
,
147 TopBottom
, BottomTop
, IgnoreShaded
, IgnoreMaximized
};
148 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
149 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
150 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
151 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
152 enum FocusModel
{ SloppyFocus
, ClickToFocus
};
153 enum RootScrollDirection
{ NoScroll
= 0, NormalScroll
, ReverseScroll
};
155 BScreen(Blackbox
*bb
, unsigned int scrn
);
158 inline bool isSloppyFocus(void) const { return resource
.sloppy_focus
; }
159 inline bool isRootColormapInstalled(void) const
160 { return root_colormap_installed
; }
161 inline bool doAutoRaise(void) const { return resource
.auto_raise
; }
162 inline bool doClickRaise(void) const { return resource
.click_raise
; }
163 inline bool isScreenManaged(void) const { return managed
; }
164 inline bool doShadowFonts(void) const { return resource
.shadow_fonts
; }
165 inline bool doAAFonts(void) const { return resource
.aa_fonts
; }
166 inline bool doImageDither(void) const { return image_control
->doDither(); }
167 inline bool doOrderedDither(void) const { return resource
.ordered_dither
; }
168 inline bool doOpaqueMove(void) const { return resource
.opaque_move
; }
169 inline bool doFullMax(void) const { return resource
.full_max
; }
170 inline bool doFocusNew(void) const { return resource
.focus_new
; }
171 inline bool doFocusLast(void) const { return resource
.focus_last
; }
172 inline int getWindowToWindowSnap(void) const
173 { return resource
.snap_to_windows
; }
174 inline int getWindowToEdgeSnap(void) const
175 { return resource
.snap_to_edges
; }
176 inline bool getWindowCornerSnap(void) const
177 { return resource
.window_corner_snap
; }
178 inline bool allowScrollLock(void) const { return resource
.allow_scroll_lock
; }
179 inline bool doWorkspaceWarping(void) const
180 { return resource
.workspace_warping
; }
181 inline int rootScrollDirection(void) const { return resource
.root_scroll
; }
183 inline const GC
&getOpGC(void) const { return opGC
; }
185 inline Blackbox
*getBlackbox(void) { return blackbox
; }
186 inline otk::BColor
*getBorderColor(void) { return &resource
.border_color
; }
187 inline otk::BImageControl
*getImageControl(void) { return image_control
; }
189 Workspace
*getWorkspace(unsigned int index
) const;
191 inline Workspace
*getCurrentWorkspace(void) { return current_workspace
; }
193 inline unsigned int getHandleWidth(void) const
194 { return resource
.handle_width
; }
195 inline unsigned int getBevelWidth(void) const
196 { return resource
.bevel_width
; }
197 inline unsigned int getFrameWidth(void) const
198 { return resource
.frame_width
; }
199 inline unsigned int getBorderWidth(void) const
200 { return resource
.border_width
; }
201 inline unsigned int getResizeZones(void) const
202 { return resource
.resize_zones
; }
203 inline bool getPlaceIgnoreShaded(void) const
204 { return resource
.ignore_shaded
; }
205 inline bool getPlaceIgnoreMaximized(void) const
206 { return resource
.ignore_maximized
; }
208 inline unsigned int getCurrentWorkspaceID(void) const
209 { return current_workspace
->getID(); }
210 inline unsigned int getWorkspaceCount(void) const
211 { return workspacesList
.size(); }
212 inline unsigned int getIconCount(void) const { return iconList
.size(); }
213 inline unsigned int getNumberOfWorkspaces(void) const
214 { return resource
.workspaces
; }
215 inline int getPlacementPolicy(void) const
216 { return resource
.placement_policy
; }
217 inline int getSnapOffset(void) const
218 { return resource
.snap_offset
; }
219 inline int getSnapThreshold(void) const
220 { return resource
.snap_threshold
; }
221 inline int getResistanceSize(void) const
222 { return resource
.resistance_size
; }
223 inline int getRowPlacementDirection(void) const
224 { return resource
.row_direction
; }
225 inline int getColPlacementDirection(void) const
226 { return resource
.col_direction
; }
228 void changeWorkspaceCount(unsigned int new_count
);
230 inline void setRootColormapInstalled(bool r
) { root_colormap_installed
= r
; }
231 void saveSloppyFocus(bool s
);
232 void saveAutoRaise(bool a
);
233 void saveClickRaise(bool c
);
234 void saveWorkspaces(unsigned int w
);
235 void savePlacementPolicy(int p
);
236 void saveRowPlacementDirection(int d
);
237 void saveColPlacementDirection(int d
);
238 void saveSnapThreshold(int t
);
239 void saveSnapOffset(int o
);
240 void saveResistanceSize(int s
);
241 void saveImageDither(bool d
);
242 void saveShadowFonts(bool f
);
243 void saveAAFonts(bool f
);
244 void saveOpaqueMove(bool o
);
245 void saveFullMax(bool f
);
246 void saveFocusNew(bool f
);
247 void saveFocusLast(bool f
);
248 void saveWindowToEdgeSnap(int s
);
249 void saveWindowToWindowSnap(int s
);
250 void saveWindowCornerSnap(bool s
);
251 void saveResizeZones(unsigned int z
);
252 void savePlaceIgnoreShaded(bool i
);
253 void savePlaceIgnoreMaximized(bool i
);
254 void saveAllowScrollLock(bool a
);
255 void saveWorkspaceWarping(bool w
);
256 void saveRootScrollDirection(int d
);
258 inline const char *getStrftimeFormat(void)
259 { return resource
.strftime_format
.c_str(); }
260 void saveStrftimeFormat(const std::string
& format
);
262 inline WindowStyle
*getWindowStyle(void) { return &resource
.wstyle
; }
264 BlackboxWindow
*getIcon(unsigned int index
);
266 // allAvailableAreas should be used whenever possible instead of this function
267 // as then Xinerama will work correctly.
268 const otk::Rect
& availableArea(void) const;
270 const RectList
& allAvailableAreas(void) const;
272 void updateAvailableArea(void);
273 void addStrut(Strut
*strut
);
274 void removeStrut(Strut
*strut
);
276 unsigned int addWorkspace(void);
277 unsigned int removeLastWorkspace(void);
278 void changeWorkspaceID(unsigned int id
);
279 void saveWorkspaceNames(void);
281 void addSystrayWindow(Window window
);
282 void removeSystrayWindow(Window window
);
284 void addIcon(BlackboxWindow
*w
);
285 void removeIcon(BlackboxWindow
*w
);
287 void updateClientList(void);
288 void updateStackingList(void);
289 void manageWindow(Window w
);
290 void unmanageWindow(BlackboxWindow
*w
, bool remap
);
291 void raiseWindows(Window
*workspace_stack
, unsigned int num
);
292 void lowerWindows(Window
*workspace_stack
, unsigned int num
);
293 void reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
295 void propagateWindowName(const BlackboxWindow
*bw
);
296 void prevFocus(void) const;
297 void nextFocus(void) const;
298 void raiseFocus(void) const;
301 void reconfigure(void);
302 void toggleFocusModel(FocusModel model
);
304 void showPosition(int x
, int y
);
305 void showGeometry(unsigned int gx
, unsigned int gy
);
306 void hideGeometry(void);
308 void buttonPressEvent(const XButtonEvent
*xbutton
);
309 void propertyNotifyEvent(const XPropertyEvent
*pe
);
314 #endif // __Screen_hh