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