Skip to content

Commit 3f33900

Browse files
committed
Keep correct size on different scales
1 parent 3edfa28 commit 3f33900

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

background/BackgroundWindow.vala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
6161
can_focus = false;
6262
child = overlay;
6363

64-
child.realize.connect (connect_to_shell);
64+
child.realize.connect (() => {
65+
connect_to_shell ();
66+
get_surface ().notify["scale"].connect (setup_size);
67+
});
6568

6669
map.connect (() => {
6770
make_background (monitor_index);
@@ -89,9 +92,16 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
8992

9093
private void setup_size () {
9194
var monitor = Gdk.Display.get_default ().get_monitor_at_surface (get_surface ());
95+
var geom = monitor.get_geometry ();
96+
97+
/* First convert into physical size of the monitor */
98+
geom.width = (int) (geom.width * monitor.scale);
99+
geom.height = (int) (geom.height * monitor.scale);
92100

93-
width_request = monitor.geometry.width;
94-
height_request = monitor.geometry.height;
101+
/* Then convert into logical size as per surface scale. We do this because
102+
* for some reason surface scale doesn't have to equal monitor scale */
103+
default_width = width_request = (int) (geom.width / get_surface ().scale);
104+
default_height = height_request = (int) (geom.height / get_surface ().scale);
95105
}
96106

97107
public void set_background (Gdk.Paintable paintable) {

0 commit comments

Comments
 (0)