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