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"
27 #include "otk/strut.hh"
28 #include "otk/property.hh"
29 #include "otk/configuration.hh"
30 #include "otk/style.hh"
32 #include "workspace.hh"
33 #include "blackbox.hh"
37 class BScreen
: public otk::ScreenInfo
{
39 bool root_colormap_installed
, managed
, geom_visible
;
45 otk::BImageControl
*image_control
;
46 otk::Configuration
*config
;
47 otk::OBProperty
*xatom
;
49 BlackboxWindowList iconList
, windowList
;
51 typedef std::vector
<Window
> WindowList
;
52 WindowList specialWindowList
, desktopWindowList
, systrayWindowList
;
54 Workspace
*current_workspace
;
56 unsigned int geom_w
, geom_h
;
57 unsigned long event_mask
;
61 RectList xineramaUsableArea
;
64 typedef std::list
<otk::Strut
*> StrutList
;
66 typedef std::vector
<Workspace
*> WorkspaceList
;
67 WorkspaceList workspacesList
;
69 struct screen_resource
{
72 bool sloppy_focus
, auto_raise
, auto_edge_balance
, ordered_dither
,
73 opaque_move
, full_max
, focus_new
, focus_last
, click_raise
,
74 allow_scroll_lock
, window_corner_snap
, aa_fonts
,
75 ignore_shaded
, ignore_maximized
, workspace_warping
, shadow_fonts
;
77 int snap_to_windows
, snap_to_edges
;
78 unsigned int snap_offset
;
80 unsigned int workspaces
;
82 snap_threshold
, row_direction
, col_direction
, root_scroll
,
85 unsigned int resize_zones
;
87 std::string strftime_format
;
90 std::string screenstr
;
92 BScreen(const BScreen
&);
93 BScreen
& operator=(const BScreen
&);
95 void updateWorkArea(void);
99 void updateNetizenWorkspaceCount();
100 void updateNetizenWindowFocus();
103 enum { WindowNoSnap
= 0, WindowSnap
, WindowResistance
};
104 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
105 UnderMousePlacement
, ClickMousePlacement
, LeftRight
, RightLeft
,
106 TopBottom
, BottomTop
, IgnoreShaded
, IgnoreMaximized
};
107 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
108 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
109 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
110 enum FocusModel
{ SloppyFocus
, ClickToFocus
};
111 enum RootScrollDirection
{ NoScroll
= 0, NormalScroll
, ReverseScroll
};
113 BScreen(Blackbox
*bb
, unsigned int scrn
);
116 void LoadStyle(void);
118 inline bool isSloppyFocus(void) const { return resource
.sloppy_focus
; }
119 inline bool isRootColormapInstalled(void) const
120 { return root_colormap_installed
; }
121 inline bool doAutoRaise(void) const { return resource
.auto_raise
; }
122 inline bool doClickRaise(void) const { return resource
.click_raise
; }
123 inline bool isScreenManaged(void) const { return managed
; }
124 inline bool doShadowFonts(void) const { return resource
.shadow_fonts
; }
125 inline bool doAAFonts(void) const { return resource
.aa_fonts
; }
126 inline bool doImageDither(void) const { return image_control
->doDither(); }
127 inline bool doOrderedDither(void) const { return resource
.ordered_dither
; }
128 inline bool doOpaqueMove(void) const { return resource
.opaque_move
; }
129 inline bool doFullMax(void) const { return resource
.full_max
; }
130 inline bool doFocusNew(void) const { return resource
.focus_new
; }
131 inline bool doFocusLast(void) const { return resource
.focus_last
; }
132 inline int getWindowToWindowSnap(void) const
133 { return resource
.snap_to_windows
; }
134 inline int getWindowToEdgeSnap(void) const
135 { return resource
.snap_to_edges
; }
136 inline bool getWindowCornerSnap(void) const
137 { return resource
.window_corner_snap
; }
138 inline bool allowScrollLock(void) const { return resource
.allow_scroll_lock
; }
139 inline bool doWorkspaceWarping(void) const
140 { return resource
.workspace_warping
; }
141 inline int rootScrollDirection(void) const { return resource
.root_scroll
; }
143 inline const GC
&getOpGC(void) const { return opGC
; }
145 inline Blackbox
*getBlackbox(void) { return blackbox
; }
146 inline otk::BColor
*getBorderColor(void) {
147 return &resource
.wstyle
.border_color
;
149 inline otk::BImageControl
*getImageControl(void) { return image_control
; }
151 Workspace
*getWorkspace(unsigned int index
) const;
153 inline Workspace
*getCurrentWorkspace(void) { return current_workspace
; }
155 inline unsigned int getResizeZones(void) const
156 { return resource
.resize_zones
; }
157 inline bool getPlaceIgnoreShaded(void) const
158 { return resource
.ignore_shaded
; }
159 inline bool getPlaceIgnoreMaximized(void) const
160 { return resource
.ignore_maximized
; }
162 inline unsigned int getCurrentWorkspaceID(void) const
163 { return current_workspace
->getID(); }
164 inline unsigned int getWorkspaceCount(void) const
165 { return workspacesList
.size(); }
166 inline unsigned int getIconCount(void) const { return iconList
.size(); }
167 inline unsigned int getNumberOfWorkspaces(void) const
168 { return resource
.workspaces
; }
169 inline int getPlacementPolicy(void) const
170 { return resource
.placement_policy
; }
171 inline int getSnapOffset(void) const
172 { return resource
.snap_offset
; }
173 inline int getSnapThreshold(void) const
174 { return resource
.snap_threshold
; }
175 inline int getResistanceSize(void) const
176 { return resource
.resistance_size
; }
177 inline int getRowPlacementDirection(void) const
178 { return resource
.row_direction
; }
179 inline int getColPlacementDirection(void) const
180 { return resource
.col_direction
; }
182 void changeWorkspaceCount(unsigned int new_count
);
184 inline void setRootColormapInstalled(bool r
) { root_colormap_installed
= r
; }
185 void saveSloppyFocus(bool s
);
186 void saveAutoRaise(bool a
);
187 void saveClickRaise(bool c
);
188 void saveWorkspaces(unsigned int w
);
189 void savePlacementPolicy(int p
);
190 void saveRowPlacementDirection(int d
);
191 void saveColPlacementDirection(int d
);
192 void saveSnapThreshold(int t
);
193 void saveSnapOffset(int o
);
194 void saveResistanceSize(int s
);
195 void saveImageDither(bool d
);
196 void saveShadowFonts(bool f
);
197 void saveAAFonts(bool f
);
198 void saveOpaqueMove(bool o
);
199 void saveFullMax(bool f
);
200 void saveFocusNew(bool f
);
201 void saveFocusLast(bool f
);
202 void saveWindowToEdgeSnap(int s
);
203 void saveWindowToWindowSnap(int s
);
204 void saveWindowCornerSnap(bool s
);
205 void saveResizeZones(unsigned int z
);
206 void savePlaceIgnoreShaded(bool i
);
207 void savePlaceIgnoreMaximized(bool i
);
208 void saveAllowScrollLock(bool a
);
209 void saveWorkspaceWarping(bool w
);
210 void saveRootScrollDirection(int d
);
212 inline const char *getStrftimeFormat(void)
213 { return resource
.strftime_format
.c_str(); }
214 void saveStrftimeFormat(const std::string
& format
);
216 inline otk::Style
*getWindowStyle(void) { return &resource
.wstyle
; }
218 BlackboxWindow
*getIcon(unsigned int index
);
220 // allAvailableAreas should be used whenever possible instead of this function
221 // as then Xinerama will work correctly.
222 const otk::Rect
& availableArea(void) const;
224 const RectList
& allAvailableAreas(void) const;
226 void updateAvailableArea(void);
227 void addStrut(otk::Strut
*strut
);
228 void removeStrut(otk::Strut
*strut
);
230 unsigned int addWorkspace(void);
231 unsigned int removeLastWorkspace(void);
232 void changeWorkspaceID(unsigned int id
);
233 void saveWorkspaceNames(void);
235 void addSystrayWindow(Window window
);
236 void removeSystrayWindow(Window window
);
238 void addIcon(BlackboxWindow
*w
);
239 void removeIcon(BlackboxWindow
*w
);
241 void updateClientList(void);
242 void updateStackingList(void);
243 void manageWindow(Window w
);
244 void unmanageWindow(BlackboxWindow
*w
, bool remap
);
245 void raiseWindows(Window
*workspace_stack
, unsigned int num
);
246 void lowerWindows(Window
*workspace_stack
, unsigned int num
);
247 void reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
249 void propagateWindowName(const BlackboxWindow
*bw
);
250 void prevFocus(void) const;
251 void nextFocus(void) const;
252 void raiseFocus(void) const;
255 void reconfigure(void);
256 void toggleFocusModel(FocusModel model
);
258 void showPosition(int x
, int y
);
259 void showGeometry(unsigned int gx
, unsigned int gy
);
260 void hideGeometry(void);
262 void buttonPressEvent(const XButtonEvent
*xbutton
);
263 void propertyNotifyEvent(const XPropertyEvent
*pe
);
268 #endif // __Screen_hh