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