]> Dogcows Code - chaz/openbox/blob - src/Screen.h
Added a runtime option for hiding the toolbar totally. Will be cleaner
[chaz/openbox] / src / Screen.h
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)
4 //
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:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
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.
22
23 #ifndef __Screen_hh
24 #define __Screen_hh
25
26 #include <X11/Xlib.h>
27 #include <X11/Xresource.h>
28
29 #ifdef TIME_WITH_SYS_TIME
30 # include <sys/time.h>
31 # include <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
36 # include <time.h>
37 # endif // HAVE_SYS_TIME_H
38 #endif // TIME_WITH_SYS_TIME
39
40 #include "BaseDisplay.h"
41 #include "Configmenu.h"
42 #include "Iconmenu.h"
43 #include "LinkedList.h"
44 #include "Netizen.h"
45 #include "Rootmenu.h"
46 #include "Timer.h"
47 #include "Workspace.h"
48 #include "Workspacemenu.h"
49 #include "openbox.h"
50 #ifdef SLIT
51 # include "Slit.h"
52 #endif // SLIT
53 #include "Image.h"
54 #include "Resource.h"
55
56 // forward declaration
57 class BScreen;
58
59 struct WindowStyle {
60 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
61 b_pic_unfocus;
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;
65
66 XFontSet fontset;
67 XFontSetExtents *fontset_extents;
68 XFontStruct *font;
69
70 int justify;
71 };
72
73 struct ToolbarStyle {
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;
77
78 XFontSet fontset;
79 XFontSetExtents *fontset_extents;
80 XFontStruct *font;
81
82 int justify;
83 };
84
85 struct MenuStyle {
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;
89
90 XFontSet t_fontset, f_fontset;
91 XFontSetExtents *t_fontset_extents, *f_fontset_extents;
92 XFontStruct *t_font, *f_font;
93
94 int t_justify, f_justify, bullet, bullet_pos;
95 };
96
97
98 class BScreen : public ScreenInfo {
99 private:
100 Bool root_colormap_installed, managed, geom_visible;
101 GC opGC;
102 Pixmap geom_pixmap;
103 Window geom_window;
104
105 Openbox &openbox;
106 BImageControl *image_control;
107 Configmenu *configmenu;
108 Iconmenu *iconmenu;
109 Rootmenu *rootmenu;
110
111 LinkedList<Rootmenu> *rootmenuList;
112 LinkedList<Netizen> *netizenList;
113 LinkedList<OpenboxWindow> *iconList;
114
115 #ifdef SLIT
116 Slit *slit;
117 #endif // SLIT
118
119 Toolbar *toolbar;
120 Workspace *current_workspace;
121 Workspacemenu *workspacemenu;
122
123 unsigned int geom_w, geom_h;
124 unsigned long event_mask;
125
126 LinkedList<char> *workspaceNames;
127 LinkedList<Workspace> *workspacesList;
128
129 struct resource {
130 WindowStyle wstyle;
131 ToolbarStyle tstyle;
132 MenuStyle mstyle;
133
134 Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
135 auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
136 focus_new, focus_last, toolbar_total_hide;
137 BColor border_color;
138 obResource styleconfig;
139
140 int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
141 edge_snap_threshold, row_direction, col_direction;
142
143 #ifdef SLIT
144 Bool slit_on_top, slit_auto_hide;
145 int slit_placement, slit_direction;
146 #endif // SLIT
147
148 unsigned int handle_width, bevel_width, frame_width, border_width;
149 unsigned int zones; // number of zones to be used when alt-resizing a window
150
151 #ifdef HAVE_STRFTIME
152 char *strftime_format;
153 #else // !HAVE_STRFTIME
154 Bool clock24hour;
155 int date_format;
156 #endif // HAVE_STRFTIME
157
158 char *root_command;
159 } resource;
160
161
162 protected:
163 Bool parseMenuFile(FILE *, Rootmenu *);
164
165 void readDatabaseTexture(const char *, const char *, BTexture *,
166 unsigned long);
167 void readDatabaseColor(const char *, const char *, BColor *, unsigned long);
168
169 void readDatabaseFontSet(const char *, const char *, XFontSet *);
170 XFontSet createFontSet(const char *);
171 void readDatabaseFont(const char *, const char *, XFontStruct **);
172
173 void InitMenu(void);
174 void LoadStyle(void);
175
176
177 public:
178 BScreen(Openbox &, int);
179 ~BScreen(void);
180
181 inline const Bool &isToolbarOnTop(void) const
182 { return resource.toolbar_on_top; }
183 inline const Bool &doToolbarAutoHide(void) const
184 { return resource.toolbar_auto_hide; }
185 inline const Bool &doToolbarHide(void) const
186 {return resource.toolbar_total_hide;}
187 inline const Bool &isSloppyFocus(void) const
188 { return resource.sloppy_focus; }
189 inline const Bool &isRootColormapInstalled(void) const
190 { return root_colormap_installed; }
191 inline const Bool &doAutoRaise(void) const { return resource.auto_raise; }
192 inline const Bool &isScreenManaged(void) const { return managed; }
193 inline const Bool &doImageDither(void) const
194 { return resource.image_dither; }
195 inline const Bool &doOrderedDither(void) const
196 { return resource.ordered_dither; }
197 inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; }
198 inline const Bool &doFullMax(void) const { return resource.full_max; }
199 inline const Bool &doFocusNew(void) const { return resource.focus_new; }
200 inline const Bool &doFocusLast(void) const { return resource.focus_last; }
201
202 inline const GC &getOpGC() const { return opGC; }
203
204 inline Openbox &getOpenbox(void) { return openbox; }
205 inline BColor *getBorderColor(void) { return &resource.border_color; }
206 inline BImageControl *getImageControl(void) { return image_control; }
207 inline Rootmenu *getRootmenu(void) { return rootmenu; }
208
209 #ifdef SLIT
210 inline const Bool &isSlitOnTop(void) const { return resource.slit_on_top; }
211 inline const Bool &doSlitAutoHide(void) const
212 { return resource.slit_auto_hide; }
213 inline Slit *getSlit(void) { return slit; }
214 inline const int &getSlitPlacement(void) const
215 { return resource.slit_placement; }
216 inline const int &getSlitDirection(void) const
217 { return resource.slit_direction; }
218 inline void saveSlitPlacement(int p) { resource.slit_placement = p; }
219 inline void saveSlitDirection(int d) { resource.slit_direction = d; }
220 inline void saveSlitOnTop(Bool t) { resource.slit_on_top = t; }
221 inline void saveSlitAutoHide(Bool t) { resource.slit_auto_hide = t; }
222 #endif // SLIT
223
224 inline int getWindowZones(void) const
225 { return resource.zones; }
226 inline void saveWindowZones(int z) { resource.zones = z; }
227
228 inline Toolbar *getToolbar(void) { return toolbar; }
229
230 inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
231 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
232
233 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
234
235 inline const unsigned int &getHandleWidth(void) const
236 { return resource.handle_width; }
237 inline const unsigned int &getBevelWidth(void) const
238 { return resource.bevel_width; }
239 inline const unsigned int &getFrameWidth(void) const
240 { return resource.frame_width; }
241 inline const unsigned int &getBorderWidth(void) const
242 { return resource.border_width; }
243
244 inline const int getCurrentWorkspaceID()
245 { return current_workspace->getWorkspaceID(); }
246 inline const int getWorkspaceCount(void) { return workspacesList->count(); }
247 inline const int getIconCount(void) { return iconList->count(); }
248 inline const int &getNumberOfWorkspaces(void) const
249 { return resource.workspaces; }
250 inline const int &getToolbarPlacement(void) const
251 { return resource.toolbar_placement; }
252 inline const int &getToolbarWidthPercent(void) const
253 { return resource.toolbar_width_percent; }
254 inline const int &getPlacementPolicy(void) const
255 { return resource.placement_policy; }
256 inline const int &getEdgeSnapThreshold(void) const
257 { return resource.edge_snap_threshold; }
258 inline const int &getRowPlacementDirection(void) const
259 { return resource.row_direction; }
260 inline const int &getColPlacementDirection(void) const
261 { return resource.col_direction; }
262
263 inline void saveRootCommand(const char *cmd) {
264 if (resource.root_command != NULL)
265 delete [] resource.root_command;
266 if (cmd != NULL)
267 resource.root_command = bstrdup(cmd);
268 else
269 resource.root_command = NULL;
270 }
271 inline const char *getRootCommand(void) const
272 { return resource.root_command; }
273
274 inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
275 inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
276 inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
277 inline void saveWorkspaces(int w) { resource.workspaces = w; }
278 inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; }
279 inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; }
280 inline void saveToolbarWidthPercent(int w)
281 { resource.toolbar_width_percent = w; }
282 inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
283 inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
284 inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
285 inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
286 inline void saveEdgeSnapThreshold(int t)
287 { resource.edge_snap_threshold = t; }
288 inline void saveImageDither(Bool d) { resource.image_dither = d; }
289 inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }
290 inline void saveFullMax(Bool f) { resource.full_max = f; }
291 inline void saveFocusNew(Bool f) { resource.focus_new = f; }
292 inline void saveFocusLast(Bool f) { resource.focus_last = f; }
293 inline void iconUpdate(void) { iconmenu->update(); }
294 #ifdef HAVE_STRFTIME
295 inline char *getStrftimeFormat(void) { return resource.strftime_format; }
296 void saveStrftimeFormat(const char *);
297 #else // !HAVE_STRFTIME
298 inline int getDateFormat(void) { return resource.date_format; }
299 inline void saveDateFormat(int f) { resource.date_format = f; }
300 inline Bool isClock24Hour(void) { return resource.clock24hour; }
301 inline void saveClock24Hour(Bool c) { resource.clock24hour = c; }
302 #endif // HAVE_STRFTIME
303
304 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
305 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
306 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
307
308 OpenboxWindow *getIcon(int);
309
310 int addWorkspace(void);
311 int removeLastWorkspace(void);
312
313 void removeWorkspaceNames(void);
314 void addWorkspaceName(const char *);
315 void addNetizen(Netizen *);
316 void removeNetizen(Window);
317 void addIcon(OpenboxWindow *);
318 void removeIcon(OpenboxWindow *);
319 char* getNameOfWorkspace(int);
320 void changeWorkspaceID(int);
321 void raiseWindows(Window *, int);
322 void reassociateWindow(OpenboxWindow *, int, Bool);
323 void prevFocus(void);
324 void nextFocus(void);
325 void raiseFocus(void);
326 void reconfigure(void);
327 void rereadMenu(void);
328 void shutdown(void);
329 void showPosition(int, int);
330 void showGeometry(unsigned int, unsigned int);
331 void hideGeometry(void);
332 void saveToolbarHide( Bool b);
333 void updateNetizenCurrentWorkspace(void);
334 void updateNetizenWorkspaceCount(void);
335 void updateNetizenWindowFocus(void);
336 void updateNetizenWindowAdd(Window, unsigned long);
337 void updateNetizenWindowDel(Window);
338 void updateNetizenConfigNotify(XEvent *);
339 void updateNetizenWindowRaise(Window);
340 void updateNetizenWindowLower(Window);
341
342 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
343 BestFitPlacement, LeftRight, RightLeft, TopBottom, BottomTop };
344 enum { LeftJustify = 1, RightJustify, CenterJustify };
345 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
346 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
347 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
348 WindowLower, WindowStick, WindowKill, SetStyle };
349 };
350
351
352 #endif // __Screen_hh
This page took 0.059493 seconds and 5 git commands to generate.