osdWindow: relayout when scale factor changes

We currently rely on the "monitors-changed" signal of LayoutManager to
relayout the OSD window. That is not enough, since the scale factor also
changes the way the OSD window is sized, and that can be updated after
"monitors-changed" has been received.
The visual effect is that under some circumstances, the OSD window will
have the wrong size under HiDpi.

This commit fixes the issue by triggering another relayout when the
scale factor changes.

https://bugzilla.gnome.org/show_bug.cgi?id=772723
This commit is contained in:
Cosimo Cecchi 2016-10-10 16:56:35 -07:00
parent 6ebabd50c6
commit 4670db6629

View File

@ -109,8 +109,11 @@ const OsdWindow = new Lang.Class({
this._reset(); this._reset();
Main.layoutManager.connect('monitors-changed', Main.layoutManager.connect('monitors-changed',
Lang.bind(this, this._monitorsChanged)); Lang.bind(this, this._relayout));
this._monitorsChanged(); let themeContext = St.ThemeContext.get_for_stage(global.stage);
themeContext.connect('notify::scale-factor',
Lang.bind(this, this._relayout));
this._relayout();
Main.uiGroup.add_child(this.actor); Main.uiGroup.add_child(this.actor);
}, },
@ -188,7 +191,7 @@ const OsdWindow = new Lang.Class({
this.setLevel(null); this.setLevel(null);
}, },
_monitorsChanged: function() { _relayout: function() {
/* assume 110x110 on a 640x480 display and scale from there */ /* assume 110x110 on a 640x480 display and scale from there */
let monitor = Main.layoutManager.monitors[this._monitorIndex]; let monitor = Main.layoutManager.monitors[this._monitorIndex];
if (!monitor) if (!monitor)