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/renderstyle.hh"
15 #include "otk/strut.hh"
16 #include "otk/rect.hh"
17 #include "otk/screeninfo.hh"
18 #include "otk/eventhandler.hh"
19 #include "otk/property.hh"
20 #include "otk/ustring.hh"
29 //! Manages a single screen
32 class Screen
: public otk::EventHandler
, public WidgetBase
{
34 //! Holds a list of otk::Strut objects
35 typedef std::list
<otk::Strut
*> StrutList
;
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 //! The style with which to render on the screen
62 otk::RenderStyle _style
;
64 //! Is the root colormap currently installed?
65 bool _root_cmap_installed
;
67 //! Area usable for placement etc (total - struts)
70 //! Combined strut from all of the clients' struts
73 //! An offscreen window which gets focus when nothing else has it
76 //! An offscreen window which shows that a NETWM compliant window manager is
78 Window _supportwindow
;
80 //! A list of all managed clients on the screen, in their stacking order
83 //! The desktop currently being displayed
86 //! The number of desktops
89 //! The names of all desktops
90 otk::Property::StringVect _desktop_names
;
92 //! Calculate the Screen::_area member
94 //! Set the list of supported NETWM atoms on the root window
95 void changeSupportedAtoms();
96 //! Set the client list on the root window
98 Sets the _NET_CLIENT_LIST root window property.<br>
99 Also calls Screen::updateStackingList.
101 void changeClientList();
102 //! Set the client stacking list on the root window
104 Set the _NET_CLIENT_LIST_STACKING root window property.
106 void changeStackingList();
107 //! Set the work area hint on the root window
109 Set the _NET_WORKAREA root window property.
111 void changeWorkArea();
113 //! Get desktop names from the root window property
114 void updateDesktopNames();
116 //! Changes to the specified desktop, displaying windows on it and hiding
117 //! windows on the others.
119 @param desktop The number of the desktop to switch to (starts from 0).
120 If the desktop is out of valid range, it is ignored.
122 void changeDesktop(long desktop
);
124 //! Changes the number of desktops.
126 @param num The number of desktops that should exist. This value must be
127 greater than 0 or it will be ignored.
129 void changeNumDesktops(long num
);
133 //! Constructs a new Screen object
135 //! Destroys the Screen object
139 inline int number() const { return _number
; }
141 //! Returns if the screen was successfully managed
143 If this is false, then the screen should be deleted and should NOT be
146 inline bool managed() const { return _managed
; }
147 //! Returns the area of the screen not reserved by applications' Struts
148 inline const otk::Rect
&area() const { return _area
; }
149 //! Returns the style in use on the screen
150 inline const otk::RenderStyle
*style() const { return &_style
; }
151 //! An offscreen window which gets focus when nothing else has it
152 inline Window
focuswindow() const { return _focuswindow
; }
153 //! Returns the desktop being displayed
154 inline long desktop() const { return _desktop
; }
155 //! Returns the number of desktops
156 inline long numDesktops() const { return _num_desktops
; }
158 //! Update's the screen's combined strut of all the clients.
160 Clients should call this whenever they change their strut.
164 //! Manage any pre-existing windows on the screen
165 void manageExisting();
166 //! Manage a client window
168 This gives the window a frame, reparents it, selects events on it, etc.
170 void manageWindow(Window window
);
171 //! Unmanage a client
173 This removes the window's frame, reparents it to root, unselects events on
175 @param client The client to unmanage
177 void unmanageWindow(Client
*client
);
179 //! Raises a client window above all others in its stacking layer
181 raiseWindow has a couple of constraints that lowerWindow does not.<br>
182 1) raiseWindow can be called after changing a Client's stack layer, and
183 the list will be reorganized properly.<br>
184 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
185 called for the specified client.
187 void raiseWindow(Client
*client
);
189 //! Lowers a client window below all others in its stacking layer
190 void lowerWindow(Client
*client
);
192 //! Sets the name of a desktop by changing the root window property
194 @param i The index of the desktop to set the name for (starts at 0)
195 @param name The name to set for the desktop
196 If the index is too large, it is simply ignored.
198 void setDesktopName(long i
, const otk::ustring
&name
);
200 void installColormap(bool install
) const;
202 virtual void propertyHandler(const XPropertyEvent
&e
);
203 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
204 virtual void mapRequestHandler(const XMapRequestEvent
&e
);