]> Dogcows Code - chaz/openbox/blob - src/screen.hh
add a Config class with config data from the scripts.
[chaz/openbox] / src / screen.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __screen_hh
3 #define __screen_hh
4
5 /*! @file screen.hh
6 @brief Screen manages a single screen
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include "config.hh"
14 #include "otk/strut.hh"
15 #include "otk/rect.hh"
16 #include "otk/screeninfo.hh"
17 #include "otk/eventhandler.hh"
18 #include "otk/property.hh"
19 #include "otk/ustring.hh"
20
21 #include <string>
22 #include <list>
23
24 namespace ob {
25
26 class Client;
27
28 struct DesktopLayout {
29 enum Corner { TopLeft, TopRight, BottomRight, BottomLeft };
30 enum Direction { Horizontal, Vertical };
31
32 Direction orientation;
33 Corner start_corner;
34 unsigned int rows;
35 unsigned int columns;
36 };
37
38 //! Manages a single screen
39 /*!
40 */
41 class Screen : public otk::EventHandler {
42 public:
43 //! Holds a list of otk::Strut objects
44 typedef std::vector<otk::Strut> StrutList;
45 //! Holds a list of otk::Rect objects
46 typedef std::vector<otk::Rect> RectList;
47
48 static const unsigned long event_mask = ColormapChangeMask |
49 EnterWindowMask |
50 LeaveWindowMask |
51 PropertyChangeMask |
52 SubstructureNotifyMask |
53 SubstructureRedirectMask |
54 ButtonPressMask |
55 ButtonReleaseMask;
56
57 //! Holds a list of Clients
58 typedef std::list<Client*> ClientList;
59 //! All managed clients on the screen (in order of being mapped)
60 ClientList clients;
61
62 private:
63 //! Was %Openbox able to manage the screen?
64 bool _managed;
65
66 //! The number of the screen on the X server
67 int _number;
68
69 //! Information about this screen
70 const otk::ScreenInfo *_info;
71
72 //! Configuration options from the user scripts
73 Config _config;
74
75 //! Area usable for placement etc (total - struts), one per desktop,
76 //! plus one extra for windows on all desktops
77 RectList _area;
78
79 //! Combined strut from all of the clients' struts, one per desktop,
80 //! plus one extra for windows on all desktops
81 StrutList _struts;
82
83 //! An offscreen window which gets focus when nothing else has it
84 Window _focuswindow;
85
86 //! An offscreen window which shows that a NETWM compliant window manager is
87 //! running
88 Window _supportwindow;
89
90 //! A list of all managed clients on the screen, in their stacking order
91 ClientList _stacking;
92
93 //! The desktop currently being displayed
94 unsigned int _desktop;
95
96 //! The number of desktops
97 unsigned int _num_desktops;
98
99 //! The names of all desktops
100 otk::Property::StringVect _desktop_names;
101
102 //! The layout of the desktops as specified by an EWMH compliant pager
103 DesktopLayout _layout;
104
105 //! True when the window manager is in 'showing desktop' mode
106 bool _showing_desktop;
107
108 //! Calculate the Screen::_area member
109 void calcArea();
110 //! Set the list of supported NETWM atoms on the root window
111 void changeSupportedAtoms();
112 //! Set the client list on the root window
113 /*!
114 Sets the _NET_CLIENT_LIST root window property.<br>
115 Also calls Screen::updateStackingList.
116 */
117 void changeClientList();
118 //! Set the client stacking list on the root window
119 /*!
120 Set the _NET_CLIENT_LIST_STACKING root window property.
121 */
122 void changeStackingList();
123 //! Set the work area hint on the root window
124 /*!
125 Set the _NET_WORKAREA root window property.
126 */
127 void changeWorkArea();
128
129 //! Get desktop names from the root window property
130 void updateDesktopNames();
131
132 //! Gets the layout of the desktops from the root window property
133 void updateDesktopLayout();
134
135 //! Changes to the specified desktop, displaying windows on it and hiding
136 //! windows on the others.
137 /*!
138 @param desktop The number of the desktop to switch to (starts from 0).
139 If the desktop is out of valid range, it is ignored.
140 */
141 void changeDesktop(unsigned int desktop);
142
143 //! Changes the number of desktops.
144 /*!
145 @param num The number of desktops that should exist. This value must be
146 greater than 0 or it will be ignored.
147 */
148 void changeNumDesktops(unsigned int num);
149
150 public:
151 #ifndef SWIG
152 //! Constructs a new Screen object
153 Screen(int screen);
154 //! Destroys the Screen object
155 virtual ~Screen();
156 #endif
157
158 inline int number() const { return _number; }
159
160 //! Returns if the screen was successfully managed
161 /*!
162 If this is false, then the screen should be deleted and should NOT be
163 used.
164 */
165 inline bool managed() const { return _managed; }
166
167 //! Returns the config options set by the user scripts
168 const Config& config() const { return _config; }
169
170 //! An offscreen window which gets focus when nothing else has it
171 inline Window focuswindow() const { return _focuswindow; }
172 //! Returns the desktop being displayed
173 inline unsigned int desktop() const { return _desktop; }
174 //! Returns the number of desktops
175 inline unsigned int numDesktops() const { return _num_desktops; }
176 //! When true, the desktop is being shown and all clients are hidden
177 inline bool showingDesktop() const { return _showing_desktop; }
178
179 //! Returns the area of the screen not reserved by applications' Struts
180 /*!
181 @param desktop The desktop number of the area to retrieve for. A value of
182 0xffffffff will return an area that combines all struts
183 on all desktops.
184 */
185 const otk::Rect& area(unsigned int desktop) const;
186
187 //! Gives the layout of how the desktops are being displayed, the number of
188 //! rows and columns etc.
189 const DesktopLayout& desktopLayout() const { return _layout; }
190
191 //! Shows and focuses the desktop and hides all the client windows, or
192 //! returns to the normal state, showing client windows.
193 void showDesktop(bool show);
194
195 //! Update's the screen's combined strut of all the clients.
196 /*!
197 Clients should call this whenever they change their strut.
198 */
199 void updateStruts();
200
201 //! Manage any pre-existing windows on the screen
202 void manageExisting();
203 //! Manage a client window
204 /*!
205 This gives the window a frame, reparents it, selects events on it, etc.
206 */
207 void manageWindow(Window window);
208 //! Unmanage a client
209 /*!
210 This removes the window's frame, reparents it to root, unselects events on
211 it, etc.
212 @param client The client to unmanage
213 */
214 void unmanageWindow(Client *client);
215
216 //! Raises a client window above all others in its stacking layer
217 /*!
218 raiseWindow has a couple of constraints that lowerWindow does not.<br>
219 1) raiseWindow can be called after changing a Client's stack layer, and
220 the list will be reorganized properly.<br>
221 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
222 called for the specified client.
223 */
224 void raiseWindow(Client *client);
225
226 //! Lowers a client window below all others in its stacking layer
227 void lowerWindow(Client *client);
228
229 //! Sets the name of a desktop by changing the root window property
230 /*!
231 @param i The index of the desktop to set the name for (starts at 0)
232 @param name The name to set for the desktop
233 If the index is too large, it is simply ignored.
234 */
235 void setDesktopName(unsigned int i, const otk::ustring &name);
236
237 otk::ustring desktopName(unsigned int i) const;
238
239 void installColormap(bool install) const;
240
241 virtual void propertyHandler(const XPropertyEvent &e);
242 virtual void clientMessageHandler(const XClientMessageEvent &e);
243 virtual void mapRequestHandler(const XMapRequestEvent &e);
244 };
245
246 }
247
248 #endif// __screen_hh
This page took 0.045514 seconds and 4 git commands to generate.