1 // Screen.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
27 #include <X11/Xresource.h>
29 #ifdef TIME_WITH_SYS_TIME
30 # include <sys/time.h>
32 #else // !TIME_WITH_SYS_TIME
33 # ifdef HAVE_SYS_TIME_H
34 # include <sys/time.h>
35 # else // !HAVE_SYS_TIME_H
37 # endif // HAVE_SYS_TIME_H
38 #endif // TIME_WITH_SYS_TIME
40 #include "BaseDisplay.h"
41 #include "Configmenu.h"
46 #include "Workspace.h"
47 #include "Workspacemenu.h"
59 // forward declaration
63 BColor f_focus
, f_unfocus
, l_text_focus
, l_text_unfocus
, b_pic_focus
,
65 BTexture t_focus
, t_unfocus
, l_focus
, l_unfocus
, h_focus
, h_unfocus
,
66 b_focus
, b_unfocus
, b_pressed
, g_focus
, g_unfocus
;
67 GC l_text_focus_gc
, l_text_unfocus_gc
, b_pic_focus_gc
, b_pic_unfocus_gc
;
70 XFontSetExtents
*fontset_extents
;
77 BColor l_text
, w_text
, c_text
, b_pic
;
78 BTexture toolbar
, label
, window
, button
, pressed
, clock
;
79 GC l_text_gc
, w_text_gc
, c_text_gc
, b_pic_gc
;
82 XFontSetExtents
*fontset_extents
;
89 BColor t_text
, f_text
, h_text
, d_text
;
90 BTexture title
, frame
, hilite
;
91 GC t_text_gc
, f_text_gc
, h_text_gc
, d_text_gc
, hilite_gc
;
93 XFontSet t_fontset
, f_fontset
;
94 XFontSetExtents
*t_fontset_extents
, *f_fontset_extents
;
95 XFontStruct
*t_font
, *f_font
;
97 int t_justify
, f_justify
, bullet
, bullet_pos
;
101 class BScreen
: public ScreenInfo
{
103 Bool root_colormap_installed
, managed
, geom_visible
;
110 BImageControl
*image_control
;
111 Configmenu
*configmenu
;
115 typedef std::list
<Rootmenu
*> menuList
;
116 menuList rootmenuList
;
117 typedef std::list
<Netizen
*> netList
;
119 typedef std::list
<OpenboxWindow
*> winList
;
120 winList iconList
; // winList is declared in Workspace.h
127 Workspace
*current_workspace
;
128 Workspacemenu
*workspacemenu
;
130 unsigned int geom_w
, geom_h
;
131 unsigned long event_mask
;
133 typedef std::vector
<std::string
> wkspNameList
;
134 wkspNameList workspaceNames
;
135 typedef std::vector
<Workspace
*> wkspList
;
136 wkspList workspacesList
;
143 bool sloppy_focus
, auto_raise
, auto_edge_balance
, focus_last
,
144 ordered_dither
, opaque_move
, hide_toolbar
, full_max
, focus_new
;
146 Resource styleconfig
;
148 int workspaces
, placement_policy
, edge_snap_threshold
, row_direction
,
151 unsigned int handle_width
, bevel_width
, frame_width
, border_width
;
152 int zones
; // number of zones to be used when alt-resizing a window
155 char *strftime_format
;
156 #else // !HAVE_STRFTIME
159 #endif // HAVE_STRFTIME
166 Bool
parseMenuFile(FILE *, Rootmenu
*);
168 void readDatabaseTexture(const char *, const char *, BTexture
*,
170 void readDatabaseColor(const char *, const char *, BColor
*, unsigned long);
172 void readDatabaseFontSet(const char *, const char *, XFontSet
*);
173 XFontSet
createFontSet(const char *);
174 void readDatabaseFont(const char *, const char *, XFontStruct
**);
181 BScreen(Openbox
&, int, Resource
&);
184 inline const Bool
&isScreenManaged() const { return managed
; }
185 inline const GC
&getOpGC() const { return opGC
; }
187 inline Openbox
&getOpenbox() { return openbox
; }
188 inline BColor
*getBorderColor() { return &resource
.border_color
; }
189 inline BImageControl
*getImageControl() { return image_control
; }
190 inline Rootmenu
*getRootmenu() { return rootmenu
; }
193 inline Slit
*getSlit() { return slit
; }
196 inline Toolbar
*getToolbar() { return toolbar
; }
198 Rect
availableArea() const;
200 inline Workspace
*getWorkspace(unsigned int w
) {
201 ASSERT(w
< workspacesList
.size());
202 return workspacesList
[w
];
204 inline Workspace
*getCurrentWorkspace() { return current_workspace
; }
206 inline Workspacemenu
*getWorkspacemenu() { return workspacemenu
; }
208 inline void iconUpdate() { iconmenu
->update(); }
210 inline const unsigned int &getHandleWidth() const
211 { return resource
.handle_width
; }
212 inline const unsigned int &getBevelWidth() const
213 { return resource
.bevel_width
; }
214 inline const unsigned int &getFrameWidth() const
215 { return resource
.frame_width
; }
216 inline const unsigned int &getBorderWidth() const
217 { return resource
.border_width
; }
219 inline const int getCurrentWorkspaceID()
220 { return current_workspace
->getWorkspaceID(); }
221 inline const int getWorkspaceCount() { return workspacesList
.size(); }
222 inline const int getIconCount() { return iconList
.size(); }
224 inline const Bool
&isRootColormapInstalled() const
225 { return root_colormap_installed
; }
226 inline void setRootColormapInstalled(Bool r
) { root_colormap_installed
= r
; }
228 inline bool sloppyFocus() const { return resource
.sloppy_focus
; }
229 void setSloppyFocus(bool s
);
231 inline bool autoRaise() const { return resource
.auto_raise
; }
232 void setAutoRaise(bool a
);
234 inline bool imageDither() const { return image_control
->doDither(); }
235 void setImageDither(bool d
, bool reconfig
= true);
237 inline bool orderedDither() const { return resource
.ordered_dither
; }
239 inline bool opaqueMove() const { return resource
.opaque_move
; }
240 void setOpaqueMove(bool o
);
242 inline bool fullMax() const { return resource
.full_max
; }
243 void setFullMax(bool f
);
245 inline bool focusNew() const { return resource
.focus_new
; }
246 void setFocusNew(bool f
);
248 inline bool focusLast() const { return resource
.focus_last
; }
249 void setFocusLast(bool f
);
251 inline int getWindowZones() const { return resource
.zones
; }
252 void setWindowZones(int z
);
254 inline int workspaceCount() const { return resource
.workspaces
; }
255 void setWorkspaceCount(int w
);
257 inline int placementPolicy() const { return resource
.placement_policy
; }
258 void setPlacementPolicy(int p
);
260 inline int edgeSnapThreshold() const { return resource
.edge_snap_threshold
; }
261 void setEdgeSnapThreshold(int t
);
263 inline int rowPlacementDirection() const { return resource
.row_direction
; }
264 void setRowPlacementDirection(int d
);
266 inline int colPlacementDirection() const { return resource
.col_direction
; }
267 void setColPlacementDirection(int d
);
269 inline char *rootCommand() const { return resource
.root_command
; }
270 inline void setRootCommand(const char *cmd
);
273 inline char *strftimeFormat() { return resource
.strftime_format
; }
274 void setStrftimeFormat(const char *);
275 #else // !HAVE_STRFTIME
276 inline int dateFormat() { return resource
.date_format
; }
277 void setDateFormat(int f
);
278 inline bool clock24Hour() { return resource
.clock24hour
; }
279 void setClock24Hour(Bool c
);
280 #endif // HAVE_STRFTIME
282 inline bool hideToolbar() const { return resource
.hide_toolbar
; }
283 void setHideToolbar(bool);
285 inline WindowStyle
*getWindowStyle() { return &resource
.wstyle
; }
286 inline MenuStyle
*getMenuStyle() { return &resource
.mstyle
; }
287 inline ToolbarStyle
*getToolbarStyle() { return &resource
.tstyle
; }
289 OpenboxWindow
*getIcon(int);
292 int removeLastWorkspace();
294 void removeWorkspaceNames();
295 void addWorkspaceName(const char *);
296 void saveWorkspaceNames();
297 void addNetizen(Netizen
*);
298 void removeNetizen(Window
);
299 void addIcon(OpenboxWindow
*);
300 void removeIcon(OpenboxWindow
*);
301 const char *getNameOfWorkspace(int);
302 void changeWorkspaceID(int);
303 void raiseWindows(Window
*, int);
304 void reassociateWindow(OpenboxWindow
*, int, Bool
);
313 void showPosition(int, int);
314 void showGeometry(unsigned int, unsigned int);
316 void updateNetizenCurrentWorkspace();
317 void updateNetizenWorkspaceCount();
318 void updateNetizenWindowFocus();
319 void updateNetizenWindowAdd(Window
, unsigned long);
320 void updateNetizenWindowDel(Window
);
321 void updateNetizenConfigNotify(XEvent
*);
322 void updateNetizenWindowRaise(Window
);
323 void updateNetizenWindowLower(Window
);
325 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
326 BestFitPlacement
, UnderMousePlacement
, ClickMousePlacement
,
327 LeftRight
, RightLeft
, TopBottom
, BottomTop
};
328 enum { LeftJustify
= 1, RightJustify
, CenterJustify
};
329 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
330 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
331 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
332 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
336 #endif // __Screen_hh