Skip to content

Commit

Permalink
Merge pull request #240 from IBBoard/IBBoard/BUG-239/Fix-lockscreen-d…
Browse files Browse the repository at this point in the history
…imming

Bug #239: fix lockscreen dimming
  • Loading branch information
neffo authored Sep 19, 2024
2 parents dbf1c90 + 22ce4a8 commit df89ae6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
7 changes: 4 additions & 3 deletions blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var shellVersionMajor = parseInt(Config.PACKAGE_VERSION.split('.')[0]);
var shellVersionMinor = parseInt(Config.PACKAGE_VERSION.split('.')[1]);
var shellVersionPoint = parseInt(Config.PACKAGE_VERSION.split('.')[2]);

var blurField = shellVersionMajor >= 46 ? "radius" : "sigma";
// default BWP mild blur
var BWP_BLUR_SIGMA = 2;
var BWP_BLUR_BRIGHTNESS = 55;
Expand Down Expand Up @@ -50,7 +51,7 @@ export function _updateBackgroundEffects_BWP(monitorIndex) {
if (effect) {
effect.set({ // GNOME defaults when login prompt is visible
brightness: BLUR_BRIGHTNESS,
sigma: BLUR_SIGMA * themeContext.scale_factor,
[blurField]: BLUR_SIGMA * themeContext.scale_factor,
});
}
}
Expand All @@ -59,7 +60,7 @@ export function _updateBackgroundEffects_BWP(monitorIndex) {
if (effect) {
effect.set({ // adjustable blur when clock is visible
brightness: BWP_BLUR_BRIGHTNESS * 0.01, // we use 0-100 rather than 0-1, so divide by 100
sigma: BWP_BLUR_SIGMA * themeContext.scale_factor,
[blurField]: BWP_BLUR_SIGMA * themeContext.scale_factor,
});
}
}
Expand Down Expand Up @@ -91,7 +92,7 @@ export function _clampValue(value) {
export default class Blur {
constructor() {
this.enabled = false;
log('Bing Wallpaper adjustable blur is '+supportedVersion()?'available':'not available');
log('Bing Wallpaper adjustable blur is '+(supportedVersion()?'available':'not available'));
}

set_blur_strength(value) {
Expand Down
39 changes: 28 additions & 11 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,21 @@ class BingWallpaperIndicator extends Button {

// listen for configuration changes
_setConnections() {
this._settings.connect('changed::hide', () => {
this.visible = !this._settings.get_boolean('hide');
});
this.settings_connections = [];

this.settings_connections.push(
this._settings.connect('changed::hide', () => {
this.visible = !this._settings.get_boolean('hide');
})
);

let settingConnections = [
{signal: 'changed::icon-name', call: this._setIcon},
{signal: 'changed::market', call: this._refresh},
{signal: 'changed::set-background', call: this._setBackground},
{signal: 'changed::override-lockscreen-blur', call: this._setBlur},
{signal: 'changed::lockscreen-blur-strength', call: this._setBlur},
{signal: 'changed::lockscreen-blur-brightness', call: this._setBlur},
{signal: 'changed::selected-image', call: this._setImage},
{signal: 'changed::delete-previous', call: this._cleanUpImages},
{signal: 'changed::notify', call: this._notifyCurrentImage},
Expand All @@ -244,11 +250,10 @@ class BingWallpaperIndicator extends Button {

// _setShuffleToggleState
settingConnections.forEach((e) => {
this._settings.connect(e.signal, e.call.bind(this));
this.settings_connections.push(
this._settings.connect(e.signal, e.call.bind(this))
);
});

this._settings.connect('changed::lockscreen-blur-strength', blur.set_blur_strength.bind(this, this._settings.get_int('lockscreen-blur-strength')));
this._settings.connect('changed::lockscreen-blur-brightness', blur.set_blur_brightness.bind(this, this._settings.get_int('lockscreen-blur-brightness')));

// ensure we're in a sensible initial state
this._setIcon();
Expand Down Expand Up @@ -282,10 +287,12 @@ class BingWallpaperIndicator extends Button {
/*{key: 'random-mode-include-only-unhidden', toggle: this.toggleShuffleOnlyUnhidden},*/
{key: 'random-mode-include-only-uhd', toggle: this.toggleShuffleOnlyUHD}];

toggles.forEach( (e) => {
this._settings.connect('changed::'+e.key, () => {
e.toggle.setToggleState(this._settings.get_boolean(e.key));
});
toggles.forEach( (e) => {
this.settings_connections.push(
this._settings.connect('changed::'+e.key, () => {
e.toggle.setToggleState(this._settings.get_boolean(e.key));
})
);
e.toggle.connect('toggled', (item, state) => {
this._settings.set_boolean(e.key, state);
});
Expand All @@ -302,6 +309,16 @@ class BingWallpaperIndicator extends Button {
}
}

_onDestroy() {
this._unsetConnections();
}

_unsetConnections() {
this.settings_connections.forEach((e) => {
this._settings.disconnect(e);
});
}

_openPrefs() {
this._extension.openPreferences();
}
Expand Down

0 comments on commit df89ae6

Please sign in to comment.