diff --git a/resources/ui/window-row.ui b/resources/ui/window-row.ui index c4d8201c..2dee00bf 100644 --- a/resources/ui/window-row.ui +++ b/resources/ui/window-row.ui @@ -35,6 +35,21 @@ + + + + Opacity + The opacity of the selected window, useful if the application itself is opaque. + window_opacity + + + + center + true + + + + 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 254af245..3c99f3d1 100644 --- a/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml +++ b/schemas/org.gnome.shell.extensions.blur-my-shell.gschema.xml @@ -319,8 +319,8 @@ Wether or not to blur all applications by default - - [] + + {} List of applications to blur diff --git a/src/components/applications.js b/src/components/applications.js index b23eb589..3e68bcf8 100644 --- a/src/components/applications.js +++ b/src/components/applications.js @@ -170,20 +170,52 @@ export const ApplicationsBlur = class ApplicationsBlur { let whitelist = this.settings.applications.WHITELIST; let blacklist = this.settings.applications.BLACKLIST; + // the element describing the window in whitelist, or undefined + let whitelist_element = whitelist.find( + element => element.wm_class == window_wm_class + ); + // verify we are dealing with a real window + let is_a_window = [ + Meta.FrameType.NORMAL, + Meta.FrameType.DIALOG, + Meta.FrameType.MODAL_DIALOG + ].includes(meta_window.get_frame_type()) + this._log(`checking blur for ${pid}`); - // either the window is included in whitelist - if (window_wm_class !== "" - && ((enable_all && !blacklist.includes(window_wm_class)) - || (!enable_all && whitelist.includes(window_wm_class)) - ) - && [ - Meta.FrameType.NORMAL, - Meta.FrameType.DIALOG, - Meta.FrameType.MODAL_DIALOG - ].includes(meta_window.get_frame_type()) + // either the window is included in whitelist or not blacklisted + if ( + window_wm_class !== "" + && !enable_all + && whitelist_element + && is_a_window ) { - this._log(`application ${pid} listed, blurring it`); + this._log(`application ${pid} whitelisted, blurring it`); + + // get blur effect parameters + + let brightness, sigma; + + if (this.prefs.applications.CUSTOMIZE) { + brightness = this.prefs.applications.BRIGHTNESS; + sigma = this.prefs.applications.SIGMA; + } else { + brightness = this.prefs.BRIGHTNESS; + sigma = this.prefs.SIGMA; + } + + this.set_opacity(window_actor, whitelist_element.opacity); + + this.update_blur(pid, window_actor, meta_window, brightness, sigma); + } + + // or enable_all is on, and application is not on blacklist + else if ( + enable_all + && !(window_wm_class !== "" && blacklist.includes(window_wm_class)) + && is_a_window + ) { + this._log(`application ${pid} not blacklisted, blurring it`); // get blur effect parameters @@ -220,6 +252,13 @@ export const ApplicationsBlur = class ApplicationsBlur { } } + set_opacity(window_actor, opacity) { + window_actor.get_children().forEach(child => { + if (child.name !== "blur-actor") + child.opacity = opacity; + }); + } + /// When given the xprop property, returns the brightness and sigma values /// matching. If one of the two values is invalid, or missing, then it uses /// default values. @@ -448,6 +487,7 @@ export const ApplicationsBlur = class ApplicationsBlur { // create the actor let blur_actor = new Clutter.Actor({ + name: 'blur-actor', x: allocation.x, y: allocation.y, width: allocation.width, diff --git a/src/conveniences/keys.js b/src/conveniences/keys.js index 5a87ba44..a503d28e 100644 --- a/src/conveniences/keys.js +++ b/src/conveniences/keys.js @@ -81,7 +81,7 @@ export const Keys = [ { type: Type.I, name: "opacity" }, { type: Type.B, name: "blur-on-overview" }, { type: Type.B, name: "enable-all" }, - { type: Type.AS, name: "whitelist" }, + { type: Type.ASD, name: "whitelist" }, { type: Type.AS, name: "blacklist" }, ] }, diff --git a/src/conveniences/settings.js b/src/conveniences/settings.js index d2bef17a..bf6e4d16 100644 --- a/src/conveniences/settings.js +++ b/src/conveniences/settings.js @@ -9,7 +9,8 @@ export const Type = { D: 'Double', S: 'String', C: 'Color', - AS: 'StringArray' + AS: 'StringArray', + ASD: 'StringDoubleArray' }; /// An object to get and manage the gsettings preferences. @@ -118,6 +119,19 @@ export const Settings = class Settings { } }); break; + + case Type.ASD: + Object.defineProperty(component, property_name, { + get() { + let val = component_settings.get_value(key.name); + return val.recursiveUnpack(); + }, + set(v) { + let val = new GLib.Variant("aa{sd}", v); + component_settings.set_value(key.name, val); + } + }); + break; } component[property_name + '_reset'] = function () { diff --git a/src/preferences/applications.js b/src/preferences/applications.js index 6bac74c1..73de7cc7 100644 --- a/src/preferences/applications.js +++ b/src/preferences/applications.js @@ -109,7 +109,7 @@ export const Applications = GObject.registerClass({ add_widgets_from_lists() { this.preferences.applications.WHITELIST.forEach( - app_name => this.add_to_whitelist(app_name) + app => this.add_to_whitelist(app) ); this.preferences.applications.BLACKLIST.forEach( @@ -136,8 +136,8 @@ export const Applications = GObject.registerClass({ ); } - add_to_whitelist(app_name = null) { - let window_row = new WindowRow('whitelist', this, app_name); + add_to_whitelist(app = {}) { + let window_row = new WindowRow('whitelist', this, app.wm_class); this._whitelist.add(window_row); }