]> Dogcows Code - chaz/openbox/blob - src/Screen.hh
make iconified windows uniconify on an XMapRequestEvent.
[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
58 class Slit; // forward reference
59 class BFont;
60 class XAtom;
61
62 enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
63
64 struct WindowStyle {
65 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
66 b_pic_unfocus;
67 BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
68 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 struct Strut {
101 unsigned int top, bottom, left, right;
102
103 Strut(void): top(0), bottom(0), left(0), right(0) {}
104 };
105
106 class BScreen : public ScreenInfo {
107 private:
108 bool root_colormap_installed, managed, geom_visible;
109 GC opGC;
110 Pixmap geom_pixmap;
111 Window geom_window;
112
113 Blackbox *blackbox;
114 BImageControl *image_control;
115 Configmenu *configmenu;
116 Iconmenu *iconmenu;
117 Rootmenu *rootmenu;
118 Configuration *config;
119 XAtom *xatom;
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 typedef std::vector<Window> WindowList;
129 WindowList desktopWindowList, systrayWindowList;
130
131 Slit *slit;
132 Toolbar *toolbar;
133 Workspace *current_workspace;
134 Workspacemenu *workspacemenu;
135
136 unsigned int geom_w, geom_h;
137 unsigned long event_mask;
138
139 Rect usableArea;
140
141 typedef std::list<Strut*> StrutList;
142 StrutList strutList;
143 typedef std::vector<Workspace*> WorkspaceList;
144 WorkspaceList workspacesList;
145
146 struct screen_resource {
147 WindowStyle wstyle;
148 ToolbarStyle tstyle;
149 MenuStyle mstyle;
150
151 bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
152 opaque_move, full_max, focus_new, focus_last, click_raise,
153 hide_toolbar, window_to_window_snap, window_corner_snap;
154 BColor border_color;
155
156 unsigned int workspaces;
157 int toolbar_placement, toolbar_width_percent, placement_policy,
158 edge_snap_threshold, row_direction, col_direction;
159
160 unsigned int handle_width, bevel_width, frame_width, border_width;
161
162 #ifdef HAVE_STRFTIME
163 std::string strftime_format;
164 #else // !HAVE_STRFTIME
165 bool clock24hour;
166 int date_format;
167 #endif // HAVE_STRFTIME
168
169 } resource;
170 std::string screenstr;
171
172 BScreen(const BScreen&);
173 BScreen& operator=(const BScreen&);
174
175 bool parseMenuFile(FILE *file, Rootmenu *menu);
176
177 BTexture readDatabaseTexture(const std::string &rname,
178 const std::string &default_color,
179 const Configuration &style);
180 BColor readDatabaseColor(const std::string &rname,
181 const std::string &default_color,
182 const Configuration &style);
183 BFont *readDatabaseFont(const std::string &rname, 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 doImageDither(void) const { return image_control->doDither(); }
208 inline bool doOrderedDither(void) const { return resource.ordered_dither; }
209 inline bool doOpaqueMove(void) const { return resource.opaque_move; }
210 inline bool doFullMax(void) const { return resource.full_max; }
211 inline bool doFocusNew(void) const { return resource.focus_new; }
212 inline bool doFocusLast(void) const { return resource.focus_last; }
213 inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
214 inline bool getWindowToWindowSnap(void) const
215 { return resource.window_to_window_snap; }
216 inline bool getWindowCornerSnap(void) const
217 { return resource.window_corner_snap; }
218
219 inline const GC &getOpGC(void) const { return opGC; }
220
221 inline Blackbox *getBlackbox(void) { return blackbox; }
222 inline BColor *getBorderColor(void) { return &resource.border_color; }
223 inline BImageControl *getImageControl(void) { return image_control; }
224 inline Rootmenu *getRootmenu(void) { return rootmenu; }
225
226 inline Slit *getSlit(void) { return slit; }
227 inline Toolbar *getToolbar(void) { return toolbar; }
228
229 Workspace *getWorkspace(unsigned int index);
230
231 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
232
233 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
234
235 inline unsigned int getHandleWidth(void) const
236 { return resource.handle_width; }
237 inline unsigned int getBevelWidth(void) const
238 { return resource.bevel_width; }
239 inline unsigned int getFrameWidth(void) const
240 { return resource.frame_width; }
241 inline unsigned int getBorderWidth(void) const
242 { return resource.border_width; }
243
244 inline unsigned int getCurrentWorkspaceID(void)
245 { return current_workspace->getID(); }
246 inline unsigned int getWorkspaceCount(void)
247 { return workspacesList.size(); }
248 inline unsigned int getIconCount(void) { return iconList.size(); }
249 inline unsigned int getNumberOfWorkspaces(void) const
250 { return resource.workspaces; }
251 inline int getPlacementPolicy(void) const
252 { return resource.placement_policy; }
253 inline int getEdgeSnapThreshold(void) const
254 { return resource.edge_snap_threshold; }
255 inline int getRowPlacementDirection(void) const
256 { return resource.row_direction; }
257 inline int getColPlacementDirection(void) const
258 { return resource.col_direction; }
259
260 inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
261 void saveSloppyFocus(bool s);
262 void saveAutoRaise(bool a);
263 void saveClickRaise(bool c);
264 void saveWorkspaces(unsigned int w);
265 void savePlacementPolicy(int p);
266 void saveRowPlacementDirection(int d);
267 void saveColPlacementDirection(int d);
268 void saveEdgeSnapThreshold(int t);
269 void saveImageDither(bool d);
270 void saveOpaqueMove(bool o);
271 void saveFullMax(bool f);
272 void saveFocusNew(bool f);
273 void saveFocusLast(bool f);
274 void saveHideToolbar(bool h);
275 void saveWindowToWindowSnap(bool s);
276 void saveWindowCornerSnap(bool s);
277 inline void iconUpdate(void) { iconmenu->update(); }
278
279 #ifdef HAVE_STRFTIME
280 inline const char *getStrftimeFormat(void)
281 { return resource.strftime_format.c_str(); }
282 void saveStrftimeFormat(const std::string& format);
283 #else // !HAVE_STRFTIME
284 inline int getDateFormat(void) { return resource.date_format; }
285 inline void saveDateFormat(int f);
286 inline bool isClock24Hour(void) { return resource.clock24hour; }
287 inline void saveClock24Hour(bool c);
288 #endif // HAVE_STRFTIME
289
290 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
291 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
292 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
293
294 BlackboxWindow *getIcon(unsigned int index);
295
296 const Rect& availableArea(void) const;
297 void updateAvailableArea(void);
298 void addStrut(Strut *strut);
299 void removeStrut(Strut *strut);
300
301 unsigned int addWorkspace(void);
302 unsigned int removeLastWorkspace(void);
303 void changeWorkspaceID(unsigned int id);
304 void saveWorkspaceNames(void);
305
306 void addNetizen(Netizen *n);
307 void removeNetizen(Window w);
308
309 void addDesktopWindow(Window window);
310 void removeDesktopWindow(Window window);
311
312 void addSystrayWindow(Window window);
313 void removeSystrayWindow(Window window);
314
315 void addIcon(BlackboxWindow *w);
316 void removeIcon(BlackboxWindow *w);
317
318 void updateClientList(void);
319 void updateStackingList(void);
320 void manageWindow(Window w);
321 void unmanageWindow(BlackboxWindow *w, bool remap);
322 void raiseWindows(Window *workspace_stack, unsigned int num);
323 void lowerDesktops(void);
324 void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
325 bool ignore_sticky);
326 void propagateWindowName(const BlackboxWindow *bw);
327 void prevFocus(void);
328 void nextFocus(void);
329 void raiseFocus(void);
330 void load_rc(void);
331 void save_rc(void);
332 void reconfigure(void);
333 void toggleFocusModel(FocusModel model);
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(const 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.053721 seconds and 5 git commands to generate.