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::vector
<otk::Strut
> StrutList
;
34 //! Holds a list of otk::Rect objects
35 typedef std::vector
<otk::Rect
> RectList
;
37 static const unsigned long event_mask
= ColormapChangeMask
|
41 SubstructureNotifyMask
|
42 SubstructureRedirectMask
|
46 //! Holds a list of Clients
47 typedef std::list
<Client
*> ClientList
;
48 //! All managed clients on the screen (in order of being mapped)
52 //! Was %Openbox able to manage the screen?
55 //! The number of the screen on the X server
58 //! Information about this screen
59 const otk::ScreenInfo
*_info
;
61 //! Is the root colormap currently installed?
62 bool _root_cmap_installed
;
64 //! Area usable for placement etc (total - struts), one per desktop,
65 //! plus one extra for windows on all desktops
68 //! Combined strut from all of the clients' struts, one per desktop,
69 //! plus one extra for windows on all desktops
72 //! An offscreen window which gets focus when nothing else has it
75 //! An offscreen window which shows that a NETWM compliant window manager is
77 Window _supportwindow
;
79 //! A list of all managed clients on the screen, in their stacking order
82 //! The desktop currently being displayed
83 unsigned int _desktop
;
85 //! The number of desktops
86 unsigned int _num_desktops
;
88 //! The names of all desktops
89 otk::Property::StringVect _desktop_names
;
91 //! Calculate the Screen::_area member
93 //! Set the list of supported NETWM atoms on the root window
94 void changeSupportedAtoms();
95 //! Set the client list on the root window
97 Sets the _NET_CLIENT_LIST root window property.<br>
98 Also calls Screen::updateStackingList.
100 void changeClientList();
101 //! Set the client stacking list on the root window
103 Set the _NET_CLIENT_LIST_STACKING root window property.
105 void changeStackingList();
106 //! Set the work area hint on the root window
108 Set the _NET_WORKAREA root window property.
110 void changeWorkArea();
112 //! Get desktop names from the root window property
113 void updateDesktopNames();
115 //! Changes to the specified desktop, displaying windows on it and hiding
116 //! windows on the others.
118 @param desktop The number of the desktop to switch to (starts from 0).
119 If the desktop is out of valid range, it is ignored.
121 void changeDesktop(unsigned int desktop
);
123 //! Changes the number of desktops.
125 @param num The number of desktops that should exist. This value must be
126 greater than 0 or it will be ignored.
128 void changeNumDesktops(unsigned int num
);
132 //! Constructs a new Screen object
134 //! Destroys the Screen object
138 inline int number() const { return _number
; }
140 //! Returns if the screen was successfully managed
142 If this is false, then the screen should be deleted and should NOT be
145 inline bool managed() const { return _managed
; }
146 //! An offscreen window which gets focus when nothing else has it
147 inline Window
focuswindow() const { return _focuswindow
; }
148 //! Returns the desktop being displayed
149 inline unsigned int desktop() const { return _desktop
; }
150 //! Returns the number of desktops
151 inline unsigned int numDesktops() const { return _num_desktops
; }
153 //! Returns the area of the screen not reserved by applications' Struts
155 @param desktop The desktop number of the area to retrieve for. A value of
156 0xffffffff will return an area that combines all struts
159 const otk::Rect
& area(unsigned int desktop
) const;
161 //! Update's the screen's combined strut of all the clients.
163 Clients should call this whenever they change their strut.
167 //! Manage any pre-existing windows on the screen
168 void manageExisting();
169 //! Manage a client window
171 This gives the window a frame, reparents it, selects events on it, etc.
173 void manageWindow(Window window
);
174 //! Unmanage a client
176 This removes the window's frame, reparents it to root, unselects events on
178 @param client The client to unmanage
180 void unmanageWindow(Client
*client
);
182 //! Raises a client window above all others in its stacking layer
184 raiseWindow has a couple of constraints that lowerWindow does not.<br>
185 1) raiseWindow can be called after changing a Client's stack layer, and
186 the list will be reorganized properly.<br>
187 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
188 called for the specified client.
190 void raiseWindow(Client
*client
);
192 //! Lowers a client window below all others in its stacking layer
193 void lowerWindow(Client
*client
);
195 //! Sets the name of a desktop by changing the root window property
197 @param i The index of the desktop to set the name for (starts at 0)
198 @param name The name to set for the desktop
199 If the index is too large, it is simply ignored.
201 void setDesktopName(unsigned int i
, const otk::ustring
&name
);
203 void installColormap(bool install
) const;
205 virtual void propertyHandler(const XPropertyEvent
&e
);
206 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
207 virtual void mapRequestHandler(const XMapRequestEvent
&e
);