Skip to content

Commit

Permalink
Merge pull request #480 from aunetx/add-effects-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aunetx authored Oct 18, 2023
2 parents 768ecc1 + b62ebda commit 8459394
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 65 deletions.
5 changes: 2 additions & 3 deletions src/components/appfolders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const Tweener = imports.tweener.tweener;

const transparent = Clutter.Color.from_pixel(0x00000000);
const FOLDER_DIALOG_ANIMATION_TIME = 200;
const FRAME_UPDATE_PERIOD = 16;

const DIALOGS_STYLES = [
"",
Expand Down Expand Up @@ -122,7 +121,7 @@ let _zoomAndFadeOut = function () {


export const AppFoldersBlur = class AppFoldersBlur {
constructor(connections, settings) {
constructor(connections, settings, _) {
this.connections = connections;
this.paint_signals = new PaintSignals(connections);
this.settings = settings;
Expand Down Expand Up @@ -260,4 +259,4 @@ export const AppFoldersBlur = class AppFoldersBlur {
if (this.settings.DEBUG)
console.log(`[Blur my Shell > appfolders] ${str}`);
}
};
};
5 changes: 3 additions & 2 deletions src/components/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import { PaintSignals } from '../effects/paint_signals.js';
import { ApplicationsService } from '../dbus/services.js';


export const ApplicationsBlur = class ApplicationsBlur {
constructor(connections, settings) {
constructor(connections, settings, _) {
this.connections = connections;
this.settings = settings;
this.paint_signals = new PaintSignals(connections);
Expand Down Expand Up @@ -544,4 +545,4 @@ export const ApplicationsBlur = class ApplicationsBlur {
if (this.settings.DEBUG)
console.log(`[Blur my Shell > applications] ${str}`);
}
};
};
2 changes: 1 addition & 1 deletion src/components/dash_to_dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DashInfos {
}

export const DashBlur = class DashBlur {
constructor(connections, settings) {
constructor(connections, settings, _) {
this.dashes = [];
this.connections = connections;
this.settings = settings;
Expand Down
14 changes: 6 additions & 8 deletions src/components/lockscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as Background from 'resource:///org/gnome/shell/ui/background.js';
import { UnlockDialog } from 'resource:///org/gnome/shell/ui/unlockDialog.js';

import { ColorEffect } from '../effects/color_effect.js';
import { NoiseEffect } from '../effects/noise_effect.js';

let sigma;
let brightness;
let color;
Expand All @@ -20,9 +17,10 @@ const original_updateBackgroundEffects =


export const LockscreenBlur = class LockscreenBlur {
constructor(connections, settings) {
constructor(connections, settings, effects_manager) {
this.connections = connections;
this.settings = settings;
this.effects_manager = effects_manager;
}

enable() {
Expand Down Expand Up @@ -73,12 +71,12 @@ export const LockscreenBlur = class LockscreenBlur {
// store the scale in the effect in order to retrieve later
blur_effect.scale = monitor.geometry_scale;

let color_effect = new ColorEffect({
let color_effect = global.blur_my_shell._lockscreen_blur.effects_manager.new_color_effect({
name: 'color',
color: color
}, this.settings);

let noise_effect = new NoiseEffect({
let noise_effect = global.blur_my_shell._lockscreen_blur.effects_manager.new_noise_effect({
name: 'noise',
noise: noise,
lightness: lightness
Expand All @@ -101,8 +99,8 @@ export const LockscreenBlur = class LockscreenBlur {

_updateBackgroundEffects() {
for (const widget of this._backgroundGroup) {
const color_effect = widget.get_effect('blur');
const noise_effect = widget.get_effect('blur');
const color_effect = widget.get_effect('color');
const noise_effect = widget.get_effect('noise');
const blur_effect = widget.get_effect('blur');

if (color_effect)
Expand Down
36 changes: 18 additions & 18 deletions src/components/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import { WorkspaceAnimationController } from 'resource:///org/gnome/shell/ui/workspaceAnimation.js';
const wac_proto = WorkspaceAnimationController.prototype;

import { ColorEffect } from '../effects/color_effect.js';
import { NoiseEffect } from '../effects/noise_effect.js';

const OVERVIEW_COMPONENTS_STYLE = [
"",
"overview-components-light",
Expand All @@ -17,10 +14,11 @@ const OVERVIEW_COMPONENTS_STYLE = [


export const OverviewBlur = class OverviewBlur {
constructor(connections, settings) {
constructor(connections, settings, effects_manager) {
this.connections = connections;
this.effects = [];
this.settings = settings;
this.effects_manager = effects_manager;
this._workspace_switch_bg_actors = [];
this.enabled = false;
}
Expand Down Expand Up @@ -75,8 +73,8 @@ export const OverviewBlur = class OverviewBlur {
const w_m = global.workspace_manager;
const outer_this = this;

// create a blurred background actor for each monitor during a workspace
// switch
// create a blurred background actor for each monitor during a
// workspace switch
wac_proto._prepareWorkspaceSwitch = function (...params) {
outer_this._log("prepare workspace switch");
outer_this._original_PrepareSwitch.apply(this, params);
Expand Down Expand Up @@ -148,13 +146,7 @@ export const OverviewBlur = class OverviewBlur {

update_backgrounds() {
// remove every old background
Main.layoutManager.overviewGroup.get_children().forEach(actor => {
if (actor.constructor.name === 'Meta_BackgroundActor') {
Main.layoutManager.overviewGroup.remove_child(actor);
actor.destroy();
}
});
this.effects = [];
this.remove_background_actors();

// add new backgrounds
Main.layoutManager.monitors.forEach(monitor => {
Expand Down Expand Up @@ -203,13 +195,13 @@ export const OverviewBlur = class OverviewBlur {
// store the scale in the effect in order to retrieve it in set_sigma
blur_effect.scale = monitor.geometry_scale;

let color_effect = new ColorEffect({
let color_effect = this.effects_manager.new_color_effect({
color: this.settings.overview.CUSTOMIZE
? this.settings.overview.COLOR
: this.settings.COLOR
}, this.settings);

let noise_effect = new NoiseEffect({
let noise_effect = this.effects_manager.new_noise_effect({
noise: this.settings.overview.CUSTOMIZE
? this.settings.overview.NOISE_AMOUNT
: this.settings.NOISE_AMOUNT,
Expand Down Expand Up @@ -271,13 +263,22 @@ export const OverviewBlur = class OverviewBlur {
});
}

disable() {
this._log("removing blur from overview");
remove_background_actors() {
Main.layoutManager.overviewGroup.get_children().forEach(actor => {
if (actor.constructor.name === 'Meta_BackgroundActor') {
actor.get_effects().forEach(effect => {
this.effects_manager.remove(effect);
});
Main.layoutManager.overviewGroup.remove_child(actor);
actor.destroy();
}
});
this.effects = [];
}

disable() {
this._log("removing blur from overview");
this.remove_background_actors();
Main.uiGroup.remove_style_class_name("blurred-overview");
OVERVIEW_COMPONENTS_STYLE.forEach(
style => Main.uiGroup.remove_style_class_name(style)
Expand All @@ -293,7 +294,6 @@ export const OverviewBlur = class OverviewBlur {
wac_proto._finishWorkspaceSwitch = this._original_FinishSwitch;
}

this.effects = [];
this.connections.disconnect_all();
this.enabled = false;
}
Expand Down
40 changes: 30 additions & 10 deletions src/components/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import Mtk from 'gi://Mtk';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import { PaintSignals } from '../effects/paint_signals.js';
import { ColorEffect } from '../effects/color_effect.js';
import { NoiseEffect } from '../effects/noise_effect.js';

const DASH_TO_PANEL_UUID = '[email protected]';

const PANEL_STYLES = [
"transparent-panel",
"light-panel",
Expand All @@ -19,10 +16,11 @@ const PANEL_STYLES = [


export const PanelBlur = class PanelBlur {
constructor(connections, settings) {
constructor(connections, settings, effects_manager) {
this.connections = connections;
this.window_signal_ids = new Map();
this.settings = settings;
this.effects_manager = effects_manager;
this.actors_list = [];
this.enabled = false;
}
Expand Down Expand Up @@ -181,13 +179,13 @@ export const PanelBlur = class PanelBlur {
// store the scale in the effect in order to retrieve it in set_sigma
blur.scale = monitor.geometry_scale;

let color = new ColorEffect({
let color = this.effects_manager.new_color_effect({
color: this.settings.panel.CUSTOMIZE
? this.settings.panel.COLOR
: this.settings.COLOR
}, this.settings);

let noise = new NoiseEffect({
let noise = this.effects_manager.new_noise_effect({
noise: this.settings.panel.CUSTOMIZE
? this.settings.panel.NOISE_AMOUNT
: this.settings.NOISE_AMOUNT,
Expand Down Expand Up @@ -239,9 +237,9 @@ export const PanelBlur = class PanelBlur {

// reset widgets to right state
actors.widgets.background_parent.remove_child(actors.widgets.background);
actors.widgets.background.remove_effect(actors.effects.blur);
actors.widgets.background.remove_effect(actors.effects.color);
actors.widgets.background.remove_effect(actors.effects.noise);
this.effects_manager.remove(actors.effects.blur);
this.effects_manager.remove(actors.effects.color);
this.effects_manager.remove(actors.effects.noise);

// create new background actor
actors.widgets.background = is_static
Expand Down Expand Up @@ -642,21 +640,43 @@ export const PanelBlur = class PanelBlur {
});
}

// destroy every blurred background left, necessary after sleep
destroy_blur_effects() {
Main.panel?.get_parent()?.get_children().forEach(
child => {
if (child.name === 'topbar-blurred-background-parent') {
child.get_children().forEach(meta_background_actor => {
meta_background_actor.get_effects().forEach(effect => {
this.effects_manager.remove(effect);
});
});
child.destroy_all_children();
child.destroy();
}
}
);
}

disable() {
this._log("removing blur from top panel");

this.disconnect_from_windows_and_overview();

this.actors_list.forEach(actors => {
this.set_should_override_panel(actors, false);
this.effects_manager.remove(actors.effects.noise);
this.effects_manager.remove(actors.effects.color);
this.effects_manager.remove(actors.effects.blur);
try {
actors.widgets.panel_box.remove_child(
actors.widgets.background_parent
);
} catch (e) { }

actors.widgets.background_parent?.destroy();
});

this.destroy_blur_effects();

this.actors_list = [];

this.connections.disconnect_all();
Expand Down
14 changes: 7 additions & 7 deletions src/components/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import Shell from 'gi://Shell';
import Meta from 'gi://Meta';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import { ColorEffect } from '../effects/color_effect.js';
import { NoiseEffect } from '../effects/noise_effect.js';


export const ScreenshotBlur = class ScreenshotBlur {
constructor(connections, settings) {
constructor(connections, settings, effects_manager) {
this.connections = connections;
this.effects = [];
this.settings = settings;
this.effects_manager = effects_manager;
}

enable() {
Expand Down Expand Up @@ -94,13 +92,13 @@ export const ScreenshotBlur = class ScreenshotBlur {
// store the scale in the effect in order to retrieve it in set_sigma
blur_effect.scale = monitor.geometry_scale;

let color_effect = new ColorEffect({
let color_effect = this.effects_manager.new_color_effect({
color: this.settings.screenshot.CUSTOMIZE
? this.settings.screenshot.COLOR
: this.settings.COLOR
}, this.settings);

let noise_effect = new NoiseEffect({
let noise_effect = this.effects_manager.new_noise_effect({
noise: this.settings.screenshot.CUSTOMIZE
? this.settings.screenshot.NOISE_AMOUNT
: this.settings.NOISE_AMOUNT,
Expand Down Expand Up @@ -149,8 +147,10 @@ export const ScreenshotBlur = class ScreenshotBlur {

remove() {
Main.screenshotUI._windowSelectors.forEach(actor => {
if (actor._blur_actor)
if (actor._blur_actor) {
actor.remove_child(actor._blur_actor);
actor._blur_actor.destroy();
}
});
this.effects = [];
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/window_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import { PaintSignals } from '../effects/paint_signals.js';


export const WindowListBlur = class WindowListBlur {
constructor(connections, settings) {
constructor(connections, settings, _) {
this.connections = connections;
this.settings = settings;
this.paint_signals = new PaintSignals(connections);
Expand Down
Loading

0 comments on commit 8459394

Please sign in to comment.