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 struct DesktopLayout
{
28 enum Corner
{ TopLeft
, TopRight
, BottomRight
, BottomLeft
};
29 enum Direction
{ Horizontal
, Vertical
};
31 Direction orientation
;
37 //! Manages a single screen
40 class Screen
: public otk::EventHandler
{
42 //! Holds a list of otk::Strut objects
43 typedef std::vector
<otk::Strut
> StrutList
;
44 //! Holds a list of otk::Rect objects
45 typedef std::vector
<otk::Rect
> RectList
;
47 static const unsigned long event_mask
= ColormapChangeMask
|
51 SubstructureNotifyMask
|
52 SubstructureRedirectMask
|
56 //! Holds a list of Clients
57 typedef std::list
<Client
*> ClientList
;
58 //! All managed clients on the screen (in order of being mapped)
62 //! Was %Openbox able to manage the screen?
65 //! The number of the screen on the X server
68 //! Information about this screen
69 const otk::ScreenInfo
*_info
;
71 //! Area usable for placement etc (total - struts), one per desktop,
72 //! plus one extra for windows on all desktops
75 //! Combined strut from all of the clients' struts, one per desktop,
76 //! plus one extra for windows on all desktops
79 //! An offscreen window which gets focus when nothing else has it
82 //! An offscreen window which shows that a NETWM compliant window manager is
84 Window _supportwindow
;
86 //! A list of all managed clients on the screen, in their stacking order
89 //! The desktop currently being displayed
90 unsigned int _desktop
;
92 //! The number of desktops
93 unsigned int _num_desktops
;
95 //! The names of all desktops
96 otk::Property::StringVect _desktop_names
;
98 DesktopLayout _layout
;
100 //! Calculate the Screen::_area member
102 //! Set the list of supported NETWM atoms on the root window
103 void changeSupportedAtoms();
104 //! Set the client list on the root window
106 Sets the _NET_CLIENT_LIST root window property.<br>
107 Also calls Screen::updateStackingList.
109 void changeClientList();
110 //! Set the client stacking list on the root window
112 Set the _NET_CLIENT_LIST_STACKING root window property.
114 void changeStackingList();
115 //! Set the work area hint on the root window
117 Set the _NET_WORKAREA root window property.
119 void changeWorkArea();
121 //! Get desktop names from the root window property
122 void updateDesktopNames();
124 //! Gets the layout of the desktops from the root window property
125 void updateDesktopLayout();
127 //! Changes to the specified desktop, displaying windows on it and hiding
128 //! windows on the others.
130 @param desktop The number of the desktop to switch to (starts from 0).
131 If the desktop is out of valid range, it is ignored.
133 void changeDesktop(unsigned int desktop
);
135 //! Changes the number of desktops.
137 @param num The number of desktops that should exist. This value must be
138 greater than 0 or it will be ignored.
140 void changeNumDesktops(unsigned int num
);
144 //! Constructs a new Screen object
146 //! Destroys the Screen object
150 inline int number() const { return _number
; }
152 //! Returns if the screen was successfully managed
154 If this is false, then the screen should be deleted and should NOT be
157 inline bool managed() const { return _managed
; }
158 //! An offscreen window which gets focus when nothing else has it
159 inline Window
focuswindow() const { return _focuswindow
; }
160 //! Returns the desktop being displayed
161 inline unsigned int desktop() const { return _desktop
; }
162 //! Returns the number of desktops
163 inline unsigned int numDesktops() const { return _num_desktops
; }
165 //! Returns the area of the screen not reserved by applications' Struts
167 @param desktop The desktop number of the area to retrieve for. A value of
168 0xffffffff will return an area that combines all struts
171 const otk::Rect
& area(unsigned int desktop
) const;
173 const DesktopLayout
& desktopLayout() const { return _layout
; }
175 //! Update's the screen's combined strut of all the clients.
177 Clients should call this whenever they change their strut.
181 //! Manage any pre-existing windows on the screen
182 void manageExisting();
183 //! Manage a client window
185 This gives the window a frame, reparents it, selects events on it, etc.
187 void manageWindow(Window window
);
188 //! Unmanage a client
190 This removes the window's frame, reparents it to root, unselects events on
192 @param client The client to unmanage
194 void unmanageWindow(Client
*client
);
196 //! Raises a client window above all others in its stacking layer
198 raiseWindow has a couple of constraints that lowerWindow does not.<br>
199 1) raiseWindow can be called after changing a Client's stack layer, and
200 the list will be reorganized properly.<br>
201 2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
202 called for the specified client.
204 void raiseWindow(Client
*client
);
206 //! Lowers a client window below all others in its stacking layer
207 void lowerWindow(Client
*client
);
209 //! Sets the name of a desktop by changing the root window property
211 @param i The index of the desktop to set the name for (starts at 0)
212 @param name The name to set for the desktop
213 If the index is too large, it is simply ignored.
215 void setDesktopName(unsigned int i
, const otk::ustring
&name
);
217 void installColormap(bool install
) const;
219 virtual void propertyHandler(const XPropertyEvent
&e
);
220 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
221 virtual void mapRequestHandler(const XMapRequestEvent
&e
);