summaryrefslogtreecommitdiff
path: root/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/WindowBlur.qml
blob: 3b45212b89d70834df6fdc032f96c7ff5d10167d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import QtQuick
import qs.Services

Item {
    id: root

    visible: false

    required property var targetWindow
    property var blurItem: null
    property real blurX: 0
    property real blurY: 0
    property real blurWidth: 0
    property real blurHeight: 0
    property real blurRadius: 0

    property var _region: null

    function _apply() {
        if (!BlurService.enabled || !targetWindow) {
            _cleanup();
            return;
        }

        if (!_region)
            _region = BlurService.createBlurRegion(targetWindow);

        if (!_region)
            return;

        _region.item = Qt.binding(() => root.blurItem);
        _region.x = Qt.binding(() => root.blurX);
        _region.y = Qt.binding(() => root.blurY);
        _region.width = Qt.binding(() => root.blurWidth);
        _region.height = Qt.binding(() => root.blurHeight);
        _region.radius = Qt.binding(() => root.blurRadius);
    }

    function _cleanup() {
        if (!_region)
            return;
        BlurService.destroyBlurRegion(targetWindow, _region);
        _region = null;
    }

    Connections {
        target: BlurService
        function onEnabledChanged() {
            root._apply();
        }
    }

    Connections {
        target: root.targetWindow
        function onVisibleChanged() {
            if (root.targetWindow && root.targetWindow.visible) {
                root._region = null;
                root._apply();
            }
        }
    }

    Component.onCompleted: _apply()
    Component.onDestruction: _cleanup()
}