From 3f6ac171039b60fbb9c8011778d9817e86d9b00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Hamy?= Date: Sun, 18 Aug 2024 12:41:40 +0200 Subject: [PATCH] Begin working on opaque fullscreen window... ...but it does not work correctly. Moreover, "opacity" here is only "opaque window BUT with blur behind", so this is clearly not the right way to do things. --- resources/ui/applications.ui | 15 +++++++ ...shell.extensions.blur-my-shell.gschema.xml | 8 +++- src/components/applications.js | 39 ++++++++++++++----- src/conveniences/keys.js | 1 + src/extension.js | 10 +++-- src/preferences/applications.js | 5 +++ 6 files changed, 64 insertions(+), 14 deletions(-) diff --git a/resources/ui/applications.ui b/resources/ui/applications.ui index 452a6b6d..9beb69df 100644 --- a/resources/ui/applications.ui +++ b/resources/ui/applications.ui @@ -95,6 +95,21 @@ To get the best results possible, although with reduced performances, you can ch + + + Opaque fullscreen window + Makes fullscreen windows opaque, helping with legibility. + opaque_fullscreen_window + + + + + center + + + + + Blur on overview diff --git a/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml b/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml index 5708ca36..450014b0 100644 --- a/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml +++ b/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml @@ -149,7 +149,8 @@ 1 - Enum to select the style of the components in overview (0 not styled, 1 light, 2 dark, 3 transparent) + Enum to select the style of the components in overview (0 not styled, 1 light, 2 dark, 3 + transparent) @@ -391,6 +392,11 @@ true Wether or not to make the focused window opaque + + + false + Wether or not to make fullscreen windows opaque + false diff --git a/src/components/applications.js b/src/components/applications.js index e2a8bdf9..7cc82f78 100644 --- a/src/components/applications.js +++ b/src/components/applications.js @@ -145,6 +145,12 @@ export const ApplicationsBlur = class ApplicationsBlur { _ => this.check_blur(meta_window) ); + // update the blur when wm-class is changed + this.connections.connect( + meta_window, 'notify::fullscreen', + _ => this.update_opacity_for(meta_window, pid) + ); + // update the position and size when the window size changes this.connections.connect( meta_window, 'size-changed', @@ -310,7 +316,7 @@ export const ApplicationsBlur = class ApplicationsBlur { // if we remove the focus and have blur, show it and make the window transparent else if (blur_actor) { blur_actor.show(); - this.set_window_opacity(window_actor, this.settings.applications.OPACITY); + this.set_window_opacity(window_actor, this.get_opacity_for_window(meta_window)); } } @@ -346,16 +352,29 @@ export const ApplicationsBlur = class ApplicationsBlur { }); } - /// Update the opacity of all window actors. - set_opacity() { - let opacity = this.settings.applications.OPACITY; + /// Get the opacity for a given meta window; taking into account whether or it is fullscreen + /// and needs to be opaque. + get_opacity_for_window(meta_window) { + if (this.settings.applications.OPAQUE_FULLSCREEN_WINDOW && meta_window.fullscreen) + return 255; + else + return this.settings.applications.OPACITY; + } - this.meta_window_map.forEach(((meta_window, pid) => { - if (pid != this.focused_window_pid && meta_window.blur_actor) { - let window_actor = meta_window.get_compositor_private(); - this.set_window_opacity(window_actor, opacity); - } - })); + /// Update the opacity of a given window actor. + update_opacity_for(meta_window, pid) { + if (pid != this.focused_window_pid && meta_window.blur_actor) { + let window_actor = meta_window.get_compositor_private(); + let opacity = this.get_opacity_for_window(meta_window); + this.set_window_opacity(window_actor, opacity); + } + } + + /// Update the opacity of all window actors. + update_opacity() { + this.meta_window_map.forEach( + (meta_window, pid) => this.update_opacity_for(meta_window, pid) + ); } /// Compute the size and position for a blur actor. diff --git a/src/conveniences/keys.js b/src/conveniences/keys.js index 1e1dba84..0d3ac640 100644 --- a/src/conveniences/keys.js +++ b/src/conveniences/keys.js @@ -57,6 +57,7 @@ export const KEYS = [ { type: Type.D, name: "brightness" }, { type: Type.I, name: "opacity" }, { type: Type.B, name: "dynamic-opacity" }, + { type: Type.B, name: "opaque-fullscreen-window" }, { type: Type.B, name: "blur-on-overview" }, { type: Type.B, name: "enable-all" }, { type: Type.AS, name: "whitelist" }, diff --git a/src/extension.js b/src/extension.js index 443d7b6b..e963e46e 100644 --- a/src/extension.js +++ b/src/extension.js @@ -466,9 +466,7 @@ export default class BlurMyShell extends Extension { // application opacity changed this._settings.applications.OPACITY_changed(() => { if (this._settings.applications.BLUR) - this._applications_blur.set_opacity( - this._settings.applications.OPACITY - ); + this._applications_blur.update_opacity(); }); // application dynamic-opacity changed @@ -477,6 +475,12 @@ export default class BlurMyShell extends Extension { this._applications_blur.init_dynamic_opacity(); }); + // application opaque-fullscreen-window changed + this._settings.applications.OPAQUE_FULLSCREEN_WINDOW_changed(() => { + if (this._settings.applications.BLUR) + this._applications_blur.init_dynamic_opacity(); + }); + // application blur-on-overview changed this._settings.applications.BLUR_ON_OVERVIEW_changed(() => { if (this._settings.applications.BLUR) diff --git a/src/preferences/applications.js b/src/preferences/applications.js index 620d59e9..d2f958e9 100644 --- a/src/preferences/applications.js +++ b/src/preferences/applications.js @@ -34,6 +34,7 @@ export const Applications = GObject.registerClass({ 'brightness', 'opacity', 'dynamic_opacity', + 'opaque_fullscreen_window', 'blur_on_overview', 'enable_all', 'whitelist', @@ -60,6 +61,10 @@ export const Applications = GObject.registerClass({ 'dynamic-opacity', this._dynamic_opacity, 'active', Gio.SettingsBindFlags.DEFAULT ); + this.preferences.applications.settings.bind( + 'opaque-fullscreen-window', this._opaque_fullscreen_window, 'active', + Gio.SettingsBindFlags.DEFAULT + ); this.preferences.applications.settings.bind( 'blur-on-overview', this._blur_on_overview, 'active', Gio.SettingsBindFlags.DEFAULT