1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief Screen manages a single screen
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"
27 //! Manages a single screen
30 class Screen
: public otk::EventHandler
{
32 //! Holds a list of otk::Strut objects
33 typedef std::list
<otk::Strut
*> StrutList
;
35 static const unsigned long event_mask
= ColormapChangeMask
|
39 SubstructureNotifyMask
|
40 SubstructureRedirectMask
|
44 //! Holds a list of Clients
45 typedef std::list
<Client
*> ClientList
;
46 //! All managed clients on the screen (in order of being mapped)
50 //! Was %Openbox able to manage the screen?
53 //! The number of the screen on the X server
56 //! Information about this screen
57 const otk::ScreenInfo
*_info
;
59 //! Is the root colormap currently installed?
60 bool _root_cmap_installed
;
62 //! Area usable for placement etc (total - struts)
65 //! Combined strut from all of the clients' struts
68 //! An offscreen window which gets focus when nothing else has it
71 //! An offscreen window which shows that a NETWM compliant window manager is
73 Window _supportwindow
;
75 //! A list of all managed clients on the screen, in their stacking order
78 //! The desktop currently being displayed
81 //! The number of desktops
84 //! The names of all desktops
85 otk::Property::StringVect _desktop_names
;
87 //! Calculate the Screen::_area member
89 //! Set the list of supported NETWM atoms on the root window
90 void changeSupportedAtoms();
91 //! Set the client list on the root window
93 Sets the _NET_CLIENT_LIST root window property.<br>
94 Also calls Screen::updateStackingList.
96 void changeClientList();
97 //! Set the client stacking list on the root window
99 Set the _NET_CLIENT_LIST_STACKING root window property.
101 void changeStackingList();
102 //! Set the work area hint on the root window
104 Set the _NET_WORKAREA root window property.
106 void changeWorkArea();
108 //! Get desktop names from the root window property
109 void updateDesktopNames();
111 //! Changes to the specified desktop, displaying windows on it and hiding
112 //! windows on the others.
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.
117 void changeDesktop(long desktop
);
119 //! Changes the number of desktops.
121 @param num The number of desktops that should exist. This value must be
122 greater than 0 or it will be ignored.
124 void changeNumDesktops(long num
);
128 //! Constructs a new Screen object
130 //! Destroys the Screen object
134 inline int number() const { return _number
; }
136 //! Returns if the screen was successfully managed
138 If this is false, then the screen should be deleted and should NOT be
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
; }
151 //! Update's the screen's combined strut of all the clients.
153 Clients should call this whenever they change their strut.
157 //! Manage any pre-existing windows on the screen
158 void manageExisting();
159 //! Manage a client window
161 This gives the window a frame, reparents it, selects events on it, etc.
163 void manageWindow(Window window
);
164 //! Unmanage a client
166 This removes the window's frame, reparents it to root, unselects events on
168 @param client The client to unmanage
170 void unmanageWindow(Client
*client
);
172 //! Raises a client window above all others in its stacking layer
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.
180 void raiseWindow(Client
*client
);
182 //! Lowers a client window below all others in its stacking layer
183 void lowerWindow(Client
*client
);
185 //! Sets the name of a desktop by changing the root window property
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.
191 void setDesktopName(long i
, const otk::ustring
&name
);
193 void installColormap(bool install
) const;
195 virtual void propertyHandler(const XPropertyEvent
&e
);
196 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
197 virtual void mapRequestHandler(const XMapRequestEvent
&e
);