summaryrefslogtreecommitdiff
path: root/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/native_static_gaussian_blur.js
blob: cc7aa7bd318433d082ebb535a86bbfee07e92a7e (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
import GObject from 'gi://GObject';

import * as utils from '../conveniences/utils.js';
const St = await utils.import_in_shell_only('gi://St');
const Shell = await utils.import_in_shell_only('gi://Shell');

const DEFAULT_PARAMS = {
    unscaled_radius: 30, brightness: 0.6
};


export const NativeStaticBlurEffect = utils.IS_IN_PREFERENCES ?
    { default_params: DEFAULT_PARAMS } :
    new GObject.registerClass({
        GTypeName: "NativeStaticBlurEffect"
    }, class NativeStaticBlurEffect extends Shell.BlurEffect {
        constructor(params) {
            const normalized_params = { ...params };
            if (!('unscaled_radius' in normalized_params) && 'radius' in normalized_params)
                normalized_params.unscaled_radius = normalized_params.radius;
            delete normalized_params.radius;

            const {
                unscaled_radius: _unscaled_radius,
                brightness: _brightness,
                ...parent_params
            } = normalized_params;
            super({ ...parent_params, mode: Shell.BlurMode.ACTOR });

            this._theme_context = St.ThemeContext.get_for_stage(global.stage);
            this._theme_context.connectObject(
                'notify::scale-factor',
                _ => this.radius = Math.max(0.5, this.unscaled_radius * this._theme_context.scale_factor),
                this
            );

            utils.setup_params(this, normalized_params);
        }

        static get default_params() {
            return DEFAULT_PARAMS;
        }

        get unscaled_radius() {
            return this._unscaled_radius;
        }

        set unscaled_radius(value) {
            this._unscaled_radius = value;
            this.radius = Math.max(0.5, value * this._theme_context.scale_factor);
        }
    });