]> Dogcows Code - chaz/openbox/blob - src/screen.hh
remove includes for widgetbase.hh. fix bug with circular modal pointer.
[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 //! Manages a single screen
28 /*!
29 */
30 class Screen : public otk::EventHandler {
31 public:
32 //! Holds a list of otk::Strut objects
33 typedef std::list<otk::Strut*> StrutList;
34
35 static const unsigned long event_mask = ColormapChangeMask |
36 EnterWindowMask |
37 LeaveWindowMask |
38 PropertyChangeMask |
39 SubstructureNotifyMask |
40 SubstructureRedirectMask |
41 ButtonPressMask |
42 ButtonReleaseMask;
43
44 //! Holds a list of Clients
45 typedef std::list<Client*> ClientList;
46 //! All managed clients on the screen (in order of being mapped)
47 ClientList clients;
48
49 private:
50 //! Was %Openbox able to manage the screen?
51 bool _managed;
52
53 //! The number of the screen on the X server
54 int _number;
55
56 //! Information about this screen
57 const otk::ScreenInfo *_info;
58
59 //! Is the root colormap currently installed?
60 bool _root_cmap_installed;
61
62 //! Area usable for placement etc (total - struts)
63 otk::Rect _area;
64
65 //! Combined strut from all of the clients' struts
66 otk::Strut _strut;
67
68 //! An offscreen window which gets focus when nothing else has it
69 Window _focuswindow;
70
71 //! An offscreen window which shows that a NETWM compliant window manager is
72 //! running
73 Window _supportwindow;
74
75 //! A list of all managed clients on the screen, in their stacking order
76 ClientList _stacking;
77
78 //! The desktop currently being displayed
79 long _desktop;
80
81 //! The number of desktops
82 long _num_desktops;
83
84 //! The names of all desktops
85 otk::Property::StringVect _desktop_names;
86
87 //! Calculate the Screen::_area member
88 void calcArea();
89 //! Set the list of supported NETWM atoms on the root window
90 void changeSupportedAtoms();
91 //! Set the client list on the root window
92 /*!
93 Sets the _NET_CLIENT_LIST root window property.<br>
94 Also calls Screen::updateStackingList.
95 */
96 void changeClientList();
97 //! Set the client stacking list on the root window
98 /*!
99 Set the _NET_CLIENT_LIST_STACKING root window property.
100 */
101 void changeStackingList();
102 //! Set the work area hint on the root window
103 /*!
104 Set the _NET_WORKAREA root window property.
105 */
106 void changeWorkArea();
107
108 //! Get desktop names from the root window property
109 void updateDesktopNames();
110
111 //! Changes to the specified desktop, displaying windows on it and hiding
112 //! windows on the others.
113 /*!
114 @param desktop The number of the desktop to switch to (starts from 0).
115 If the desktop is out of valid range, it is ignored.
116 */
117 void changeDesktop(long desktop);
118
119 //! Changes the number of desktops.
120 /*!
121 @param num The number of desktops that should exist. This value must be
122 greater than 0 or it will be ignored.
123 */
124 void changeNumDesktops(long num);
125
126 public:
127 #ifndef SWIG
128 //! Constructs a new Screen object
129 Screen(int screen);
130 //! Destroys the Screen object
131 virtual ~Screen();
132 #endif
133
134 inline int number() const { return _number; }
135
136 //! Returns if the screen was successfully managed
137 /*!
138 If this is false, then the screen should be deleted and should NOT be
139 used.
140 */
141 inline bool managed() const { return _managed; }
142 //! Returns the area of the screen not reserved by applications' Struts
143 inline const otk::Rect &area() const { return _area; }
144 //! An offscreen window which gets focus when nothing else has it
145 inline Window focuswindow() const { return _focuswindow; }
146 //! Returns the desktop being displayed
147 inline long desktop() const { return _desktop; }
148 //! Returns the number of desktops
149 inline long numDesktops() const { return _num_desktops; }
150
151 //! Update's the screen's combined strut of all the clients.
152 /*!
153 Clients should call this whenever they change their strut.
154 */
155 void updateStrut();
156
157 //! Manage any pre-existing windows on the screen
158 void manageExisting();
159 //! Manage a client window
160 /*!
161 This gives the window a frame, reparents it, selects events on it, etc.
162 */
163 void manageWindow(Window window);
164 //! Unmanage a client
165 /*!
166 This removes the window's frame, reparents it to root, unselects events on
167 it, etc.
168 @param client The client to unmanage
169 */
170 void unmanageWindow(Client *client);
171
172 //! Raises a client window above all others in its stacking layer
173 /*!
174 raiseWindow has a couple of constraints that lowerWindow does not.<br>
175 1) raiseWindow can be called after changing a Client's stack layer, and
176 the list will be reorganized properly.<br>
177 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
178 called for the specified client.
179 */
180 void raiseWindow(Client *client);
181
182 //! Lowers a client window below all others in its stacking layer
183 void lowerWindow(Client *client);
184
185 //! Sets the name of a desktop by changing the root window property
186 /*!
187 @param i The index of the desktop to set the name for (starts at 0)
188 @param name The name to set for the desktop
189 If the index is too large, it is simply ignored.
190 */
191 void setDesktopName(long i, const otk::ustring &name);
192
193 void installColormap(bool install) const;
194
195 virtual void propertyHandler(const XPropertyEvent &e);
196 virtual void clientMessageHandler(const XClientMessageEvent &e);
197 virtual void mapRequestHandler(const XMapRequestEvent &e);
198 };
199
200 }
201
202 #endif// __screen_hh
This page took 0.045216 seconds and 4 git commands to generate.