]> Dogcows Code - chaz/openbox/blob - src/Screen.hh
2511ae854f8f8c02178241ae2ec9eb5ee3b3a7b3
[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 l_text_focus, l_text_unfocus, b_pic_focus,
66 b_pic_unfocus;
67 BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
68 h_focus, h_unfocus, 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 specialWindowList, 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 #ifdef XINERAMA
135 RectList xineramaUsableArea;
136 #endif // XINERAMA
137
138 typedef std::list<Strut*> StrutList;
139 StrutList strutList;
140 typedef std::vector<Workspace*> WorkspaceList;
141 WorkspaceList workspacesList;
142
143 struct screen_resource {
144 WindowStyle wstyle;
145 ToolbarStyle tstyle;
146 MenuStyle mstyle;
147
148 bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
149 opaque_move, full_max, focus_new, focus_last, click_raise,
150 allow_scroll_lock, hide_toolbar, window_corner_snap, aa_fonts,
151 ignore_shaded, ignore_maximized, workspace_warping, shadow_fonts;
152
153 int snap_to_windows, snap_to_edges;
154 unsigned int snap_offset;
155
156 BColor border_color;
157
158 unsigned int workspaces;
159 int toolbar_placement, toolbar_width_percent, placement_policy,
160 snap_threshold, row_direction, col_direction, root_scroll,
161 resistance_size;
162
163 unsigned int handle_width, bevel_width, frame_width, border_width,
164 resize_zones;
165
166 unsigned int root_menu_button, workspace_menu_button;
167
168 #ifdef HAVE_STRFTIME
169 std::string strftime_format;
170 #else // !HAVE_STRFTIME
171 bool clock24hour;
172 int date_format;
173 #endif // HAVE_STRFTIME
174
175 } resource;
176 std::string screenstr;
177
178 BScreen(const BScreen&);
179 BScreen& operator=(const BScreen&);
180
181 bool parseMenuFile(FILE *file, Rootmenu *menu);
182
183 BTexture readDatabaseTexture(const std::string &rname,
184 const std::string &default_color,
185 const Configuration &style);
186 BColor readDatabaseColor(const std::string &rname,
187 const std::string &default_color,
188 const Configuration &style);
189 BFont *readDatabaseFont(const std::string &rbasename,
190 const Configuration &style);
191
192 void InitMenu(void);
193 void LoadStyle(void);
194
195 void updateWorkArea(void);
196 public:
197 enum { WindowNoSnap = 0, WindowSnap, WindowResistance };
198 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
199 UnderMousePlacement, ClickMousePlacement, LeftRight, RightLeft,
200 TopBottom, BottomTop, IgnoreShaded, IgnoreMaximized };
201 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
202 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
203 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
204 WindowLower, WindowStick, WindowKill, SetStyle };
205 enum FocusModel { SloppyFocus, ClickToFocus };
206 enum RootScrollDirection { NoScroll = 0, NormalScroll, ReverseScroll };
207
208 BScreen(Blackbox *bb, unsigned int scrn);
209 ~BScreen(void);
210
211 inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
212 inline bool isRootColormapInstalled(void) const
213 { return root_colormap_installed; }
214 inline bool doAutoRaise(void) const { return resource.auto_raise; }
215 inline bool doClickRaise(void) const { return resource.click_raise; }
216 inline bool isScreenManaged(void) const { return managed; }
217 inline bool doShadowFonts(void) const { return resource.shadow_fonts; }
218 inline bool doAAFonts(void) const { return resource.aa_fonts; }
219 inline bool doImageDither(void) const { return image_control->doDither(); }
220 inline bool doOrderedDither(void) const { return resource.ordered_dither; }
221 inline bool doOpaqueMove(void) const { return resource.opaque_move; }
222 inline bool doFullMax(void) const { return resource.full_max; }
223 inline bool doFocusNew(void) const { return resource.focus_new; }
224 inline bool doFocusLast(void) const { return resource.focus_last; }
225 inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
226 inline int getWindowToWindowSnap(void) const
227 { return resource.snap_to_windows; }
228 inline int getWindowToEdgeSnap(void) const
229 { return resource.snap_to_edges; }
230 inline bool getWindowCornerSnap(void) const
231 { return resource.window_corner_snap; }
232 inline bool allowScrollLock(void) const { return resource.allow_scroll_lock; }
233 inline bool doWorkspaceWarping(void) const
234 { return resource.workspace_warping; }
235 inline int rootScrollDirection(void) const { return resource.root_scroll; }
236 inline unsigned int rootMenuButton(void) const
237 { return resource.root_menu_button; }
238 inline unsigned int workspaceMenuButton(void) const
239 { return resource.workspace_menu_button; }
240
241 inline const GC &getOpGC(void) const { return opGC; }
242
243 inline Blackbox *getBlackbox(void) { return blackbox; }
244 inline BColor *getBorderColor(void) { return &resource.border_color; }
245 inline BImageControl *getImageControl(void) { return image_control; }
246 inline Rootmenu *getRootmenu(void) { return rootmenu; }
247
248 inline Slit *getSlit(void) { return slit; }
249 inline Toolbar *getToolbar(void) { return toolbar; }
250
251 Workspace *getWorkspace(unsigned int index);
252
253 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
254
255 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
256
257 inline unsigned int getHandleWidth(void) const
258 { return resource.handle_width; }
259 inline unsigned int getBevelWidth(void) const
260 { return resource.bevel_width; }
261 inline unsigned int getFrameWidth(void) const
262 { return resource.frame_width; }
263 inline unsigned int getBorderWidth(void) const
264 { return resource.border_width; }
265 inline unsigned int getResizeZones(void) const
266 { return resource.resize_zones; }
267 inline bool getPlaceIgnoreShaded(void) const
268 { return resource.ignore_shaded; }
269 inline bool getPlaceIgnoreMaximized(void) const
270 { return resource.ignore_maximized; }
271
272 inline unsigned int getCurrentWorkspaceID(void) const
273 { return current_workspace->getID(); }
274 inline unsigned int getWorkspaceCount(void) const
275 { return workspacesList.size(); }
276 inline unsigned int getIconCount(void) const { return iconList.size(); }
277 inline unsigned int getNumberOfWorkspaces(void) const
278 { return resource.workspaces; }
279 inline int getPlacementPolicy(void) const
280 { return resource.placement_policy; }
281 inline int getSnapOffset(void) const
282 { return resource.snap_offset; }
283 inline int getSnapThreshold(void) const
284 { return resource.snap_threshold; }
285 inline int getResistanceSize(void) const
286 { return resource.resistance_size; }
287 inline int getRowPlacementDirection(void) const
288 { return resource.row_direction; }
289 inline int getColPlacementDirection(void) const
290 { return resource.col_direction; }
291
292 void changeWorkspaceCount(unsigned int new_count);
293
294 inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
295 void saveSloppyFocus(bool s);
296 void saveAutoRaise(bool a);
297 void saveClickRaise(bool c);
298 void saveWorkspaces(unsigned int w);
299 void savePlacementPolicy(int p);
300 void saveRowPlacementDirection(int d);
301 void saveColPlacementDirection(int d);
302 void saveSnapThreshold(int t);
303 void saveSnapOffset(int o);
304 void saveResistanceSize(int s);
305 void saveImageDither(bool d);
306 void saveShadowFonts(bool f);
307 void saveAAFonts(bool f);
308 void saveOpaqueMove(bool o);
309 void saveFullMax(bool f);
310 void saveFocusNew(bool f);
311 void saveFocusLast(bool f);
312 void saveHideToolbar(bool h);
313 void saveWindowToEdgeSnap(int s);
314 void saveWindowToWindowSnap(int s);
315 void saveWindowCornerSnap(bool s);
316 void saveResizeZones(unsigned int z);
317 void savePlaceIgnoreShaded(bool i);
318 void savePlaceIgnoreMaximized(bool i);
319 void saveAllowScrollLock(bool a);
320 void saveWorkspaceWarping(bool w);
321 void saveRootScrollDirection(int d);
322 void saveRootMenuButton(unsigned int b);
323 void saveWorkspaceMenuButton(unsigned int b);
324 inline void iconUpdate(void) { iconmenu->update(); }
325
326 #ifdef HAVE_STRFTIME
327 inline const char *getStrftimeFormat(void)
328 { return resource.strftime_format.c_str(); }
329 void saveStrftimeFormat(const std::string& format);
330 #else // !HAVE_STRFTIME
331 inline int getDateFormat(void) { return resource.date_format; }
332 inline void saveDateFormat(int f);
333 inline bool isClock24Hour(void) { return resource.clock24hour; }
334 inline void saveClock24Hour(bool c);
335 #endif // HAVE_STRFTIME
336
337 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
338 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
339 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
340
341 BlackboxWindow *getIcon(unsigned int index);
342
343 // allAvailableAreas should be used whenever possible instead of this function
344 // as then Xinerama will work correctly.
345 const Rect& availableArea(void) const;
346 #ifdef XINERAMA
347 const RectList& allAvailableAreas(void) const;
348 #endif // XINERAMA
349 void updateAvailableArea(void);
350 void addStrut(Strut *strut);
351 void removeStrut(Strut *strut);
352
353 unsigned int addWorkspace(void);
354 unsigned int removeLastWorkspace(void);
355 void changeWorkspaceID(unsigned int id);
356 void saveWorkspaceNames(void);
357
358 void addNetizen(Netizen *n);
359 void removeNetizen(Window w);
360
361 void addSystrayWindow(Window window);
362 void removeSystrayWindow(Window window);
363
364 void addIcon(BlackboxWindow *w);
365 void removeIcon(BlackboxWindow *w);
366
367 void updateClientList(void);
368 void updateStackingList(void);
369 void manageWindow(Window w);
370 void unmanageWindow(BlackboxWindow *w, bool remap);
371 void raiseWindows(Window *workspace_stack, unsigned int num);
372 void lowerWindows(Window *workspace_stack, unsigned int num);
373 void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
374 bool ignore_sticky);
375 void propagateWindowName(const BlackboxWindow *bw);
376 void prevFocus(void);
377 void nextFocus(void);
378 void raiseFocus(void);
379 void load_rc(void);
380 void save_rc(void);
381 void reconfigure(void);
382 void toggleFocusModel(FocusModel model);
383 void rereadMenu(void);
384 void shutdown(void);
385 void showPosition(int x, int y);
386 void showGeometry(unsigned int gx, unsigned int gy);
387 void hideGeometry(void);
388
389 void showWorkspaceMenu(int x, int y);
390 void showRootMenu(int x, int y);
391
392 void buttonPressEvent(const XButtonEvent *xbutton);
393 void propertyNotifyEvent(const XPropertyEvent *pe);
394
395 void updateNetizenCurrentWorkspace(void);
396 void updateNetizenWorkspaceCount(void);
397 void updateNetizenWindowFocus(void);
398 void updateNetizenWindowAdd(Window w, unsigned long p);
399 void updateNetizenWindowDel(Window w);
400 void updateNetizenConfigNotify(XEvent *e);
401 void updateNetizenWindowRaise(Window w);
402 void updateNetizenWindowLower(Window w);
403 };
404
405
406 #endif // __Screen_hh
This page took 0.04939 seconds and 3 git commands to generate.