Changeset View
Changeset View
Standalone View
Standalone View
plugins/windowsystem/windowshadow.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "windowshadow.h" | ||||
22 | | ||||
23 | #include <QVariant> | ||||
24 | | ||||
25 | Q_DECLARE_METATYPE(QMargins) | ||||
26 | | ||||
27 | namespace KWin | ||||
28 | { | ||||
29 | | ||||
30 | bool WindowShadowTile::create() | ||||
31 | { | ||||
32 | return true; | ||||
33 | } | ||||
34 | | ||||
35 | void WindowShadowTile::destroy() | ||||
36 | { | ||||
37 | } | ||||
38 | | ||||
39 | bool WindowShadow::create() | ||||
40 | { | ||||
41 | // TODO: Perhaps we set way too many properties here. Alternatively we could put all shadow tiles | ||||
42 | // in one big image and attach it rather than 8 separate images. | ||||
43 | if (leftTile) { | ||||
44 | window->setProperty("kwin_shadow_left_tile", QVariant::fromValue(leftTile->image())); | ||||
45 | } | ||||
46 | if (topLeftTile) { | ||||
47 | window->setProperty("kwin_shadow_top_left_tile", QVariant::fromValue(topLeftTile->image())); | ||||
48 | } | ||||
49 | if (topTile) { | ||||
50 | window->setProperty("kwin_shadow_top_tile", QVariant::fromValue(topTile->image())); | ||||
51 | } | ||||
52 | if (topRightTile) { | ||||
53 | window->setProperty("kwin_shadow_top_right_tile", QVariant::fromValue(topRightTile->image())); | ||||
54 | } | ||||
55 | if (rightTile) { | ||||
56 | window->setProperty("kwin_shadow_right_tile", QVariant::fromValue(rightTile->image())); | ||||
57 | } | ||||
58 | if (bottomRightTile) { | ||||
59 | window->setProperty("kwin_shadow_bottom_right_tile", QVariant::fromValue(bottomRightTile->image())); | ||||
60 | } | ||||
61 | if (bottomTile) { | ||||
62 | window->setProperty("kwin_shadow_bottom_tile", QVariant::fromValue(bottomTile->image())); | ||||
63 | } | ||||
64 | if (bottomLeftTile) { | ||||
65 | window->setProperty("kwin_shadow_bottom_left_tile", QVariant::fromValue(bottomLeftTile->image())); | ||||
66 | } | ||||
67 | window->setProperty("kwin_shadow_padding", QVariant::fromValue(padding)); | ||||
68 | | ||||
69 | // Notice that the enabled property must be set last. | ||||
70 | window->setProperty("kwin_shadow_enabled", QVariant::fromValue(true)); | ||||
71 | | ||||
72 | return true; | ||||
73 | } | ||||
74 | | ||||
75 | void WindowShadow::destroy() | ||||
76 | { | ||||
77 | // Attempting to uninstall the shadow after the decorated window has been destroyed. It's doomed. | ||||
78 | if (!window) { | ||||
79 | return; | ||||
80 | } | ||||
81 | | ||||
82 | // Remove relevant shadow properties. | ||||
83 | window->setProperty("kwin_shadow_left_tile", {}); | ||||
84 | window->setProperty("kwin_shadow_top_left_tile", {}); | ||||
85 | window->setProperty("kwin_shadow_top_tile", {}); | ||||
86 | window->setProperty("kwin_shadow_top_right_tile", {}); | ||||
87 | window->setProperty("kwin_shadow_right_tile", {}); | ||||
88 | window->setProperty("kwin_shadow_bottom_right_tile", {}); | ||||
89 | window->setProperty("kwin_shadow_bottom_tile", {}); | ||||
90 | window->setProperty("kwin_shadow_bottom_left_tile", {}); | ||||
91 | window->setProperty("kwin_shadow_padding", {}); | ||||
92 | window->setProperty("kwin_shadow_enabled", {}); | ||||
93 | } | ||||
94 | | ||||
95 | } // namespace KWin |