]> Dogcows Code - chaz/openbox/blob - src/Screen.hh
add option to the rc file to use/not use AA for Xft fonts
[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
61 enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
62
63 struct WindowStyle {
64 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
65 b_pic_unfocus;
66 BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
67 b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
68
69 BFont *font;
70
71 TextJustify justify;
72
73 void doJustify(const std::string &text, int &start_pos,
74 unsigned int max_length, unsigned int modifier) const;
75 };
76
77 struct ToolbarStyle {
78 BColor l_text, w_text, c_text, b_pic;
79 BTexture toolbar, label, window, button, pressed, clock;
80
81 BFont *font;
82
83 TextJustify justify;
84
85 void doJustify(const std::string &text, int &start_pos,
86 unsigned int max_length, unsigned int modifier) const;
87 };
88
89 struct MenuStyle {
90 BColor t_text, f_text, h_text, d_text;
91 BTexture title, frame, hilite;
92
93 BFont *t_font, *f_font;
94
95 TextJustify t_justify, f_justify;
96 int bullet, bullet_pos;
97 };
98
99 struct Strut {
100 unsigned int top, bottom, left, right;
101
102 Strut(void): top(0), bottom(0), left(0), right(0) {}
103 };
104
105 class BScreen : public ScreenInfo {
106 private:
107 bool root_colormap_installed, managed, geom_visible;
108 GC opGC;
109 Pixmap geom_pixmap;
110 Window geom_window;
111
112 Blackbox *blackbox;
113 BImageControl *image_control;
114 Configmenu *configmenu;
115 Iconmenu *iconmenu;
116 Rootmenu *rootmenu;
117 Configuration *config;
118 XAtom *xatom;
119
120 typedef std::list<Rootmenu*> RootmenuList;
121 RootmenuList rootmenuList;
122
123 typedef std::list<Netizen*> NetizenList;
124 NetizenList netizenList;
125 BlackboxWindowList iconList, windowList;
126
127 typedef std::vector<Window> WindowList;
128 WindowList desktopWindowList, systrayWindowList;
129
130 Slit *slit;
131 Toolbar *toolbar;
132 Workspace *current_workspace;
133 Workspacemenu *workspacemenu;
134
135 unsigned int geom_w, geom_h;
136 unsigned long event_mask;
137
138 Rect usableArea;
139
140 typedef std::list<Strut*> StrutList;
141 StrutList strutList;
142 typedef std::vector<Workspace*> WorkspaceList;
143 WorkspaceList workspacesList;
144
145 struct screen_resource {
146 WindowStyle wstyle;
147 ToolbarStyle tstyle;
148 MenuStyle mstyle;
149
150 bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
151 opaque_move, full_max, focus_new, focus_last, click_raise,
152 hide_toolbar, window_to_window_snap, window_corner_snap, aa_fonts;
153 BColor border_color;
154
155 unsigned int workspaces;
156 int toolbar_placement, toolbar_width_percent, placement_policy,
157 edge_snap_threshold, row_direction, col_direction;
158
159 unsigned int handle_width, bevel_width, frame_width, border_width;
160
161 #ifdef HAVE_STRFTIME
162 std::string strftime_format;
163 #else // !HAVE_STRFTIME
164 bool clock24hour;
165 int date_format;
166 #endif // HAVE_STRFTIME
167
168 } resource;
169 std::string screenstr;
170
171 BScreen(const BScreen&);
172 BScreen& operator=(const BScreen&);
173
174 bool parseMenuFile(FILE *file, Rootmenu *menu);
175
176 BTexture readDatabaseTexture(const std::string &rname,
177 const std::string &default_color,
178 const Configuration &style);
179 BColor readDatabaseColor(const std::string &rname,
180 const std::string &default_color,
181 const Configuration &style);
182 BFont *readDatabaseFont(const std::string &rbasename,
183 const Configuration &style);
184
185 void InitMenu(void);
186 void LoadStyle(void);
187
188 void updateWorkArea(void);
189 public:
190 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
191 UnderMousePlacement, LeftRight, RightLeft, TopBottom, BottomTop };
192 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
193 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
194 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
195 WindowLower, WindowStick, WindowKill, SetStyle };
196 enum FocusModel { SloppyFocus, ClickToFocus };
197
198 BScreen(Blackbox *bb, unsigned int scrn);
199 ~BScreen(void);
200
201 inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
202 inline bool isRootColormapInstalled(void) const
203 { return root_colormap_installed; }
204 inline bool doAutoRaise(void) const { return resource.auto_raise; }
205 inline bool doClickRaise(void) const { return resource.click_raise; }
206 inline bool isScreenManaged(void) const { return managed; }
207 inline bool doAAFonts(void) const { return resource.aa_fonts; }
208 inline bool doImageDither(void) const { return image_control->doDither(); }
209 inline bool doOrderedDither(void) const { return resource.ordered_dither; }
210 inline bool doOpaqueMove(void) const { return resource.opaque_move; }
211 inline bool doFullMax(void) const { return resource.full_max; }
212 inline bool doFocusNew(void) const { return resource.focus_new; }
213 inline bool doFocusLast(void) const { return resource.focus_last; }
214 inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
215 inline bool getWindowToWindowSnap(void) const
216 { return resource.window_to_window_snap; }
217 inline bool getWindowCornerSnap(void) const
218 { return resource.window_corner_snap; }
219
220 inline const GC &getOpGC(void) const { return opGC; }
221
222 inline Blackbox *getBlackbox(void) { return blackbox; }
223 inline BColor *getBorderColor(void) { return &resource.border_color; }
224 inline BImageControl *getImageControl(void) { return image_control; }
225 inline Rootmenu *getRootmenu(void) { return rootmenu; }
226
227 inline Slit *getSlit(void) { return slit; }
228 inline Toolbar *getToolbar(void) { return toolbar; }
229
230 Workspace *getWorkspace(unsigned int index);
231
232 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
233
234 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
235
236 inline unsigned int getHandleWidth(void) const
237 { return resource.handle_width; }
238 inline unsigned int getBevelWidth(void) const
239 { return resource.bevel_width; }
240 inline unsigned int getFrameWidth(void) const
241 { return resource.frame_width; }
242 inline unsigned int getBorderWidth(void) const
243 { return resource.border_width; }
244
245 inline unsigned int getCurrentWorkspaceID(void)
246 { return current_workspace->getID(); }
247 inline unsigned int getWorkspaceCount(void)
248 { return workspacesList.size(); }
249 inline unsigned int getIconCount(void) { return iconList.size(); }
250 inline unsigned int getNumberOfWorkspaces(void) const
251 { return resource.workspaces; }
252 inline int getPlacementPolicy(void) const
253 { return resource.placement_policy; }
254 inline int getEdgeSnapThreshold(void) const
255 { return resource.edge_snap_threshold; }
256 inline int getRowPlacementDirection(void) const
257 { return resource.row_direction; }
258 inline int getColPlacementDirection(void) const
259 { return resource.col_direction; }
260
261 inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
262 void saveSloppyFocus(bool s);
263 void saveAutoRaise(bool a);
264 void saveClickRaise(bool c);
265 void saveWorkspaces(unsigned int w);
266 void savePlacementPolicy(int p);
267 void saveRowPlacementDirection(int d);
268 void saveColPlacementDirection(int d);
269 void saveEdgeSnapThreshold(int t);
270 void saveImageDither(bool d);
271 void saveAAFonts(bool f);
272 void saveOpaqueMove(bool o);
273 void saveFullMax(bool f);
274 void saveFocusNew(bool f);
275 void saveFocusLast(bool f);
276 void saveHideToolbar(bool h);
277 void saveWindowToWindowSnap(bool s);
278 void saveWindowCornerSnap(bool s);
279 inline void iconUpdate(void) { iconmenu->update(); }
280
281 #ifdef HAVE_STRFTIME
282 inline const char *getStrftimeFormat(void)
283 { return resource.strftime_format.c_str(); }
284 void saveStrftimeFormat(const std::string& format);
285 #else // !HAVE_STRFTIME
286 inline int getDateFormat(void) { return resource.date_format; }
287 inline void saveDateFormat(int f);
288 inline bool isClock24Hour(void) { return resource.clock24hour; }
289 inline void saveClock24Hour(bool c);
290 #endif // HAVE_STRFTIME
291
292 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
293 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
294 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
295
296 BlackboxWindow *getIcon(unsigned int index);
297
298 const Rect& availableArea(void) const;
299 void updateAvailableArea(void);
300 void addStrut(Strut *strut);
301 void removeStrut(Strut *strut);
302
303 unsigned int addWorkspace(void);
304 unsigned int removeLastWorkspace(void);
305 void changeWorkspaceID(unsigned int id);
306 void saveWorkspaceNames(void);
307
308 void addNetizen(Netizen *n);
309 void removeNetizen(Window w);
310
311 void addDesktopWindow(Window window);
312 void removeDesktopWindow(Window window);
313
314 void addSystrayWindow(Window window);
315 void removeSystrayWindow(Window window);
316
317 void addIcon(BlackboxWindow *w);
318 void removeIcon(BlackboxWindow *w);
319
320 void updateClientList(void);
321 void updateStackingList(void);
322 void manageWindow(Window w);
323 void unmanageWindow(BlackboxWindow *w, bool remap);
324 void raiseWindows(Window *workspace_stack, unsigned int num);
325 void lowerDesktops(void);
326 void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
327 bool ignore_sticky);
328 void propagateWindowName(const BlackboxWindow *bw);
329 void prevFocus(void);
330 void nextFocus(void);
331 void raiseFocus(void);
332 void load_rc(void);
333 void save_rc(void);
334 void reconfigure(void);
335 void toggleFocusModel(FocusModel model);
336 void rereadMenu(void);
337 void shutdown(void);
338 void showPosition(int x, int y);
339 void showGeometry(unsigned int gx, unsigned int gy);
340 void hideGeometry(void);
341
342 void buttonPressEvent(const XButtonEvent *xbutton);
343
344 void updateNetizenCurrentWorkspace(void);
345 void updateNetizenWorkspaceCount(void);
346 void updateNetizenWindowFocus(void);
347 void updateNetizenWindowAdd(Window w, unsigned long p);
348 void updateNetizenWindowDel(Window w);
349 void updateNetizenConfigNotify(XEvent *e);
350 void updateNetizenWindowRaise(Window w);
351 void updateNetizenWindowLower(Window w);
352 };
353
354
355 #endif // __Screen_hh
This page took 0.049703 seconds and 5 git commands to generate.