]> Dogcows Code - chaz/openbox/blob - src/Screen.h
8d41352962d90de46970aabf40e6999f65bbc08c
[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 Resource &config;
107 BImageControl *image_control;
108 Configmenu *configmenu;
109 Iconmenu *iconmenu;
110 Rootmenu *rootmenu;
111
112 LinkedList<Rootmenu> *rootmenuList;
113 LinkedList<Netizen> *netizenList;
114 LinkedList<OpenboxWindow> *iconList;
115
116 #ifdef SLIT
117 Slit *slit;
118 #endif // SLIT
119
120 Toolbar *toolbar;
121 Workspace *current_workspace;
122 Workspacemenu *workspacemenu;
123
124 unsigned int geom_w, geom_h;
125 unsigned long event_mask;
126
127 LinkedList<char> *workspaceNames;
128 LinkedList<Workspace> *workspacesList;
129
130 struct resource {
131 WindowStyle wstyle;
132 ToolbarStyle tstyle;
133 MenuStyle mstyle;
134
135 Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
136 auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
137 focus_new, focus_last, toolbar_total_hide;
138 BColor border_color;
139 Resource styleconfig;
140
141 int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
142 edge_snap_threshold, row_direction, col_direction;
143
144 #ifdef SLIT
145 Bool slit_on_top, slit_auto_hide;
146 int slit_placement, slit_direction;
147 #endif // SLIT
148
149 unsigned int handle_width, bevel_width, frame_width, border_width;
150 unsigned int zones; // number of zones to be used when alt-resizing a window
151
152 #ifdef HAVE_STRFTIME
153 char *strftime_format;
154 #else // !HAVE_STRFTIME
155 Bool clock24hour;
156 int date_format;
157 #endif // HAVE_STRFTIME
158
159 char *root_command;
160 } resource;
161
162
163 protected:
164 Bool parseMenuFile(FILE *, Rootmenu *);
165
166 void readDatabaseTexture(const char *, const char *, BTexture *,
167 unsigned long);
168 void readDatabaseColor(const char *, const char *, BColor *, unsigned long);
169
170 void readDatabaseFontSet(const char *, const char *, XFontSet *);
171 XFontSet createFontSet(const char *);
172 void readDatabaseFont(const char *, const char *, XFontStruct **);
173
174 void InitMenu(void);
175 void LoadStyle(void);
176
177
178 public:
179 BScreen(Openbox &, int, Resource &);
180 ~BScreen(void);
181
182 inline const Bool &isToolbarOnTop(void) const
183 { return resource.toolbar_on_top; }
184 inline const Bool &doToolbarAutoHide(void) const
185 { return resource.toolbar_auto_hide; }
186 inline const Bool &doToolbarHide(void) const
187 {return resource.toolbar_total_hide;}
188 inline const Bool &isSloppyFocus(void) const
189 { return resource.sloppy_focus; }
190 inline const Bool &isRootColormapInstalled(void) const
191 { return root_colormap_installed; }
192 inline const Bool &doAutoRaise(void) const { return resource.auto_raise; }
193 inline const Bool &isScreenManaged(void) const { return managed; }
194 inline const Bool &doImageDither(void) const
195 { return resource.image_dither; }
196 inline const Bool &doOrderedDither(void) const
197 { return resource.ordered_dither; }
198 inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; }
199 inline const Bool &doFullMax(void) const { return resource.full_max; }
200 inline const Bool &doFocusNew(void) const { return resource.focus_new; }
201 inline const Bool &doFocusLast(void) const { return resource.focus_last; }
202
203 inline const GC &getOpGC() const { return opGC; }
204
205 inline Openbox &getOpenbox(void) { return openbox; }
206 inline BColor *getBorderColor(void) { return &resource.border_color; }
207 inline BImageControl *getImageControl(void) { return image_control; }
208 inline Rootmenu *getRootmenu(void) { return rootmenu; }
209
210 #ifdef SLIT
211 inline Slit *getSlit(void) { return slit; }
212 #endif // SLIT
213
214 inline int getWindowZones(void) const
215 { return resource.zones; }
216 inline void saveWindowZones(int z) { resource.zones = z; }
217
218 inline Toolbar *getToolbar(void) { return toolbar; }
219
220 inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
221 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
222
223 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
224
225 inline const unsigned int &getHandleWidth(void) const
226 { return resource.handle_width; }
227 inline const unsigned int &getBevelWidth(void) const
228 { return resource.bevel_width; }
229 inline const unsigned int &getFrameWidth(void) const
230 { return resource.frame_width; }
231 inline const unsigned int &getBorderWidth(void) const
232 { return resource.border_width; }
233
234 inline const int getCurrentWorkspaceID()
235 { return current_workspace->getWorkspaceID(); }
236 inline const int getWorkspaceCount(void) { return workspacesList->count(); }
237 inline const int getIconCount(void) { return iconList->count(); }
238 inline const int &getNumberOfWorkspaces(void) const
239 { return resource.workspaces; }
240 inline const int &getToolbarPlacement(void) const
241 { return resource.toolbar_placement; }
242 inline const int &getToolbarWidthPercent(void) const
243 { return resource.toolbar_width_percent; }
244 inline const int &getPlacementPolicy(void) const
245 { return resource.placement_policy; }
246 inline const int &getEdgeSnapThreshold(void) const
247 { return resource.edge_snap_threshold; }
248 inline const int &getRowPlacementDirection(void) const
249 { return resource.row_direction; }
250 inline const int &getColPlacementDirection(void) const
251 { return resource.col_direction; }
252
253 inline void saveRootCommand(const char *cmd) {
254 if (resource.root_command != NULL)
255 delete [] resource.root_command;
256 if (cmd != NULL)
257 resource.root_command = bstrdup(cmd);
258 else
259 resource.root_command = NULL;
260 }
261 inline const char *getRootCommand(void) const
262 { return resource.root_command; }
263
264 inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
265 inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
266 inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
267 inline void saveWorkspaces(int w) { resource.workspaces = w; }
268 inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; }
269 inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; }
270 inline void saveToolbarWidthPercent(int w)
271 { resource.toolbar_width_percent = w; }
272 inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
273 inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
274 inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
275 inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
276 inline void saveEdgeSnapThreshold(int t)
277 { resource.edge_snap_threshold = t; }
278 inline void saveImageDither(Bool d) { resource.image_dither = d; }
279 inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }
280 inline void saveFullMax(Bool f) { resource.full_max = f; }
281 inline void saveFocusNew(Bool f) { resource.focus_new = f; }
282 inline void saveFocusLast(Bool f) { resource.focus_last = f; }
283 inline void iconUpdate(void) { iconmenu->update(); }
284 #ifdef HAVE_STRFTIME
285 inline char *getStrftimeFormat(void) { return resource.strftime_format; }
286 void saveStrftimeFormat(const char *);
287 #else // !HAVE_STRFTIME
288 inline int getDateFormat(void) { return resource.date_format; }
289 inline void saveDateFormat(int f) { resource.date_format = f; }
290 inline Bool isClock24Hour(void) { return resource.clock24hour; }
291 inline void saveClock24Hour(Bool c) { resource.clock24hour = c; }
292 #endif // HAVE_STRFTIME
293
294 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
295 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
296 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
297
298 OpenboxWindow *getIcon(int);
299
300 int addWorkspace(void);
301 int removeLastWorkspace(void);
302
303 void removeWorkspaceNames(void);
304 void addWorkspaceName(const char *);
305 void addNetizen(Netizen *);
306 void removeNetizen(Window);
307 void addIcon(OpenboxWindow *);
308 void removeIcon(OpenboxWindow *);
309 char* getNameOfWorkspace(int);
310 void changeWorkspaceID(int);
311 void raiseWindows(Window *, int);
312 void reassociateWindow(OpenboxWindow *, int, Bool);
313 void prevFocus(void);
314 void nextFocus(void);
315 void raiseFocus(void);
316 void reconfigure(void);
317 void rereadMenu(void);
318 void shutdown(void);
319 void showPosition(int, int);
320 void showGeometry(unsigned int, unsigned int);
321 void hideGeometry(void);
322 void saveToolbarHide( Bool b);
323 void updateNetizenCurrentWorkspace(void);
324 void updateNetizenWorkspaceCount(void);
325 void updateNetizenWindowFocus(void);
326 void updateNetizenWindowAdd(Window, unsigned long);
327 void updateNetizenWindowDel(Window);
328 void updateNetizenConfigNotify(XEvent *);
329 void updateNetizenWindowRaise(Window);
330 void updateNetizenWindowLower(Window);
331
332 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
333 BestFitPlacement, LeftRight, RightLeft, TopBottom, BottomTop };
334 enum { LeftJustify = 1, RightJustify, CenterJustify };
335 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
336 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
337 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
338 WindowLower, WindowStick, WindowKill, SetStyle };
339 };
340
341
342 #endif // __Screen_hh
This page took 0.049455 seconds and 4 git commands to generate.