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"
43 #include "LinkedList.h"
47 #include "Workspace.h"
48 #include "Workspacemenu.h"
57 typedef std::list
<Rootmenu
*> menuList
;
58 typedef std::list
<Netizen
*> netList
;
60 // forward declaration
64 BColor f_focus
, f_unfocus
, l_text_focus
, l_text_unfocus
, b_pic_focus
,
66 BTexture t_focus
, t_unfocus
, l_focus
, l_unfocus
, h_focus
, h_unfocus
,
67 b_focus
, b_unfocus
, b_pressed
, g_focus
, g_unfocus
;
68 GC l_text_focus_gc
, l_text_unfocus_gc
, b_pic_focus_gc
, b_pic_unfocus_gc
;
71 XFontSetExtents
*fontset_extents
;
78 BColor l_text
, w_text
, c_text
, b_pic
;
79 BTexture toolbar
, label
, window
, button
, pressed
, clock
;
80 GC l_text_gc
, w_text_gc
, c_text_gc
, b_pic_gc
;
83 XFontSetExtents
*fontset_extents
;
90 BColor t_text
, f_text
, h_text
, d_text
;
91 BTexture title
, frame
, hilite
;
92 GC t_text_gc
, f_text_gc
, h_text_gc
, d_text_gc
, hilite_gc
;
94 XFontSet t_fontset
, f_fontset
;
95 XFontSetExtents
*t_fontset_extents
, *f_fontset_extents
;
96 XFontStruct
*t_font
, *f_font
;
98 int t_justify
, f_justify
, bullet
, bullet_pos
;
102 class BScreen
: public ScreenInfo
{
104 Bool root_colormap_installed
, managed
, geom_visible
;
111 BImageControl
*image_control
;
112 Configmenu
*configmenu
;
116 menuList rootmenuList
;
118 LinkedList
<OpenboxWindow
> *iconList
;
125 Workspace
*current_workspace
;
126 Workspacemenu
*workspacemenu
;
128 unsigned int geom_w
, geom_h
;
129 unsigned long event_mask
;
131 LinkedList
<char> *workspaceNames
;
132 LinkedList
<Workspace
> *workspacesList
;
139 bool sloppy_focus
, auto_raise
, auto_edge_balance
, focus_last
,
140 ordered_dither
, opaque_move
, hide_toolbar
, full_max
, focus_new
;
142 Resource styleconfig
;
144 int workspaces
, placement_policy
, edge_snap_threshold
, row_direction
,
147 unsigned int handle_width
, bevel_width
, frame_width
, border_width
;
148 int zones
; // number of zones to be used when alt-resizing a window
151 char *strftime_format
;
152 #else // !HAVE_STRFTIME
155 #endif // HAVE_STRFTIME
162 Bool
parseMenuFile(FILE *, Rootmenu
*);
164 void readDatabaseTexture(const char *, const char *, BTexture
*,
166 void readDatabaseColor(const char *, const char *, BColor
*, unsigned long);
168 void readDatabaseFontSet(const char *, const char *, XFontSet
*);
169 XFontSet
createFontSet(const char *);
170 void readDatabaseFont(const char *, const char *, XFontStruct
**);
177 BScreen(Openbox
&, int, Resource
&);
180 inline const Bool
&isScreenManaged() const { return managed
; }
181 inline const GC
&getOpGC() const { return opGC
; }
183 inline Openbox
&getOpenbox() { return openbox
; }
184 inline BColor
*getBorderColor() { return &resource
.border_color
; }
185 inline BImageControl
*getImageControl() { return image_control
; }
186 inline Rootmenu
*getRootmenu() { return rootmenu
; }
189 inline Slit
*getSlit() { return slit
; }
192 inline Toolbar
*getToolbar() { return toolbar
; }
194 Rect
availableArea() const;
196 inline Workspace
*getWorkspace(int w
) { return workspacesList
->find(w
); }
197 inline Workspace
*getCurrentWorkspace() { return current_workspace
; }
199 inline Workspacemenu
*getWorkspacemenu() { return workspacemenu
; }
201 inline void iconUpdate() { iconmenu
->update(); }
203 inline const unsigned int &getHandleWidth() const
204 { return resource
.handle_width
; }
205 inline const unsigned int &getBevelWidth() const
206 { return resource
.bevel_width
; }
207 inline const unsigned int &getFrameWidth() const
208 { return resource
.frame_width
; }
209 inline const unsigned int &getBorderWidth() const
210 { return resource
.border_width
; }
212 inline const int getCurrentWorkspaceID()
213 { return current_workspace
->getWorkspaceID(); }
214 inline const int getWorkspaceCount() { return workspacesList
->count(); }
215 inline const int getIconCount() { return iconList
->count(); }
217 inline const Bool
&isRootColormapInstalled() const
218 { return root_colormap_installed
; }
219 inline void setRootColormapInstalled(Bool r
) { root_colormap_installed
= r
; }
221 inline bool sloppyFocus() const { return resource
.sloppy_focus
; }
222 void setSloppyFocus(bool s
);
224 inline bool autoRaise() const { return resource
.auto_raise
; }
225 void setAutoRaise(bool a
);
227 inline bool imageDither() const { return image_control
->doDither(); }
228 void setImageDither(bool d
, bool reconfig
= true);
230 inline bool orderedDither() const { return resource
.ordered_dither
; }
232 inline bool opaqueMove() const { return resource
.opaque_move
; }
233 void setOpaqueMove(bool o
);
235 inline bool fullMax() const { return resource
.full_max
; }
236 void setFullMax(bool f
);
238 inline bool focusNew() const { return resource
.focus_new
; }
239 void setFocusNew(bool f
);
241 inline bool focusLast() const { return resource
.focus_last
; }
242 void setFocusLast(bool f
);
244 inline int getWindowZones() const { return resource
.zones
; }
245 void setWindowZones(int z
);
247 inline int workspaceCount() const { return resource
.workspaces
; }
248 void setWorkspaceCount(int w
);
250 inline int placementPolicy() const { return resource
.placement_policy
; }
251 void setPlacementPolicy(int p
);
253 inline int edgeSnapThreshold() const { return resource
.edge_snap_threshold
; }
254 void setEdgeSnapThreshold(int t
);
256 inline int rowPlacementDirection() const { return resource
.row_direction
; }
257 void setRowPlacementDirection(int d
);
259 inline int colPlacementDirection() const { return resource
.col_direction
; }
260 void setColPlacementDirection(int d
);
262 inline char *rootCommand() const { return resource
.root_command
; }
263 inline void setRootCommand(const char *cmd
);
266 inline char *strftimeFormat() { return resource
.strftime_format
; }
267 void setStrftimeFormat(const char *);
268 #else // !HAVE_STRFTIME
269 inline int dateFormat() { return resource
.date_format
; }
270 void setDateFormat(int f
);
271 inline bool clock24Hour() { return resource
.clock24hour
; }
272 void setClock24Hour(Bool c
);
273 #endif // HAVE_STRFTIME
275 inline bool hideToolbar() const { return resource
.hide_toolbar
; }
276 void setHideToolbar(bool);
278 inline WindowStyle
*getWindowStyle() { return &resource
.wstyle
; }
279 inline MenuStyle
*getMenuStyle() { return &resource
.mstyle
; }
280 inline ToolbarStyle
*getToolbarStyle() { return &resource
.tstyle
; }
282 OpenboxWindow
*getIcon(int);
285 int removeLastWorkspace();
287 void removeWorkspaceNames();
288 void addWorkspaceName(const char *);
289 void saveWorkspaceNames();
290 void addNetizen(Netizen
*);
291 void removeNetizen(Window
);
292 void addIcon(OpenboxWindow
*);
293 void removeIcon(OpenboxWindow
*);
294 char* getNameOfWorkspace(int);
295 void changeWorkspaceID(int);
296 void raiseWindows(Window
*, int);
297 void reassociateWindow(OpenboxWindow
*, int, Bool
);
306 void showPosition(int, int);
307 void showGeometry(unsigned int, unsigned int);
309 void updateNetizenCurrentWorkspace();
310 void updateNetizenWorkspaceCount();
311 void updateNetizenWindowFocus();
312 void updateNetizenWindowAdd(Window
, unsigned long);
313 void updateNetizenWindowDel(Window
);
314 void updateNetizenConfigNotify(XEvent
*);
315 void updateNetizenWindowRaise(Window
);
316 void updateNetizenWindowLower(Window
);
318 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
319 BestFitPlacement
, UnderMousePlacement
, ClickMousePlacement
,
320 LeftRight
, RightLeft
, TopBottom
, BottomTop
};
321 enum { LeftJustify
= 1, RightJustify
, CenterJustify
};
322 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
323 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
324 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
325 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
329 #endif // __Screen_hh