diff options
Diffstat (limited to 'util/fbcompose/OpenGLWindow.cc')
-rw-r--r-- | util/fbcompose/OpenGLWindow.cc | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/util/fbcompose/OpenGLWindow.cc b/util/fbcompose/OpenGLWindow.cc new file mode 100644 index 0000000..a0977af --- /dev/null +++ b/util/fbcompose/OpenGLWindow.cc | |||
@@ -0,0 +1,112 @@ | |||
1 | /** OpenGLWindow.cc 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 | #include "OpenGLWindow.hh" | ||
25 | |||
26 | #include "BaseScreen.hh" | ||
27 | #include "Logging.hh" | ||
28 | #include "OpenGLScreen.hh" | ||
29 | #include "OpenGLUtility.hh" | ||
30 | #include "Utility.hh" | ||
31 | |||
32 | #include <X11/Xutil.h> | ||
33 | |||
34 | #include <algorithm> | ||
35 | #include <iostream> | ||
36 | |||
37 | using namespace FbCompositor; | ||
38 | |||
39 | |||
40 | //--- CONSTRUCTORS AND DESTRUCTORS --------------------------------------------- | ||
41 | |||
42 | // Constructor. | ||
43 | OpenGLWindow::OpenGLWindow(const OpenGLScreen &screen, Window window_xid) : | ||
44 | BaseCompWindow(static_cast<const BaseScreen&>(screen), window_xid, false) { | ||
45 | |||
46 | m_content_tex_partition = new OpenGL2DTexturePartition(screen, true); | ||
47 | m_shape_tex_partition = new OpenGL2DTexturePartition(screen, false); | ||
48 | |||
49 | updateWindowPos(); | ||
50 | } | ||
51 | |||
52 | // Destructor. | ||
53 | OpenGLWindow::~OpenGLWindow() { } | ||
54 | |||
55 | |||
56 | //--- ACCESSORS ---------------------------------------------------------------- | ||
57 | |||
58 | // Returns the window's screen, cast into the correct class. | ||
59 | const OpenGLScreen &OpenGLWindow::openGLScreen() const { | ||
60 | static const OpenGLScreen &s = dynamic_cast<const OpenGLScreen&>(screen()); | ||
61 | return s; | ||
62 | } | ||
63 | |||
64 | |||
65 | //--- WINDOW UPDATE FUNCTIONS -------------------------------------------------- | ||
66 | |||
67 | // Updates the window's contents. | ||
68 | void OpenGLWindow::updateContents() { | ||
69 | updateContentPixmap(); | ||
70 | if (contentPixmap()) { | ||
71 | m_content_tex_partition->setPixmap(contentPixmap(), false, realWidth(), realHeight(), depth()); | ||
72 | } | ||
73 | |||
74 | if (clipShapeChanged()) { | ||
75 | updateShape(); | ||
76 | } | ||
77 | |||
78 | clearDamage(); | ||
79 | } | ||
80 | |||
81 | // Updates window's geometry. | ||
82 | void OpenGLWindow::updateGeometry() { | ||
83 | BaseCompWindow::updateGeometry(); | ||
84 | updateWindowPos(); | ||
85 | } | ||
86 | |||
87 | // Updates the window's shape. | ||
88 | void OpenGLWindow::updateShape() { | ||
89 | BaseCompWindow::updateShape(); | ||
90 | |||
91 | Pixmap shape_pixmap = XCreatePixmap(display(), window(), realWidth(), realHeight(), depth()); | ||
92 | |||
93 | GC gc = XCreateGC(display(), shape_pixmap, 0, 0); | ||
94 | XSetGraphicsExposures(display(), gc, False); | ||
95 | XSetPlaneMask(display(), gc, 0xffffffff); | ||
96 | |||
97 | XSetForeground(display(), gc, 0x00000000); | ||
98 | XFillRectangle(display(), shape_pixmap, gc, 0, 0, realWidth(), realHeight()); | ||
99 | |||
100 | XSetForeground(display(), gc, 0xffffffff); | ||
101 | XSetClipRectangles(display(), gc, 0, 0, clipShapeRects(), clipShapeRectCount(), Unsorted); | ||
102 | XFillRectangle(display(), shape_pixmap, gc, 0, 0, realWidth(), realHeight()); | ||
103 | |||
104 | XFreeGC(display(), gc); | ||
105 | |||
106 | m_shape_tex_partition->setPixmap(shape_pixmap, true, realWidth(), realHeight(), depth()); | ||
107 | } | ||
108 | |||
109 | // Updates the window position vertex array. | ||
110 | void OpenGLWindow::updateWindowPos() { | ||
111 | m_window_pos_buffers = partitionSpaceToBuffers(openGLScreen(), x(), y(), realWidth(), realHeight()); | ||
112 | } | ||