1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief Screen manages a single screen
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"
28 //! Manages a single screen
31 class Screen
: public otk::EventHandler
, public WidgetBase
{
33 //! Holds a list of otk::Strut objects
34 typedef std::list
<otk::Strut
*> StrutList
;
36 static const unsigned long event_mask
= ColormapChangeMask
|
40 SubstructureNotifyMask
|
41 SubstructureRedirectMask
|
45 //! Holds a list of Clients
46 typedef std::list
<Client
*> ClientList
;
47 //! All managed clients on the screen (in order of being mapped)
51 //! Was %Openbox able to manage the screen?
54 //! The number of the screen on the X server
57 //! Information about this screen
58 const otk::ScreenInfo
*_info
;
60 //! Is the root colormap currently installed?
61 bool _root_cmap_installed
;
63 //! Area usable for placement etc (total - struts)
66 //! Combined strut from all of the clients' struts
69 //! An offscreen window which gets focus when nothing else has it
72 //! An offscreen window which shows that a NETWM compliant window manager is
74 Window _supportwindow
;
76 //! A list of all managed clients on the screen, in their stacking order
79 //! The desktop currently being displayed
82 //! The number of desktops
85 //! The names of all desktops
86 otk::Property::StringVect _desktop_names
;
88 //! Calculate the Screen::_area member
90 //! Set the list of supported NETWM atoms on the root window
91 void changeSupportedAtoms();
92 //! Set the client list on the root window
94 Sets the _NET_CLIENT_LIST root window property.<br>
95 Also calls Screen::updateStackingList.
97 void changeClientList();
98 //! Set the client stacking list on the root window
100 Set the _NET_CLIENT_LIST_STACKING root window property.
102 void changeStackingList();
103 //! Set the work area hint on the root window
105 Set the _NET_WORKAREA root window property.
107 void changeWorkArea();
109 //! Get desktop names from the root window property
110 void updateDesktopNames();
112 //! Changes to the specified desktop, displaying windows on it and hiding
113 //! windows on the others.
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.
118 void changeDesktop(long desktop
);
120 //! Changes the number of desktops.
122 @param num The number of desktops that should exist. This value must be
123 greater than 0 or it will be ignored.
125 void changeNumDesktops(long num
);
129 //! Constructs a new Screen object
131 //! Destroys the Screen object
135 inline int number() const { return _number
; }
137 //! Returns if the screen was successfully managed
139 If this is false, then the screen should be deleted and should NOT be
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
; }
152 //! Update's the screen's combined strut of all the clients.
154 Clients should call this whenever they change their strut.
158 //! Manage any pre-existing windows on the screen
159 void manageExisting();
160 //! Manage a client window
162 This gives the window a frame, reparents it, selects events on it, etc.
164 void manageWindow(Window window
);
165 //! Unmanage a client
167 This removes the window's frame, reparents it to root, unselects events on
169 @param client The client to unmanage
171 void unmanageWindow(Client
*client
);
173 //! Raises a client window above all others in its stacking layer
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.
181 void raiseWindow(Client
*client
);
183 //! Lowers a client window below all others in its stacking layer
184 void lowerWindow(Client
*client
);
186 //! Sets the name of a desktop by changing the root window property
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.
192 void setDesktopName(long i
, const otk::ustring
&name
);
194 void installColormap(bool install
) const;
196 virtual void propertyHandler(const XPropertyEvent
&e
);
197 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
198 virtual void mapRequestHandler(const XMapRequestEvent
&e
);