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