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
, auto_edge_balance
, image_dither
, focus_last
,
136 ordered_dither
, opaque_move
, hide_toolbar
, full_max
, focus_new
;
138 Resource styleconfig
;
140 int workspaces
, placement_policy
, edge_snap_threshold
, row_direction
,
143 unsigned int handle_width
, bevel_width
, frame_width
, border_width
;
144 int zones
; // number of zones to be used when alt-resizing a window
147 char *strftime_format
;
148 #else // !HAVE_STRFTIME
151 #endif // HAVE_STRFTIME
158 Bool
parseMenuFile(FILE *, Rootmenu
*);
160 void readDatabaseTexture(const char *, const char *, BTexture
*,
162 void readDatabaseColor(const char *, const char *, BColor
*, unsigned long);
164 void readDatabaseFontSet(const char *, const char *, XFontSet
*);
165 XFontSet
createFontSet(const char *);
166 void readDatabaseFont(const char *, const char *, XFontStruct
**);
173 BScreen(Openbox
&, int, Resource
&);
176 inline const Bool
&isScreenManaged() const { return managed
; }
177 inline const GC
&getOpGC() const { return opGC
; }
179 inline Openbox
&getOpenbox() { return openbox
; }
180 inline BColor
*getBorderColor() { return &resource
.border_color
; }
181 inline BImageControl
*getImageControl() { return image_control
; }
182 inline Rootmenu
*getRootmenu() { return rootmenu
; }
185 inline Slit
*getSlit() { return slit
; }
188 inline Toolbar
*getToolbar() { return toolbar
; }
190 Rect
availableArea() const;
192 inline Workspace
*getWorkspace(int w
) { return workspacesList
->find(w
); }
193 inline Workspace
*getCurrentWorkspace() { return current_workspace
; }
195 inline Workspacemenu
*getWorkspacemenu() { return workspacemenu
; }
197 inline void iconUpdate() { iconmenu
->update(); }
199 inline const unsigned int &getHandleWidth() const
200 { return resource
.handle_width
; }
201 inline const unsigned int &getBevelWidth() const
202 { return resource
.bevel_width
; }
203 inline const unsigned int &getFrameWidth() const
204 { return resource
.frame_width
; }
205 inline const unsigned int &getBorderWidth() const
206 { return resource
.border_width
; }
208 inline const int getCurrentWorkspaceID()
209 { return current_workspace
->getWorkspaceID(); }
210 inline const int getWorkspaceCount() { return workspacesList
->count(); }
211 inline const int getIconCount() { return iconList
->count(); }
213 inline const Bool
&isRootColormapInstalled() const
214 { return root_colormap_installed
; }
215 inline void setRootColormapInstalled(Bool r
) { root_colormap_installed
= r
; }
217 inline bool sloppyFocus() const { return resource
.sloppy_focus
; }
218 void setSloppyFocus(bool s
);
220 inline bool autoRaise() const { return resource
.auto_raise
; }
221 void setAutoRaise(bool a
);
223 inline bool imageDither() const { return resource
.image_dither
; }
224 void setImageDither(bool d
, bool reconfig
= true);
226 inline bool orderedDither() const { return resource
.ordered_dither
; }
228 inline bool opaqueMove() const { return resource
.opaque_move
; }
229 void setOpaqueMove(bool o
);
231 inline bool fullMax() const { return resource
.full_max
; }
232 void setFullMax(bool f
);
234 inline bool focusNew() const { return resource
.focus_new
; }
235 void setFocusNew(bool f
);
237 inline bool focusLast() const { return resource
.focus_last
; }
238 void setFocusLast(bool f
);
240 inline int getWindowZones() const { return resource
.zones
; }
241 void setWindowZones(int z
);
243 inline int workspaceCount() const { return resource
.workspaces
; }
244 void setWorkspaceCount(int w
);
246 inline int placementPolicy() const { return resource
.placement_policy
; }
247 void setPlacementPolicy(int p
);
249 inline int edgeSnapThreshold() const { return resource
.edge_snap_threshold
; }
250 void setEdgeSnapThreshold(int t
);
252 inline int rowPlacementDirection() const { return resource
.row_direction
; }
253 void setRowPlacementDirection(int d
);
255 inline int colPlacementDirection() const { return resource
.col_direction
; }
256 void setColPlacementDirection(int d
);
258 inline char *rootCommand() const { return resource
.root_command
; }
259 inline void setRootCommand(const char *cmd
);
262 inline char *strftimeFormat() { return resource
.strftime_format
; }
263 void setStrftimeFormat(const char *);
264 #else // !HAVE_STRFTIME
265 inline int dateFormat() { return resource
.date_format
; }
266 void setDateFormat(int f
);
267 inline bool clock24Hour() { return resource
.clock24hour
; }
268 void setClock24Hour(Bool c
);
269 #endif // HAVE_STRFTIME
271 inline bool hideToolbar() const { return resource
.hide_toolbar
; }
272 void setHideToolbar(bool);
274 inline WindowStyle
*getWindowStyle() { return &resource
.wstyle
; }
275 inline MenuStyle
*getMenuStyle() { return &resource
.mstyle
; }
276 inline ToolbarStyle
*getToolbarStyle() { return &resource
.tstyle
; }
278 OpenboxWindow
*getIcon(int);
281 int removeLastWorkspace();
283 void removeWorkspaceNames();
284 void addWorkspaceName(const char *);
285 void saveWorkspaceNames();
286 void addNetizen(Netizen
*);
287 void removeNetizen(Window
);
288 void addIcon(OpenboxWindow
*);
289 void removeIcon(OpenboxWindow
*);
290 char* getNameOfWorkspace(int);
291 void changeWorkspaceID(int);
292 void raiseWindows(Window
*, int);
293 void reassociateWindow(OpenboxWindow
*, int, Bool
);
302 void showPosition(int, int);
303 void showGeometry(unsigned int, unsigned int);
305 void updateNetizenCurrentWorkspace();
306 void updateNetizenWorkspaceCount();
307 void updateNetizenWindowFocus();
308 void updateNetizenWindowAdd(Window
, unsigned long);
309 void updateNetizenWindowDel(Window
);
310 void updateNetizenConfigNotify(XEvent
*);
311 void updateNetizenWindowRaise(Window
);
312 void updateNetizenWindowLower(Window
);
314 enum { RowSmartPlacement
= 1, ColSmartPlacement
, CascadePlacement
,
315 BestFitPlacement
, UnderMousePlacement
, ClickMousePlacement
,
316 LeftRight
, RightLeft
, TopBottom
, BottomTop
};
317 enum { LeftJustify
= 1, RightJustify
, CenterJustify
};
318 enum { RoundBullet
= 1, TriangleBullet
, SquareBullet
, NoBullet
};
319 enum { Restart
= 1, RestartOther
, Exit
, Shutdown
, Execute
, Reconfigure
,
320 WindowShade
, WindowIconify
, WindowMaximize
, WindowClose
, WindowRaise
,
321 WindowLower
, WindowStick
, WindowKill
, SetStyle
};
325 #endif // __Screen_hh