KWin
Loading...
Searching...
No Matches
windowshadow.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6
7#include "windowshadow.h"
8
9#include <QVariant>
10
11Q_DECLARE_METATYPE(QMargins)
12
13namespace KWin
14{
15
17{
18 return true;
19}
20
24
26{
27 // TODO: Perhaps we set way too many properties here. Alternatively we could put all shadow tiles
28 // in one big image and attach it rather than 8 separate images.
29 if (leftTile) {
30 window->setProperty("kwin_shadow_left_tile", QVariant::fromValue(leftTile->image()));
31 }
32 if (topLeftTile) {
33 window->setProperty("kwin_shadow_top_left_tile", QVariant::fromValue(topLeftTile->image()));
34 }
35 if (topTile) {
36 window->setProperty("kwin_shadow_top_tile", QVariant::fromValue(topTile->image()));
37 }
38 if (topRightTile) {
39 window->setProperty("kwin_shadow_top_right_tile", QVariant::fromValue(topRightTile->image()));
40 }
41 if (rightTile) {
42 window->setProperty("kwin_shadow_right_tile", QVariant::fromValue(rightTile->image()));
43 }
44 if (bottomRightTile) {
45 window->setProperty("kwin_shadow_bottom_right_tile", QVariant::fromValue(bottomRightTile->image()));
46 }
47 if (bottomTile) {
48 window->setProperty("kwin_shadow_bottom_tile", QVariant::fromValue(bottomTile->image()));
49 }
50 if (bottomLeftTile) {
51 window->setProperty("kwin_shadow_bottom_left_tile", QVariant::fromValue(bottomLeftTile->image()));
52 }
53 window->setProperty("kwin_shadow_padding", QVariant::fromValue(padding));
54
55 // Notice that the enabled property must be set last.
56 window->setProperty("kwin_shadow_enabled", QVariant::fromValue(true));
57
58 return true;
59}
60
62{
63 // Attempting to uninstall the shadow after the decorated window has been destroyed. It's doomed.
64 if (!window) {
65 return;
66 }
67
68 // Remove relevant shadow properties.
69 window->setProperty("kwin_shadow_left_tile", {});
70 window->setProperty("kwin_shadow_top_left_tile", {});
71 window->setProperty("kwin_shadow_top_tile", {});
72 window->setProperty("kwin_shadow_top_right_tile", {});
73 window->setProperty("kwin_shadow_right_tile", {});
74 window->setProperty("kwin_shadow_bottom_right_tile", {});
75 window->setProperty("kwin_shadow_bottom_tile", {});
76 window->setProperty("kwin_shadow_bottom_left_tile", {});
77 window->setProperty("kwin_shadow_padding", {});
78 window->setProperty("kwin_shadow_enabled", {});
79}
80
81} // namespace KWin
bool create() override
void destroy() override
void destroy() override
bool create() override
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)