KWin
Loading...
Searching...
No Matches
shadow.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
6 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10#pragma once
11
12#include "kwin_export.h"
13
14#include <QImage>
15#include <QObject>
16#include <QRectF>
17
18#include <xcb/xcb.h>
19
20namespace KDecoration2
21{
22class Decoration;
23class DecorationShadow;
24}
25
26namespace KWin
27{
28
29class ShadowInterface;
30class Window;
31
47class KWIN_EXPORT Shadow : public QObject
48{
49 Q_OBJECT
50public:
51 explicit Shadow(Window *window);
52 ~Shadow() override;
53
63 bool updateShadow();
64
75 static std::unique_ptr<Shadow> createShadow(Window *window);
76
77 Window *window() const;
78
80 {
81 return m_decorationShadow != nullptr;
82 }
83 QImage decorationShadowImage() const;
84
85 std::weak_ptr<KDecoration2::DecorationShadow> decorationShadow() const
86 {
87 return m_decorationShadow;
88 }
89
101 QSize elementSize(ShadowElements element) const;
102
103 QRectF rect() const
104 {
105 return QRectF(QPoint(0, 0), m_cachedSize);
106 }
107 QMargins offset() const
108 {
109 return m_offset;
110 }
111 inline const QImage &shadowElement(ShadowElements element) const
112 {
113 return m_shadowElements[element];
114 }
115
116Q_SIGNALS:
120
121public Q_SLOTS:
122 void geometryChanged();
123
124private:
125 static std::unique_ptr<Shadow> createShadowFromX11(Window *window);
126 static std::unique_ptr<Shadow> createShadowFromDecoration(Window *window);
127 static std::unique_ptr<Shadow> createShadowFromWayland(Window *window);
128 static std::unique_ptr<Shadow> createShadowFromInternalWindow(Window *window);
129 static QList<uint32_t> readX11ShadowProperty(xcb_window_t id);
130 bool init(const QList<uint32_t> &data);
131 bool init(KDecoration2::Decoration *decoration);
132 bool init(const QPointer<ShadowInterface> &shadow);
133 bool init(const QWindow *window);
134 Window *m_window;
135 // shadow elements
136 QImage m_shadowElements[ShadowElementsCount];
137 // shadow offsets
138 QMargins m_offset;
139 // caches
140 QSizeF m_cachedSize;
141 // Decoration based shadows
142 std::shared_ptr<KDecoration2::DecorationShadow> m_decorationShadow;
143};
144
145}
Class representing a Window's Shadow to be rendered by the Compositor.
Definition shadow.h:48
QRectF rect() const
Definition shadow.h:103
bool hasDecorationShadow() const
Definition shadow.h:79
void textureChanged()
@ ShadowElementLeft
Definition shadow.h:97
@ ShadowElementTopRight
Definition shadow.h:92
@ ShadowElementBottomLeft
Definition shadow.h:96
@ ShadowElementBottomRight
Definition shadow.h:94
@ ShadowElementTopLeft
Definition shadow.h:98
@ ShadowElementRight
Definition shadow.h:93
@ ShadowElementTop
Definition shadow.h:91
@ ShadowElementBottom
Definition shadow.h:95
const QImage & shadowElement(ShadowElements element) const
Definition shadow.h:111
void rectChanged()
QMargins offset() const
Definition shadow.h:107
void offsetChanged()
std::weak_ptr< KDecoration2::DecorationShadow > decorationShadow() const
Definition shadow.h:85