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/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"
32 //! Manages a single screen
35 class Screen
: public otk::EventHandler
, public WidgetBase
{
37 //! Holds a list of otk::Strut objects
38 typedef std::list
<otk::Strut
*> StrutList
;
40 static const unsigned long event_mask
= ColormapChangeMask
|
44 SubstructureNotifyMask
|
45 SubstructureRedirectMask
|
49 //! All managed clients on the screen (in order of being mapped)
53 //! Was %Openbox able to manage the screen?
56 //! The number of the screen on the X server
59 //! Information about this screen
60 const otk::ScreenInfo
*_info
;
62 //! The Image Control used for rendering on the screen
63 otk::ImageControl
*_image_control
;
65 //! The style with which to render on the screen
68 //! Is the root colormap currently installed?
69 bool _root_cmap_installed
;
71 //! Area usable for placement etc (total - struts)
74 //! Combined strut from all of the clients' struts
77 //! An offscreen window which gets focus when nothing else has it
80 //! An offscreen window which shows that a NETWM compliant window manager is
82 Window _supportwindow
;
84 //! A list of all managed clients on the screen, in their stacking order
85 Client::List _stacking
;
87 //! The desktop currently being displayed
90 //! The number of desktops
93 //! The names of all desktops
94 otk::Property::StringVect _desktop_names
;
96 //! Calculate the Screen::_area member
98 //! Set the list of supported NETWM atoms on the root window
99 void changeSupportedAtoms();
100 //! Set the client list on the root window
102 Sets the _NET_CLIENT_LIST root window property.<br>
103 Also calls Screen::updateStackingList.
105 void changeClientList();
106 //! Set the client stacking list on the root window
108 Set the _NET_CLIENT_LIST_STACKING root window property.
110 void changeStackingList();
111 //! Set the work area hint on the root window
113 Set the _NET_WORKAREA root window property.
115 void changeWorkArea();
117 //! Get desktop names from the root window property
118 void updateDesktopNames();
120 //! Changes to the specified desktop, displaying windows on it and hiding
121 //! windows on the others.
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.
126 void changeDesktop(long desktop
);
128 //! Changes the number of desktops.
130 @param num The number of desktops that should exist. This value must be
131 greater than 0 or it will be ignored.
133 void changeNumDesktops(long num
);
137 //! Constructs a new Screen object
139 //! Destroys the Screen object
143 inline int number() const { return _number
; }
145 //! Returns if the screen was successfully managed
147 If this is false, then the screen should be deleted and should NOT be
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
; }
164 //! Update's the screen's combined strut of all the clients.
166 Clients should call this whenever they change their strut.
170 //! Manage any pre-existing windows on the screen
171 void manageExisting();
172 //! Manage a client window
174 This gives the window a frame, reparents it, selects events on it, etc.
176 void manageWindow(Window window
);
177 //! Unmanage a client
179 This removes the window's frame, reparents it to root, unselects events on
181 @param client The client to unmanage
183 void unmanageWindow(Client
*client
);
185 //! Raises a client window above all others in its stacking layer
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.
193 void raiseWindow(Client
*client
);
195 //! Lowers a client window below all others in its stacking layer
196 void lowerWindow(Client
*client
);
198 //! Sets the name of a desktop by changing the root window property
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.
204 void setDesktopName(long i
, const otk::ustring
&name
);
206 virtual void propertyHandler(const XPropertyEvent
&e
);
207 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
208 virtual void mapRequestHandler(const XMapRequestEvent
&e
);