unlockDialog: Fix scale-factor handling on multihead

The blur effect needs to take the scale-factor into account, so we
listen for scale changes. However we set up the signal handler when
creating a background, which is repeated for each monitor, and every
time the monitor configuration changes. But we only disconnect the
last handler that was connected, and only when we are destroyed,
not when recreating backgrounds.

Fix this by splitting out updating the effect parameters to a separate
method that iterates over all backgrounds, so we can simply set up the
handler from the constructor.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1341
This commit is contained in:
Florian Müllner 2020-06-30 13:08:03 +02:00 committed by Georges Basile Stavracas Neto
parent 845122497b
commit 140ab4dec1

View File

@ -524,6 +524,10 @@ var UnlockDialog = GObject.registerClass({
this._bgManagers = [];
const themeContext = St.ThemeContext.get_for_stage(global.stage);
this._scaleChangedId = themeContext.connect('notify::scale-factor',
() => this._updateBackgroundEffects());
this._updateBackgrounds();
this._monitorsChangedId =
Main.layoutManager.connect('monitors-changed', this._updateBackgrounds.bind(this));
@ -626,6 +630,7 @@ var UnlockDialog = GObject.registerClass({
y: monitor.y,
width: monitor.width,
height: monitor.height,
effect: new Shell.BlurEffect({ name: 'blur' }),
});
let bgManager = new Background.BackgroundManager({
@ -637,19 +642,17 @@ var UnlockDialog = GObject.registerClass({
this._bgManagers.push(bgManager);
this._backgroundGroup.add_child(widget);
}
_updateBackgroundEffects() {
const themeContext = St.ThemeContext.get_for_stage(global.stage);
let effect = new Shell.BlurEffect({
for (const widget of this._backgroundGroup) {
widget.get_effect('blur').set({
brightness: BLUR_BRIGHTNESS,
sigma: BLUR_SIGMA * themeContext.scale_factor,
});
this._scaleChangedId = themeContext.connect('notify::scale-factor', () => {
effect.sigma = BLUR_SIGMA * themeContext.scale_factor;
});
widget.add_effect(effect);
}
}
_updateBackgrounds() {
@ -661,6 +664,7 @@ var UnlockDialog = GObject.registerClass({
for (let i = 0; i < Main.layoutManager.monitors.length; i++)
this._createBackground(i);
this._updateBackgroundEffects();
}
_ensureAuthPrompt() {