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