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