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"
56 // forward declaration
60 BColor f_focus
, f_unfocus
, l_text_focus
, l_text_unfocus
, b_pic_focus
,
62 BTexture t_focus
, t_unfocus
, l_focus
, l_unfocus
, h_focus
, h_unfocus
,
63 b_focus
, b_unfocus
, b_pressed
, g_focus
, g_unfocus
;
64 GC l_text_focus_gc
, l_text_unfocus_gc
, b_pic_focus_gc
, b_pic_unfocus_gc
;
67 XFontSetExtents
*fontset_extents
;
74 BColor l_text
, w_text
, c_text
, b_pic
;
75 BTexture toolbar
, label
, window
, button
, pressed
, clock
;
76 GC l_text_gc
, w_text_gc
, c_text_gc
, b_pic_gc
;
79 XFontSetExtents
*fontset_extents
;
86 BColor t_text
, f_text
, h_text
, d_text
;
87 BTexture title
, frame
, hilite
;
88 GC t_text_gc
, f_text_gc
, h_text_gc
, d_text_gc
, hilite_gc
;
90 XFontSet t_fontset
, f_fontset
;
91 XFontSetExtents
*t_fontset_extents
, *f_fontset_extents
;
92 XFontStruct
*t_font
, *f_font
;
94 int t_justify
, f_justify
, bullet
, bullet_pos
;
98 class BScreen
: public ScreenInfo
{
100 Bool root_colormap_installed
, managed
, geom_visible
;
107 BImageControl
*image_control
;
108 Configmenu
*configmenu
;
112 LinkedList
<Rootmenu
> *rootmenuList
;
113 LinkedList
<Netizen
> *netizenList
;
114 LinkedList
<OpenboxWindow
> *iconList
;
121 Workspace
*current_workspace
;
122 Workspacemenu
*workspacemenu
;
124 unsigned int geom_w
, geom_h
;
125 unsigned long event_mask
;
127 LinkedList
<char> *workspaceNames
;
128 LinkedList
<Workspace
> *workspacesList
;
135 Bool sloppy_focus
, auto_raise
,
136 auto_edge_balance
, image_dither
, ordered_dither
, opaque_move
, full_max
,
137 focus_new
, focus_last
;
140 Resource styleconfig
;
142 int workspaces
, toolbar_placement
, toolbar_width_percent
, placement_policy
,
143 edge_snap_threshold
, row_direction
, col_direction
;
145 unsigned int handle_width
, bevel_width
, frame_width
, border_width
;
146 unsigned int zones
; // number of zones to be used when alt-resizing a window
149 char *strftime_format
;
150 #else // !HAVE_STRFTIME
153 #endif // HAVE_STRFTIME
160 Bool
parseMenuFile(FILE *, Rootmenu
*);
162 void readDatabaseTexture(const char *, const char *, BTexture
*,
164 void readDatabaseColor(const char *, const char *, BColor
*, unsigned long);
166 void readDatabaseFontSet(const char *, const char *, XFontSet
*);
167 XFontSet
createFontSet(const char *);
168 void readDatabaseFont(const char *, const char *, XFontStruct
**);
175 BScreen(Openbox
&, int, Resource
&);
178 inline const Bool
&isSloppyFocus() const
179 { return resource
.sloppy_focus
; }
180 inline const Bool
&isRootColormapInstalled() const
181 { return root_colormap_installed
; }
182 inline const Bool
&doAutoRaise() const { return resource
.auto_raise
; }
183 inline const Bool
&isScreenManaged() const { return managed
; }
184 inline const Bool
&doImageDither() const
185 { return resource
.image_dither
; }
186 inline const Bool
&doOrderedDither() const
187 { return resource
.ordered_dither
; }
188 inline const Bool
&doOpaqueMove() const { return resource
.opaque_move
; }
189 inline const Bool
&doFullMax() const { return resource
.full_max
; }
190 inline const Bool
&doFocusNew() const { return resource
.focus_new
; }
191 inline const Bool
&doFocusLast() const { return resource
.focus_last
; }
193 inline const GC
&getOpGC() const { return opGC
; }
195 inline Openbox
&getOpenbox() { return openbox
; }
196 inline BColor
*getBorderColor() { return &resource
.border_color
; }
197 inline BImageControl
*getImageControl() { return image_control
; }
198 inline Rootmenu
*getRootmenu() { return rootmenu
; }
201 inline Slit
*getSlit() { return slit
; }
204 inline int getWindowZones() const
205 { return resource
.zones
; }
206 inline void saveWindowZones(int z
) { resource
.zones
= z
; }
208 inline Toolbar
*getToolbar() { return toolbar
; }
210 inline Workspace
*getWorkspace(int w
) { return workspacesList
->find(w
); }
211 inline Workspace
*getCurrentWorkspace() { return current_workspace
; }
213 inline Workspacemenu
*getWorkspacemenu() { return workspacemenu
; }
215 inline const unsigned int &getHandleWidth() const
216 { return resource
.handle_width
; }
217 inline const unsigned int &getBevelWidth() const
218 { return resource
.bevel_width
; }
219 inline const unsigned int &getFrameWidth() const
220 { return resource
.frame_width
; }
221 inline const unsigned int &getBorderWidth() const
222 { return resource
.border_width
; }
224 inline const int getCurrentWorkspaceID()
225 { return current_workspace
->getWorkspaceID(); }
226 inline const int getWorkspaceCount() { return workspacesList
->count(); }
227 inline const int getIconCount() { return iconList
->count(); }
228 inline const int &getNumberOfWorkspaces() const
229 { return resource
.workspaces
; }
230 inline const int &getPlacementPolicy() const
231 { return resource
.placement_policy
; }
232 inline const int &getEdgeSnapThreshold() const
233 { return resource
.edge_snap_threshold
; }
234 inline const int &getRowPlacementDirection() const
235 { return resource
.row_direction
; }
236 inline const int &getColPlacementDirection() const
237 { return resource
.col_direction
; }
239 inline void saveRootCommand(const char *cmd
) {
240 if (resource
.root_command
!= NULL
)
241 delete [] resource
.root_command
;
243 resource
.root_command
= bstrdup(cmd
);
245 resource
.root_command
= NULL
;
247 inline const char *getRootCommand() const
248 { return resource
.root_command
; }
250 inline void setRootColormapInstalled(Bool r
) { root_colormap_installed
= r
; }
251 inline void saveSloppyFocus(Bool s
) { resource
.sloppy_focus
= s
; }
252 inline void saveAutoRaise(Bool a
) { resource
.auto_raise
= a
; }
253 inline void saveWorkspaces(int w
) { resource
.workspaces
= w
; }
254 inline void savePlacementPolicy(int p
) { resource
.placement_policy
= p
; }
255 inline void saveRowPlacementDirection(int d
) { resource
.row_direction
= d
; }
256 inline void saveColPlacementDirection(int d
) { resource
.col_direction
= d
; }
257 inline void saveEdgeSnapThreshold(int t
)
258 { resource
.edge_snap_threshold
= t
; }
259 inline void saveImageDither(Bool d
) { resource
.image_dither
= d
; }
260 inline void saveOpaqueMove(Bool o
) { resource
.opaque_move
= o
; }
261 inline void saveFullMax(Bool f
) { resource
.full_max
= f
; }
262 inline void saveFocusNew(Bool f
) { resource
.focus_new
= f
; }
263 inline void saveFocusLast(Bool f
) { resource
.focus_last
= f
; }
264 inline void iconUpdate() { iconmenu
->update(); }
266 inline char *getStrftimeFormat() { return resource
.strftime_format
; }
267 void saveStrftimeFormat(const char *);
268 #else // !HAVE_STRFTIME
269 inline int getDateFormat() { return resource
.date_format
; }
270 inline void saveDateFormat(int f
) { resource
.date_format
= f
; }
271 inline Bool
isClock24Hour() { return resource
.clock24hour
; }
272 inline void saveClock24Hour(Bool c
) { resource
.clock24hour
= 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 addNetizen(Netizen
*);
290 void removeNetizen(Window
);
291 void addIcon(OpenboxWindow
*);
292 void removeIcon(OpenboxWindow
*);
293 char* getNameOfWorkspace(int);
294 void changeWorkspaceID(int);
295 void raiseWindows(Window
*, int);
296 void reassociateWindow(OpenboxWindow
*, int, Bool
);
304 void showPosition(int, int);
305 void showGeometry(unsigned int, unsigned int);
307 void updateNetizenCurrentWorkspace();
308 void updateNetizenWorkspaceCount();
309 void updateNetizenWindowFocus();
310 void updateNetizenWindowAdd(Window
, unsigned long);
311 void updateNetizenWindowDel(Window
);
312 void updateNetizenConfigNotify(XEvent
*);
313 void updateNetizenWindowRaise(Window
);
314 void updateNetizenWindowLower(Window
);
316 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
317 BestFitPlacement
, LeftRight
, RightLeft
, TopBottom
, BottomTop
};
318 enum { LeftJustify
= 1, RightJustify
, CenterJustify
};
319 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
320 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
321 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
322 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
326 #endif // __Screen_hh