aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/BaseScreen.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbcompose/BaseScreen.hh')
-rw-r--r--util/fbcompose/BaseScreen.hh401
1 files changed, 401 insertions, 0 deletions
diff --git a/util/fbcompose/BaseScreen.hh b/util/fbcompose/BaseScreen.hh
new file mode 100644
index 0000000..f8f5208
--- /dev/null
+++ b/util/fbcompose/BaseScreen.hh
@@ -0,0 +1,401 @@
1/** BaseScreen.hh file for the fluxbox compositor. */
2
3// Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23
24#ifndef FBCOMPOSITOR_SCREEN_HH
25#define FBCOMPOSITOR_SCREEN_HH
26
27#include "BaseCompWindow.hh"
28#include "Enumerations.hh"
29#include "PluginManager.hh"
30
31#include <X11/extensions/Xfixes.h>
32#include <X11/Xlib.h>
33
34#include <algorithm>
35#include <iosfwd>
36#include <list>
37#include <vector>
38
39
40namespace FbCompositor {
41
42 class BaseScreen;
43 class CompositorConfig;
44
45
46 //--- SUPPORTING FUNCTIONS -------------------------------------------------
47
48 /** << output stream operator for the BaseScreen class. */
49 std::ostream &operator<<(std::ostream& out, const BaseScreen& s);
50
51
52 //--- BASE CLASS FOR SCREENS -----------------------------------------------
53
54 /**
55 * Base class for screen managing classes.
56 */
57 class BaseScreen {
58 //--- FRIEND OPERATORS -------------------------------------------------
59
60 friend std::ostream &operator<<(std::ostream& out, const BaseScreen& s);
61
62 public:
63 //--- CONSTRUCTORS AND DESTRUCTORS -------------------------------------
64
65 /** Constructor. */
66 BaseScreen(int screen_number, PluginType plugin_type, const CompositorConfig &config);
67
68 /** Destructor. */
69 virtual ~BaseScreen();
70
71
72 //--- OTHER INITIALIZATION ---------------------------------------------
73
74 /** Initializes the screen's plugins. */
75 virtual void initPlugins(const CompositorConfig &config);
76
77 /** Initializes all of the windows on the screen. */
78 virtual void initWindows();
79
80
81 //--- ACCESSORS --------------------------------------------------------
82
83 /** \returns the current connection to the X server. */
84 Display *display();
85
86 /** \returns the current connection to the X server (const version). */
87 const Display *display() const;
88
89 /** \returns the vector with the output heads on this screen. */
90 const std::vector<XRectangle> &heads() const;
91
92 /** \returns screen's root window. */
93 BaseCompWindow &rootWindow();
94
95 /** \returns screen's root window (const version). */
96 const BaseCompWindow &rootWindow() const;
97
98
99 /** \returns the active window XID. */
100 Window activeWindow() const;
101
102 /** \returns the XID of the current iconbar item. */
103 Window currentIconbarItem() const;
104
105 /** \returns the index of the current workspace. */
106 int currentWorkspace() const;
107
108 /** \returns screen's number. */
109 int screenNumber() const;
110
111 /** \returns the number of workspaces on this screen. */
112 int workspaceCount() const;
113
114
115 //--- WINDOW MANIPULATION ----------------------------------------------
116
117 /** Circulates a window on this screen. */
118 void circulateWindow(Window window, int place);
119
120 /** Creates a new window on this screen. */
121 void createWindow(Window window);
122
123 /** Damages a window on this screen. */
124 void damageWindow(Window window, const XRectangle &area);
125
126 /** Destroys a window on this screen. */
127 void destroyWindow(Window window);
128
129 /** Maps a window on this screen. */
130 void mapWindow(Window window);
131
132 /** Updates window's configuration. */
133 void reconfigureWindow(const XConfigureEvent &event);
134
135 /** Reparents a window. */
136 void reparentWindow(Window window, Window parent);
137
138 /** Updates window's shape. */
139 void updateShape(Window window);
140
141 /** Unmaps a window on this screen. */
142 void unmapWindow(Window window);
143
144 /** Updates the value of some window's property. */
145 void updateWindowProperty(Window window, Atom property, int state);
146
147
148 /** Marks a particular window as ignored. */
149 void ignoreWindow(Window window);
150
151 /** Checks whether a given window is managed by the current screen. */
152 bool isWindowManaged(Window window);
153
154
155 //--- SCREEN MANIPULATION ----------------------------------------------
156
157 /** Removes all accumulated damage from the screen. */
158 void clearScreenDamage();
159
160 /** Updates heads on the current screen. */
161 void updateHeads(HeadMode head_mode);
162
163
164 /** Notifies the screen of a background change. */
165 virtual void setRootPixmapChanged();
166
167 /** Notifies the screen of a root window change. */
168 virtual void setRootWindowSizeChanged();
169
170
171 //--- SCREEN RENDERING -------------------------------------------------
172
173 /** Renders the screen's contents. */
174 virtual void renderScreen() = 0;
175
176
177 protected:
178 //--- PROTECTED ACCESSORS ----------------------------------------------
179
180 /** \returns the list of windows on the screen. */
181 const std::list<BaseCompWindow*> &allWindows() const;
182
183 /** \returns the damaged screen area. */
184 XserverRegion damagedScreenArea();
185
186 /** \returns the plugin manager. */
187 const PluginManager &pluginManager() const;
188
189 /** \returns the reconfigure rectangle. */
190 XRectangle reconfigureRectangle() const;
191
192
193 /** \returns the root window pixmap. */
194 Pixmap rootWindowPixmap() const;
195
196 /** \returns whether the root window pixmap was set by the WM. */
197 bool wmSetRootWindowPixmap() const;
198
199
200 //--- SPECIALIZED WINDOW MANIPULATION FUNCTIONS ------------------------
201
202 /** Creates a window object from its XID. */
203 virtual BaseCompWindow *createWindowObject(Window window) = 0;
204
205
206 private:
207 //--- CONSTRUCTORS -----------------------------------------------------
208
209 /** Copy constructor. */
210 BaseScreen(const BaseScreen&);
211
212
213 //--- PROPERTY UPDATE FUNCTIONS ----------------------------------------
214
215 /** Update stored active window. */
216 void updateActiveWindow();
217
218 /** Update the current iconbar item. */
219 void updateCurrentIconbarItem();
220
221 /** Update the current workspace index. */
222 void updateCurrentWorkspace();
223
224 /** Update stored reconfigure rectangle. */
225 void updateReconfigureRect();
226
227 /** Update stored root window pixmap. */
228 void updateRootWindowPixmap(Pixmap new_pixmap = None);
229
230 /** Update the number of workspaces. */
231 void updateWorkspaceCount();
232
233
234 //--- SCREEN DAMAGE FUNCTIONS ------------------------------------------
235
236 /** Damages the reconfigure rectangle on the screen. */
237 void damageReconfigureRect();
238
239 /** Damages the given rectangle on the screen. */
240 void damageScreenArea(XRectangle area);
241
242 /** Damages the area in the given window. */
243 void damageWindowArea(BaseCompWindow *window, XRectangle area);
244
245 /** Damages the area taken by the given window. */
246 void damageWholeWindowArea(BaseCompWindow *window);
247
248
249 //--- INTERNAL FUNCTIONS -----------------------------------------------
250
251 /** \returns the first managed ancestor of a window. */
252 std::list<BaseCompWindow*>::iterator getFirstManagedAncestorIterator(Window window);
253
254 /** \returns the parent of a given window. */
255 Window getParentWindow(Window window);
256
257 /** \returns an iterator of m_windows that points to the given window. */
258 std::list<BaseCompWindow*>::iterator getWindowIterator(Window window);
259
260 /** \returns whether the given window is in the ignore list. */
261 bool isWindowIgnored(Window window);
262
263 /** Puts a window to a new location on the stack. */
264 void restackWindow(std::list<BaseCompWindow*>::iterator &windowIt, Window above);
265
266
267 //--- MAIN SCREEN DATA -------------------------------------------------
268
269 /** Current connection to the X server. */
270 Display *m_display;
271
272 /** Heads of the current display. */
273 std::vector<XRectangle> m_heads;
274
275 /** Windows that should be ignored. */
276 std::vector<Window> m_ignore_list;
277
278 /** Plugin manager for this screen. */
279 PluginManager m_plugin_manager;
280
281 /** Screen's number. */
282 int m_screen_number;
283
284 /** Screen's root window. */
285 BaseCompWindow m_root_window;
286
287 /** Screen's windows. */
288 std::list<BaseCompWindow*> m_windows;
289
290
291 /** XID of the active window. */
292 Window m_active_window_xid;
293
294 /** XID of the current iconbar item. */
295 Window m_current_iconbar_item;
296
297 /** The index of the current workspace. */
298 int m_current_workspace;
299
300 /** The current reconfigure rectangle. */
301 XRectangle m_reconfigure_rect;
302
303 /** The total number of workspaces. */
304 int m_workspace_count;
305
306
307 /** A list of damaged rectangles on the screen. */
308 std::vector<XRectangle> m_damaged_screen_rects;
309
310 /** Damaged screen region. */
311 XserverRegion m_screen_damage;
312
313
314 /** Pixmap, containing the desktop background. */
315 Pixmap m_root_window_pixmap;
316
317 /** Whether the background pixmap is set by the window manager or this class. */
318 bool m_wm_set_root_window_pixmap;
319 };
320
321
322 //--- INLINE FUNCTIONS -----------------------------------------------------
323
324 // Returns the active window XID.
325 inline Window BaseScreen::activeWindow() const {
326 return m_active_window_xid;
327 }
328
329 // Returns all of screen's windows.
330 inline const std::list<BaseCompWindow*> &BaseScreen::allWindows() const {
331 return m_windows;
332 }
333
334 // Returns the XID of the current iconbar item.
335 inline Window BaseScreen::currentIconbarItem() const {
336 return m_current_iconbar_item;
337 }
338
339 // Returns the index of the current workspace.
340 inline int BaseScreen::currentWorkspace() const {
341 return m_current_workspace;
342 }
343
344 // Returns the current connection to the X server.
345 inline Display *BaseScreen::display() {
346 return m_display;
347 }
348
349 // Returns the current connection to the X server (const version).
350 inline const Display *BaseScreen::display() const {
351 return m_display;
352 }
353
354 // Returns the vector with the output heads on this screen.
355 inline const std::vector<XRectangle> &BaseScreen::heads() const {
356 return m_heads;
357 }
358
359 // Returns the plugin manager.
360 inline const PluginManager &BaseScreen::pluginManager() const {
361 return m_plugin_manager;
362 }
363
364 // Returns the reconfigure rectangle.
365 inline XRectangle BaseScreen::reconfigureRectangle() const {
366 return m_reconfigure_rect;
367 }
368
369 // Returns screen's root window.
370 inline BaseCompWindow &BaseScreen::rootWindow() {
371 return m_root_window;
372 }
373
374 // Returns screen's root window (const version).
375 inline const BaseCompWindow &BaseScreen::rootWindow() const {
376 return m_root_window;
377 }
378
379 // Returns the root window pixmap.
380 inline Pixmap BaseScreen::rootWindowPixmap() const {
381 return m_root_window_pixmap;
382 }
383
384 // Returns the screen's number.
385 inline int BaseScreen::screenNumber() const {
386 return m_screen_number;
387 }
388
389 // Returns whether the root window pixmap was set by the WM.
390 inline bool BaseScreen::wmSetRootWindowPixmap() const {
391 return m_wm_set_root_window_pixmap;
392 }
393
394 // Returns the number of workspaces on this screen.
395 inline int BaseScreen::workspaceCount() const {
396 return m_workspace_count;
397 }
398}
399
400
401#endif // FBCOMPOSITOR_SCREEN_HH