1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief Screen manages a single screen
14 #include "widgetbase.hh"
15 #include "otk/renderstyle.hh"
16 #include "otk/strut.hh"
17 #include "otk/rect.hh"
18 #include "otk/screeninfo.hh"
19 #include "otk/eventhandler.hh"
20 #include "otk/property.hh"
21 #include "otk/ustring.hh"
30 //! Manages a single screen
33 class Screen
: public otk::EventHandler
, public WidgetBase
{
35 //! Holds a list of otk::Strut objects
36 typedef std::list
<otk::Strut
*> StrutList
;
38 static const unsigned long event_mask
= ColormapChangeMask
|
42 SubstructureNotifyMask
|
43 SubstructureRedirectMask
|
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 //! The style with which to render on the screen
61 otk::RenderStyle _style
;
63 //! Is the root colormap currently installed?
64 bool _root_cmap_installed
;
66 //! Area usable for placement etc (total - struts)
69 //! Combined strut from all of the clients' struts
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
80 Client::List _stacking
;
82 //! The desktop currently being displayed
85 //! The number of 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(long 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(long 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 //! Returns the area of the screen not reserved by applications' Struts
147 inline const otk::Rect
&area() const { return _area
; }
148 //! Returns the style in use on the screen
149 inline const otk::RenderStyle
*style() const { return &_style
; }
150 //! An offscreen window which gets focus when nothing else has it
151 inline Window
focuswindow() const { return _focuswindow
; }
152 //! Returns the desktop being displayed
153 inline long desktop() const { return _desktop
; }
154 //! Returns the number of desktops
155 inline long numDesktops() const { return _num_desktops
; }
157 //! Update's the screen's combined strut of all the clients.
159 Clients should call this whenever they change their strut.
163 //! Manage any pre-existing windows on the screen
164 void manageExisting();
165 //! Manage a client window
167 This gives the window a frame, reparents it, selects events on it, etc.
169 void manageWindow(Window window
);
170 //! Unmanage a client
172 This removes the window's frame, reparents it to root, unselects events on
174 @param client The client to unmanage
176 void unmanageWindow(Client
*client
);
178 //! Raises a client window above all others in its stacking layer
180 raiseWindow has a couple of constraints that lowerWindow does not.<br>
181 1) raiseWindow can be called after changing a Client's stack layer, and
182 the list will be reorganized properly.<br>
183 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
184 called for the specified client.
186 void raiseWindow(Client
*client
);
188 //! Lowers a client window below all others in its stacking layer
189 void lowerWindow(Client
*client
);
191 //! Sets the name of a desktop by changing the root window property
193 @param i The index of the desktop to set the name for (starts at 0)
194 @param name The name to set for the desktop
195 If the index is too large, it is simply ignored.
197 void setDesktopName(long i
, const otk::ustring
&name
);
199 virtual void propertyHandler(const XPropertyEvent
&e
);
200 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
201 virtual void mapRequestHandler(const XMapRequestEvent
&e
);