]> Dogcows Code - chaz/openbox/blob - src/screen.hh
keep track of desktops...
[chaz/openbox] / src / screen.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __screen_hh
3 #define __screen_hh
4
5 /*! @file screen.hh
6 @brief OBScreen manages a single screen
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include "client.hh"
14 #include "widget.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
23 #include <string>
24 #include <list>
25
26 namespace ob {
27
28 class OBClient;
29 class OBRootWindow;
30
31 //! Manages a single screen
32 /*!
33 */
34 class OBScreen : public otk::OtkEventHandler, public OBWidget {
35 public:
36 //! Holds a list of otk::Strut objects
37 typedef std::list<otk::Strut*> StrutList;
38
39 static const unsigned long event_mask = ColormapChangeMask |
40 EnterWindowMask |
41 LeaveWindowMask |
42 PropertyChangeMask |
43 SubstructureNotifyMask |
44 SubstructureRedirectMask |
45 ButtonPressMask |
46 ButtonReleaseMask;
47
48 //! All managed clients on the screen (in order of being mapped)
49 OBClient::List clients;
50
51 private:
52 //! Was %Openbox able to manage the screen?
53 bool _managed;
54
55 //! The number of the screen on the X server
56 int _number;
57
58 //! Information about this screen
59 const otk::ScreenInfo *_info;
60
61 //! The Image Control used for rendering on the screen
62 otk::BImageControl *_image_control;
63
64 //! The style with which to render on the screen
65 otk::Style _style;
66
67 //! Is the root colormap currently installed?
68 bool _root_cmap_installed;
69
70 //! Area usable for placement etc (total - struts)
71 otk::Rect _area;
72
73 //! Combined strut from all of the clients' struts
74 otk::Strut _strut;
75
76 //! An offscreen window which gets focus when nothing else has it
77 Window _focuswindow;
78
79 //! An offscreen window which shows that a NETWM compliant window manager is
80 //! running
81 Window _supportwindow;
82
83 //! A list of all managed clients on the screen, in their stacking order
84 OBClient::List _stacking;
85
86 //! The desktop currently being displayed
87 long _desktop;
88
89 //! The number of desktops
90 long _num_desktops;
91
92 //! The names of all desktops
93 otk::OBProperty::StringVect _desktop_names;
94
95 //! Calculate the OBScreen::_area member
96 void calcArea();
97 //! Set the list of supported NETWM atoms on the root window
98 void changeSupportedAtoms();
99 //! Set the client list on the root window
100 /*!
101 Sets the _NET_CLIENT_LIST root window property.<br>
102 Also calls OBScreen::updateStackingList.
103 */
104 void changeClientList();
105 //! Set the client stacking list on the root window
106 /*!
107 Set the _NET_CLIENT_LIST_STACKING root window property.
108 */
109 void changeStackingList();
110 //! Set the work area hint on the root window
111 /*!
112 Set the _NET_WORKAREA root window property.
113 */
114 void changeWorkArea();
115
116 //! Get desktop names from the root window property
117 void updateDesktopNames();
118
119 public:
120 #ifndef SWIG
121 //! Constructs a new OBScreen object
122 OBScreen(int screen);
123 //! Destroys the OBScreen object
124 virtual ~OBScreen();
125 #endif
126
127 inline int number() const { return _number; }
128
129 //! Returns if the screen was successfully managed
130 /*!
131 If this is false, then the screen should be deleted and should NOT be
132 used.
133 */
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 unsigned long desktop() const { return _desktop; }
145
146 //! Update's the screen's combined strut of all the clients.
147 /*!
148 Clients should call this whenever they change their strut.
149 */
150 void updateStrut();
151
152 //! Manage any pre-existing windows on the screen
153 void manageExisting();
154 //! Manage a client window
155 /*!
156 This gives the window a frame, reparents it, selects events on it, etc.
157 */
158 void manageWindow(Window window);
159 //! Unmanage a client
160 /*!
161 This removes the window's frame, reparents it to root, unselects events on
162 it, etc.
163 */
164 void unmanageWindow(OBClient *client);
165
166 //! Raises/Lowers a client window above/below all others in its stacking
167 //! layer
168 void restack(bool raise, OBClient *client);
169
170 //! Changes to the specified desktop, displaying windows on it and hiding
171 //! windows on the others.
172 /*!
173 @param desktop The number of the desktop to switch to (starts from 0).
174 If the desktop is out of valid range, it is ignored.
175 */
176 void changeDesktop(long desktop);
177
178 //! Changes the number of desktops.
179 /*!
180 @param num The number of desktops that should exist. This value must be
181 greater than 0 or it will be ignored.
182 */
183 void changeNumDesktops(long num);
184
185 //! Sets the name of a desktop
186 /*!
187 @param i The index of the desktop to set the name for (starts at 0)
188 @param name The name to set for the desktop
189 If the index is too large, it is simply ignored.
190 */
191 void setDesktopName(long i, const std::string &name);
192
193 virtual void propertyHandler(const XPropertyEvent &e);
194 virtual void clientMessageHandler(const XClientMessageEvent &e);
195 virtual void mapRequestHandler(const XMapRequestEvent &e);
196 };
197
198 }
199
200 #endif// __screen_hh
This page took 0.047852 seconds and 5 git commands to generate.