aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/XRenderWindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbcompose/XRenderWindow.cc')
-rw-r--r--util/fbcompose/XRenderWindow.cc105
1 files changed, 105 insertions, 0 deletions
diff --git a/util/fbcompose/XRenderWindow.cc b/util/fbcompose/XRenderWindow.cc
new file mode 100644
index 0000000..eb4d672
--- /dev/null
+++ b/util/fbcompose/XRenderWindow.cc
@@ -0,0 +1,105 @@
1/** XRenderWindow.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 "XRenderWindow.hh"
25
26#include "Atoms.hh"
27#include "Logging.hh"
28#include "XRenderScreen.hh"
29
30using namespace FbCompositor;
31
32
33//--- CONSTRUCTORS AND DESTRUCTORS ---------------------------------------------
34
35// Constructor.
36XRenderWindow::XRenderWindow(const XRenderScreen &screen, Window window_xid, const char *pict_filter) :
37 BaseCompWindow(static_cast<const BaseScreen&>(screen), window_xid, false),
38 m_pict_filter(pict_filter) {
39
40 XRenderPictFormat *content_pict_format = XRenderFindVisualFormat(display(), visual());
41 m_content_picture = new XRenderPicture(screen, content_pict_format, m_pict_filter);
42
43 XRenderPictFormat *mask_pict_format = XRenderFindStandardFormat(display(), PictStandardARGB32);
44 m_mask_picture = new XRenderPicture(screen, mask_pict_format, m_pict_filter);
45}
46
47// Destructor.
48XRenderWindow::~XRenderWindow() { }
49
50
51//--- WINDOW MANIPULATION ------------------------------------------------------
52
53// Update the window's contents.
54void XRenderWindow::updateContents() {
55 updateContentPixmap();
56 if (contentPixmap()) {
57 XRenderPictureAttributes pa;
58 pa.subwindow_mode = IncludeInferiors;
59 long pa_mask = CPSubwindowMode;
60
61 m_content_picture->setPictFormat(XRenderFindVisualFormat(display(), visual()));
62 m_content_picture->setPixmap(contentPixmap(), false, pa, pa_mask);
63 }
64
65 if (clipShapeChanged()) {
66 updateShape();
67 }
68
69 clearDamage();
70}
71
72// Update window's property.
73void XRenderWindow::updateProperty(Atom property, int state) {
74 BaseCompWindow::updateProperty(property, state);
75
76 if (property == Atoms::opacityAtom()) {
77 updateMaskPicture();
78 }
79}
80
81
82//--- PROTECTED WINDOW MANIPULATION --------------------------------------------
83
84// Update the window's clip shape.
85void XRenderWindow::updateShape() {
86 BaseCompWindow::updateShape();
87 updateMaskPicture();
88}
89
90
91//--- INTERNAL FUNCTIONS -------------------------------------------------------
92
93// Update the window's mask picture.
94void XRenderWindow::updateMaskPicture() {
95 if ((m_mask_picture->pictureHandle() == None) || isResized()) {
96 Pixmap mask_pixmap = XCreatePixmap(display(), window(), realWidth(), realHeight(), 32);
97 m_mask_picture->setPixmap(mask_pixmap, true);
98 }
99
100 XRenderColor color = { 0, 0, 0, 0 };
101 XRenderFillRectangle(display(), PictOpSrc, m_mask_picture->pictureHandle(), &color, 0, 0, realWidth(), realHeight());
102
103 color.alpha = (unsigned long)((alpha() * 0xffff) / 255.0);
104 XRenderFillRectangles(display(), PictOpSrc, m_mask_picture->pictureHandle(), &color, clipShapeRects(), clipShapeRectCount());
105}