| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2009 Marco Martin <notmart@gmail.com> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KWINDOWEFFECTS_H |
| 8 | #define KWINDOWEFFECTS_H |
| 9 | |
| 10 | #include "kwindowsystem_export.h" |
| 11 | #include <optional> |
| 12 | |
| 13 | #include <QWidgetList> // for WId, etc. |
| 14 | |
| 15 | #include <QColor> |
| 16 | #include <QRegion> |
| 17 | |
| 18 | /*! |
| 19 | * \namespace KWindowEffects |
| 20 | * \inmodule KWindowSystem |
| 21 | * \brief Namespace for common standardized window effects. |
| 22 | */ |
| 23 | namespace KWindowEffects |
| 24 | { |
| 25 | /*! |
| 26 | * \value Slide |
| 27 | * \value BlurBehind |
| 28 | * \value BackgroundContrast |
| 29 | */ |
| 30 | enum Effect { |
| 31 | Slide = 1, |
| 32 | BlurBehind = 7, |
| 33 | BackgroundContrast = 9, |
| 34 | }; |
| 35 | |
| 36 | /*! |
| 37 | * \value NoEdge |
| 38 | * \value TopEdge |
| 39 | * \value RightEdge |
| 40 | * \value BottomEdge |
| 41 | * \value LeftEdge |
| 42 | */ |
| 43 | enum SlideFromLocation { |
| 44 | NoEdge = 0, |
| 45 | TopEdge, |
| 46 | RightEdge, |
| 47 | BottomEdge, |
| 48 | LeftEdge, |
| 49 | }; |
| 50 | /*! |
| 51 | * Returns if an atom property is available |
| 52 | * |
| 53 | * \a effect the effect we want to check |
| 54 | */ |
| 55 | KWINDOWSYSTEM_EXPORT bool isEffectAvailable(Effect effect); |
| 56 | |
| 57 | /*! |
| 58 | * Instructs the window manager to blur the background |
| 59 | * in the specified region behind the given window. |
| 60 | * The given region will overwrite any previous blur-behind region. |
| 61 | * Passing a null region will enable the blur effect for the whole window. |
| 62 | * The region is relative to the top-left corner of the client area. |
| 63 | * |
| 64 | * If \a enable is \c false, blur will be disabled for the whole window |
| 65 | * (\a region is ignored). |
| 66 | * |
| 67 | * Note that you will usually want to set the region to the shape of the window, |
| 68 | * excluding any shadow or halo. |
| 69 | * |
| 70 | * \a window The window for which to enable the blur effect |
| 71 | * |
| 72 | * \a enable Enable the effect if \c true, disable it if \c false |
| 73 | * |
| 74 | * \a region The region within the window where the background will be blurred, specified in logical pixels |
| 75 | * |
| 76 | * \since 5.82 |
| 77 | */ |
| 78 | KWINDOWSYSTEM_EXPORT void enableBlurBehind(QWindow *window, bool enable = true, const QRegion ®ion = QRegion()); |
| 79 | |
| 80 | /*! |
| 81 | * Instructs the window manager to modify the color of the background |
| 82 | * in the specified region behind the given window, |
| 83 | * in order to improve the contrast and readability of any text |
| 84 | * in the translucent window. |
| 85 | * The given region will overwrite any previous backgroundcontrast region. |
| 86 | * Passing a null region will enable the blur effect for the whole window. |
| 87 | * The region is relative to the top-left corner of the client area. |
| 88 | * |
| 89 | * If \a enable is \c false, blur will be disabled for the whole window |
| 90 | * (\a region is ignored). |
| 91 | * |
| 92 | * Note that you will usually want to set the region to the shape of the window, |
| 93 | * excluding any shadow or halo. |
| 94 | * |
| 95 | * \a window The window for which to enable the background contrast effect |
| 96 | * |
| 97 | * \a enable Enable the effect if \c true, disable it if \c false |
| 98 | * |
| 99 | * \a brightness How to modify the area brightness: from 0 (make it black) to 2 (make it white), 1 leaves it unchanged |
| 100 | * |
| 101 | * \a region The region within the window where the background will be modified, specified in logical pixels |
| 102 | * |
| 103 | * \since 5.82 |
| 104 | */ |
| 105 | KWINDOWSYSTEM_EXPORT void |
| 106 | enableBackgroundContrast(QWindow *window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion ®ion = QRegion()); |
| 107 | |
| 108 | /*! |
| 109 | * Mark a window as sliding from screen edge |
| 110 | * |
| 111 | * \a id of the window on which we want to apply the effect |
| 112 | * |
| 113 | * \a location edge of the screen from which we want the sliding effect. |
| 114 | * Desktop and Floating won't have effect. |
| 115 | * \a offset distance in pixels from the screen edge defined by location |
| 116 | * |
| 117 | * \since 5.82 |
| 118 | */ |
| 119 | KWINDOWSYSTEM_EXPORT void slideWindow(QWindow *window, SlideFromLocation location, int offset = -1); |
| 120 | } |
| 121 | |
| 122 | #endif |
| 123 | |