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