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();
119 //! Changes to the specified desktop, displaying windows on it and hiding
120 //! windows on the others.
122 @param desktop The number of the desktop to switch to (starts from 0).
123 If the desktop is out of valid range, it is ignored.
125 void changeDesktop(long desktop
);
127 //! Changes the number of desktops.
129 @param num The number of desktops that should exist. This value must be
130 greater than 0 or it will be ignored.
132 void changeNumDesktops(long num
);
136 //! Constructs a new OBScreen object
137 OBScreen(int screen
);
138 //! Destroys the OBScreen object
142 inline int number() const { return _number
; }
144 //! Returns if the screen was successfully managed
146 If this is false, then the screen should be deleted and should NOT be
149 inline bool managed() const { return _managed
; }
150 //! Returns the Image Control used for rendering on the screen
151 inline otk::BImageControl
*imageControl() { return _image_control
; }
152 //! Returns the area of the screen not reserved by applications' Struts
153 inline const otk::Rect
&area() const { return _area
; }
154 //! Returns the style in use on the screen
155 inline const otk::Style
*style() const { return &_style
; }
156 //! An offscreen window which gets focus when nothing else has it
157 inline Window
focuswindow() const { return _focuswindow
; }
158 //! Returns the desktop being displayed
159 inline long desktop() const { return _desktop
; }
160 //! Returns the number of desktops
161 inline long numDesktops() const { return _num_desktops
; }
163 //! Update's the screen's combined strut of all the clients.
165 Clients should call this whenever they change their strut.
169 //! Manage any pre-existing windows on the screen
170 void manageExisting();
171 //! Manage a client window
173 This gives the window a frame, reparents it, selects events on it, etc.
175 void manageWindow(Window window
);
176 //! Unmanage a client
178 This removes the window's frame, reparents it to root, unselects events on
181 void unmanageWindow(OBClient
*client
);
183 //! Raises/Lowers a client window above/below all others in its stacking
185 void restack(bool raise
, OBClient
*client
);
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
);