File indexing completed on 2024-11-10 04:57:12
0001 /* 0002 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "windowshadow.h" 0008 0009 #include <QVariant> 0010 0011 Q_DECLARE_METATYPE(QMargins) 0012 0013 namespace KWin 0014 { 0015 0016 bool WindowShadowTile::create() 0017 { 0018 return true; 0019 } 0020 0021 void WindowShadowTile::destroy() 0022 { 0023 } 0024 0025 bool WindowShadow::create() 0026 { 0027 // TODO: Perhaps we set way too many properties here. Alternatively we could put all shadow tiles 0028 // in one big image and attach it rather than 8 separate images. 0029 if (leftTile) { 0030 window->setProperty("kwin_shadow_left_tile", QVariant::fromValue(leftTile->image())); 0031 } 0032 if (topLeftTile) { 0033 window->setProperty("kwin_shadow_top_left_tile", QVariant::fromValue(topLeftTile->image())); 0034 } 0035 if (topTile) { 0036 window->setProperty("kwin_shadow_top_tile", QVariant::fromValue(topTile->image())); 0037 } 0038 if (topRightTile) { 0039 window->setProperty("kwin_shadow_top_right_tile", QVariant::fromValue(topRightTile->image())); 0040 } 0041 if (rightTile) { 0042 window->setProperty("kwin_shadow_right_tile", QVariant::fromValue(rightTile->image())); 0043 } 0044 if (bottomRightTile) { 0045 window->setProperty("kwin_shadow_bottom_right_tile", QVariant::fromValue(bottomRightTile->image())); 0046 } 0047 if (bottomTile) { 0048 window->setProperty("kwin_shadow_bottom_tile", QVariant::fromValue(bottomTile->image())); 0049 } 0050 if (bottomLeftTile) { 0051 window->setProperty("kwin_shadow_bottom_left_tile", QVariant::fromValue(bottomLeftTile->image())); 0052 } 0053 window->setProperty("kwin_shadow_padding", QVariant::fromValue(padding)); 0054 0055 // Notice that the enabled property must be set last. 0056 window->setProperty("kwin_shadow_enabled", QVariant::fromValue(true)); 0057 0058 return true; 0059 } 0060 0061 void WindowShadow::destroy() 0062 { 0063 // Attempting to uninstall the shadow after the decorated window has been destroyed. It's doomed. 0064 if (!window) { 0065 return; 0066 } 0067 0068 // Remove relevant shadow properties. 0069 window->setProperty("kwin_shadow_left_tile", {}); 0070 window->setProperty("kwin_shadow_top_left_tile", {}); 0071 window->setProperty("kwin_shadow_top_tile", {}); 0072 window->setProperty("kwin_shadow_top_right_tile", {}); 0073 window->setProperty("kwin_shadow_right_tile", {}); 0074 window->setProperty("kwin_shadow_bottom_right_tile", {}); 0075 window->setProperty("kwin_shadow_bottom_tile", {}); 0076 window->setProperty("kwin_shadow_bottom_left_tile", {}); 0077 window->setProperty("kwin_shadow_padding", {}); 0078 window->setProperty("kwin_shadow_enabled", {}); 0079 } 0080 0081 } // namespace KWin