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