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