1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief OBScreen manages a single screen
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"
31 //! Manages a single screen
34 class OBScreen
: public otk::OtkEventHandler
, public OBWidget
{
36 //! Holds a list of otk::Strut objects
37 typedef std::list
<otk::Strut
*> StrutList
;
39 static const unsigned long event_mask
= ColormapChangeMask
|
43 SubstructureNotifyMask
|
44 SubstructureRedirectMask
|
48 //! All managed clients on the screen (in order of being mapped)
49 OBClient::List clients
;
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 Image Control used for rendering on the screen
62 otk::BImageControl
*_image_control
;
64 //! The style with which to render on the screen
67 //! Is the root colormap currently installed?
68 bool _root_cmap_installed
;
70 //! Area usable for placement etc (total - struts)
73 //! Combined strut from all of the clients' struts
76 //! An offscreen window which gets focus when nothing else has it
79 //! An offscreen window which shows that a NETWM compliant window manager is
81 Window _supportwindow
;
83 //! A list of all managed clients on the screen, in their stacking order
84 OBClient::List _stacking
;
86 //! The desktop currently being displayed
89 //! The number of desktops
92 //! The names of all desktops
93 otk::OBProperty::StringVect _desktop_names
;
95 //! Calculate the OBScreen::_area member
97 //! Set the list of supported NETWM atoms on the root window
98 void changeSupportedAtoms();
99 //! Set the client list on the root window
101 Sets the _NET_CLIENT_LIST root window property.<br>
102 Also calls OBScreen::updateStackingList.
104 void changeClientList();
105 //! Set the client stacking list on the root window
107 Set the _NET_CLIENT_LIST_STACKING root window property.
109 void changeStackingList();
110 //! Set the work area hint on the root window
112 Set the _NET_WORKAREA root window property.
114 void changeWorkArea();
116 //! Get desktop names from the root window property
117 void updateDesktopNames();
121 //! Constructs a new OBScreen object
122 OBScreen(int screen
);
123 //! Destroys the OBScreen object
127 inline int number() const { return _number
; }
129 //! Returns if the screen was successfully managed
131 If this is false, then the screen should be deleted and should NOT be
134 inline bool managed() const { return _managed
; }
135 //! Returns the Image Control used for rendering on the screen
136 inline otk::BImageControl
*imageControl() { return _image_control
; }
137 //! Returns the area of the screen not reserved by applications' Struts
138 inline const otk::Rect
&area() const { return _area
; }
139 //! Returns the style in use on the screen
140 inline const otk::Style
*style() const { return &_style
; }
141 //! An offscreen window which gets focus when nothing else has it
142 inline Window
focuswindow() const { return _focuswindow
; }
143 //! Returns the desktop being displayed
144 inline long desktop() const { return _desktop
; }
145 //! Returns the number of desktops
146 inline long numDesktops() const { return _num_desktops
; }
148 //! Update's the screen's combined strut of all the clients.
150 Clients should call this whenever they change their strut.
154 //! Manage any pre-existing windows on the screen
155 void manageExisting();
156 //! Manage a client window
158 This gives the window a frame, reparents it, selects events on it, etc.
160 void manageWindow(Window window
);
161 //! Unmanage a client
163 This removes the window's frame, reparents it to root, unselects events on
166 void unmanageWindow(OBClient
*client
);
168 //! Raises/Lowers a client window above/below all others in its stacking
170 void restack(bool raise
, OBClient
*client
);
172 //! Changes to the specified desktop, displaying windows on it and hiding
173 //! windows on the others.
175 @param desktop The number of the desktop to switch to (starts from 0).
176 If the desktop is out of valid range, it is ignored.
178 void changeDesktop(long desktop
);
180 //! Changes the number of desktops.
182 @param num The number of desktops that should exist. This value must be
183 greater than 0 or it will be ignored.
185 void changeNumDesktops(long num
);
187 //! Sets the name of a desktop
189 @param i The index of the desktop to set the name for (starts at 0)
190 @param name The name to set for the desktop
191 If the index is too large, it is simply ignored.
193 void setDesktopName(long i
, const std::string
&name
);
195 virtual void propertyHandler(const XPropertyEvent
&e
);
196 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
197 virtual void mapRequestHandler(const XMapRequestEvent
&e
);