]> Dogcows Code - chaz/openbox/blob - src/Screen.hh
move the Strut struct from Screen.hh to Util.hh
[chaz/openbox] / src / Screen.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Screen.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef __Screen_hh
25 #define __Screen_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29
30 #ifdef TIME_WITH_SYS_TIME
31 # include <sys/time.h>
32 # include <time.h>
33 #else // !TIME_WITH_SYS_TIME
34 # ifdef HAVE_SYS_TIME_H
35 # include <sys/time.h>
36 # else // !HAVE_SYS_TIME_H
37 # include <time.h>
38 # endif // HAVE_SYS_TIME_H
39 #endif // TIME_WITH_SYS_TIME
40 }
41
42 #include <list>
43 #include <vector>
44
45 #include "Color.hh"
46 #include "Texture.hh"
47 #include "Image.hh"
48 #include "Configmenu.hh"
49 #include "Iconmenu.hh"
50 #include "Netizen.hh"
51 #include "Rootmenu.hh"
52 #include "Timer.hh"
53 #include "Workspace.hh"
54 #include "Workspacemenu.hh"
55 #include "blackbox.hh"
56
57 class Slit; // forward reference
58 class BFont;
59 class XAtom;
60 struct Strut;
61
62 enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
63
64 struct WindowStyle {
65 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
66 b_pic_unfocus;
67 BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
68 b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
69
70 BFont *font;
71
72 TextJustify justify;
73
74 void doJustify(const std::string &text, int &start_pos,
75 unsigned int max_length, unsigned int modifier) const;
76 };
77
78 struct ToolbarStyle {
79 BColor l_text, w_text, c_text, b_pic;
80 BTexture toolbar, label, window, button, pressed, clock;
81
82 BFont *font;
83
84 TextJustify justify;
85
86 void doJustify(const std::string &text, int &start_pos,
87 unsigned int max_length, unsigned int modifier) const;
88 };
89
90 struct MenuStyle {
91 BColor t_text, f_text, h_text, d_text;
92 BTexture title, frame, hilite;
93
94 BFont *t_font, *f_font;
95
96 TextJustify t_justify, f_justify;
97 int bullet, bullet_pos;
98 };
99
100 class BScreen : public ScreenInfo {
101 private:
102 bool root_colormap_installed, managed, geom_visible;
103 GC opGC;
104 Pixmap geom_pixmap;
105 Window geom_window;
106
107 Blackbox *blackbox;
108 BImageControl *image_control;
109 Configmenu *configmenu;
110 Iconmenu *iconmenu;
111 Rootmenu *rootmenu;
112 Configuration *config;
113 XAtom *xatom;
114
115 typedef std::list<Rootmenu*> RootmenuList;
116 RootmenuList rootmenuList;
117
118 typedef std::list<Netizen*> NetizenList;
119 NetizenList netizenList;
120 BlackboxWindowList iconList, windowList;
121
122 typedef std::vector<Window> WindowList;
123 WindowList desktopWindowList, systrayWindowList;
124
125 Slit *slit;
126 Toolbar *toolbar;
127 Workspace *current_workspace;
128 Workspacemenu *workspacemenu;
129
130 unsigned int geom_w, geom_h;
131 unsigned long event_mask;
132
133 Rect usableArea;
134
135 typedef std::list<Strut*> StrutList;
136 StrutList strutList;
137 typedef std::vector<Workspace*> WorkspaceList;
138 WorkspaceList workspacesList;
139
140 struct screen_resource {
141 WindowStyle wstyle;
142 ToolbarStyle tstyle;
143 MenuStyle mstyle;
144
145 bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
146 opaque_move, full_max, focus_new, focus_last, click_raise,
147 hide_toolbar, window_to_window_snap, window_corner_snap, aa_fonts,
148 ignore_shaded, ignore_maximized;
149 BColor border_color;
150
151 unsigned int workspaces;
152 int toolbar_placement, toolbar_width_percent, placement_policy,
153 edge_snap_threshold, row_direction, col_direction;
154
155 unsigned int handle_width, bevel_width, frame_width, border_width,
156 resize_zones;
157
158 #ifdef HAVE_STRFTIME
159 std::string strftime_format;
160 #else // !HAVE_STRFTIME
161 bool clock24hour;
162 int date_format;
163 #endif // HAVE_STRFTIME
164
165 } resource;
166 std::string screenstr;
167
168 BScreen(const BScreen&);
169 BScreen& operator=(const BScreen&);
170
171 bool parseMenuFile(FILE *file, Rootmenu *menu);
172
173 BTexture readDatabaseTexture(const std::string &rname,
174 const std::string &default_color,
175 const Configuration &style);
176 BColor readDatabaseColor(const std::string &rname,
177 const std::string &default_color,
178 const Configuration &style);
179 BFont *readDatabaseFont(const std::string &rbasename,
180 const Configuration &style);
181
182 void InitMenu(void);
183 void LoadStyle(void);
184
185 void updateWorkArea(void);
186 public:
187 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
188 UnderMousePlacement, ClickMousePlacement, LeftRight, RightLeft,
189 TopBottom, BottomTop, IgnoreShaded, IgnoreMaximized };
190 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
191 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
192 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
193 WindowLower, WindowStick, WindowKill, SetStyle };
194 enum FocusModel { SloppyFocus, ClickToFocus };
195
196 BScreen(Blackbox *bb, unsigned int scrn);
197 ~BScreen(void);
198
199 inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
200 inline bool isRootColormapInstalled(void) const
201 { return root_colormap_installed; }
202 inline bool doAutoRaise(void) const { return resource.auto_raise; }
203 inline bool doClickRaise(void) const { return resource.click_raise; }
204 inline bool isScreenManaged(void) const { return managed; }
205 inline bool doAAFonts(void) const { return resource.aa_fonts; }
206 inline bool doImageDither(void) const { return image_control->doDither(); }
207 inline bool doOrderedDither(void) const { return resource.ordered_dither; }
208 inline bool doOpaqueMove(void) const { return resource.opaque_move; }
209 inline bool doFullMax(void) const { return resource.full_max; }
210 inline bool doFocusNew(void) const { return resource.focus_new; }
211 inline bool doFocusLast(void) const { return resource.focus_last; }
212 inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
213 inline bool getWindowToWindowSnap(void) const
214 { return resource.window_to_window_snap; }
215 inline bool getWindowCornerSnap(void) const
216 { return resource.window_corner_snap; }
217
218 inline const GC &getOpGC(void) const { return opGC; }
219
220 inline Blackbox *getBlackbox(void) { return blackbox; }
221 inline BColor *getBorderColor(void) { return &resource.border_color; }
222 inline BImageControl *getImageControl(void) { return image_control; }
223 inline Rootmenu *getRootmenu(void) { return rootmenu; }
224
225 inline Slit *getSlit(void) { return slit; }
226 inline Toolbar *getToolbar(void) { return toolbar; }
227
228 Workspace *getWorkspace(unsigned int index);
229
230 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
231
232 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
233
234 inline unsigned int getHandleWidth(void) const
235 { return resource.handle_width; }
236 inline unsigned int getBevelWidth(void) const
237 { return resource.bevel_width; }
238 inline unsigned int getFrameWidth(void) const
239 { return resource.frame_width; }
240 inline unsigned int getBorderWidth(void) const
241 { return resource.border_width; }
242 inline unsigned int getResizeZones(void) const
243 { return resource.resize_zones; }
244 inline bool getPlaceIgnoreShaded(void) const
245 { return resource.ignore_shaded; }
246 inline bool getPlaceIgnoreMaximized(void) const
247 { return resource.ignore_maximized; }
248
249 inline unsigned int getCurrentWorkspaceID(void) const
250 { return current_workspace->getID(); }
251 inline unsigned int getWorkspaceCount(void) const
252 { return workspacesList.size(); }
253 inline unsigned int getIconCount(void) const { return iconList.size(); }
254 inline unsigned int getNumberOfWorkspaces(void) const
255 { return resource.workspaces; }
256 inline int getPlacementPolicy(void) const
257 { return resource.placement_policy; }
258 inline int getEdgeSnapThreshold(void) const
259 { return resource.edge_snap_threshold; }
260 inline int getRowPlacementDirection(void) const
261 { return resource.row_direction; }
262 inline int getColPlacementDirection(void) const
263 { return resource.col_direction; }
264
265 void changeWorkspaceCount(unsigned int new_count);
266
267 inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
268 void saveSloppyFocus(bool s);
269 void saveAutoRaise(bool a);
270 void saveClickRaise(bool c);
271 void saveWorkspaces(unsigned int w);
272 void savePlacementPolicy(int p);
273 void saveRowPlacementDirection(int d);
274 void saveColPlacementDirection(int d);
275 void saveEdgeSnapThreshold(int t);
276 void saveImageDither(bool d);
277 void saveAAFonts(bool f);
278 void saveOpaqueMove(bool o);
279 void saveFullMax(bool f);
280 void saveFocusNew(bool f);
281 void saveFocusLast(bool f);
282 void saveHideToolbar(bool h);
283 void saveWindowToWindowSnap(bool s);
284 void saveWindowCornerSnap(bool s);
285 void saveResizeZones(unsigned int z);
286 void savePlaceIgnoreShaded(bool i);
287 void savePlaceIgnoreMaximized(bool i);
288 inline void iconUpdate(void) { iconmenu->update(); }
289
290 #ifdef HAVE_STRFTIME
291 inline const char *getStrftimeFormat(void)
292 { return resource.strftime_format.c_str(); }
293 void saveStrftimeFormat(const std::string& format);
294 #else // !HAVE_STRFTIME
295 inline int getDateFormat(void) { return resource.date_format; }
296 inline void saveDateFormat(int f);
297 inline bool isClock24Hour(void) { return resource.clock24hour; }
298 inline void saveClock24Hour(bool 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 BlackboxWindow *getIcon(unsigned int index);
306
307 const Rect& availableArea(void) const;
308 void updateAvailableArea(void);
309 void addStrut(Strut *strut);
310 void removeStrut(Strut *strut);
311
312 unsigned int addWorkspace(void);
313 unsigned int removeLastWorkspace(void);
314 void changeWorkspaceID(unsigned int id);
315 void saveWorkspaceNames(void);
316
317 void addNetizen(Netizen *n);
318 void removeNetizen(Window w);
319
320 void addSystrayWindow(Window window);
321 void removeSystrayWindow(Window window);
322
323 void addIcon(BlackboxWindow *w);
324 void removeIcon(BlackboxWindow *w);
325
326 void updateClientList(void);
327 void updateStackingList(void);
328 void manageWindow(Window w);
329 void unmanageWindow(BlackboxWindow *w, bool remap);
330 void raiseWindows(Window *workspace_stack, unsigned int num);
331 void lowerWindows(Window *workspace_stack, unsigned int num);
332 void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
333 bool ignore_sticky);
334 void propagateWindowName(const BlackboxWindow *bw);
335 void prevFocus(void);
336 void nextFocus(void);
337 void raiseFocus(void);
338 void load_rc(void);
339 void save_rc(void);
340 void reconfigure(void);
341 void toggleFocusModel(FocusModel model);
342 void rereadMenu(void);
343 void shutdown(void);
344 void showPosition(int x, int y);
345 void showGeometry(unsigned int gx, unsigned int gy);
346 void hideGeometry(void);
347
348 void buttonPressEvent(const XButtonEvent *xbutton);
349 void propertyNotifyEvent(const XPropertyEvent *pe);
350
351 void updateNetizenCurrentWorkspace(void);
352 void updateNetizenWorkspaceCount(void);
353 void updateNetizenWindowFocus(void);
354 void updateNetizenWindowAdd(Window w, unsigned long p);
355 void updateNetizenWindowDel(Window w);
356 void updateNetizenConfigNotify(XEvent *e);
357 void updateNetizenWindowRaise(Window w);
358 void updateNetizenWindowLower(Window w);
359 };
360
361
362 #endif // __Screen_hh
This page took 0.053291 seconds and 5 git commands to generate.