From 0677bc359a23115ac6f8b9a1af03095981d7ca19 Mon Sep 17 00:00:00 2001 From: flodavid Date: Sat, 21 Mar 2026 23:56:00 +0100 Subject: [PATCH 1/2] Apply scaling to virtual monitor reported size --- src/Objects/VirtualMonitor.vala | 29 +++++++++++++++++++---------- src/Widgets/DisplayWidget.vala | 2 ++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Objects/VirtualMonitor.vala b/src/Objects/VirtualMonitor.vala index 450add74..533db2b5 100644 --- a/src/Objects/VirtualMonitor.vala +++ b/src/Objects/VirtualMonitor.vala @@ -59,7 +59,7 @@ public class Display.VirtualMonitor : GLib.Object { } } - /* + /** * Used to distinguish two VirtualMonitors from each other. * We make up and ID by sum all hashes of * monitors that a VirtualMonitor has. @@ -83,7 +83,7 @@ public class Display.VirtualMonitor : GLib.Object { public bool is_active { get; set; default = true; } - /* + /** * Get the first monitor of the list, handy in non-mirror context. */ public Display.Monitor monitor { @@ -119,23 +119,23 @@ public class Display.VirtualMonitor : GLib.Object { // mode when the monitor is re-activated foreach (var mode in monitor.modes) { if (mode.is_preferred) { - width = mode.width; - height = mode.height; + width = scaled(mode.width); + height = scaled(mode.height); return; } } // Last resort fallback if no preferred mode - width = 1280; - height = 720; + width = scaled(1280); + height = scaled(720); } else if (is_mirror) { var current_mode = monitors[0].current_mode; - width = current_mode.width; - height = current_mode.height; + width = scaled(current_mode.width); + height = scaled(current_mode.height); } else { var current_mode = monitor.current_mode; - width = current_mode.width; - height = current_mode.height; + width = scaled(current_mode.width); + height = scaled(current_mode.height); } } @@ -211,4 +211,13 @@ public class Display.VirtualMonitor : GLib.Object { return val.to_string (); } + + /** + * Apply scaling, to avoid gaps between virtual monitors in the configuration + * @param dimension The monitor dimension to scale (width or height) by the current `scale` factor + * @return the dimension scaled then rounded up and converted back to int + */ + private int scaled (int dimension) { + return (int) Math.ceil (dimension / scale); + } } diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 2cbfbc5f..7346c388 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -433,7 +433,9 @@ public class Display.DisplayWidget : Gtk.Box { // Prevent breaking autohide by closing popover popover.popdown (); + virtual_monitor.get_current_mode_size (out real_height, out real_width); configuration_changed (); + check_position (); }); rotation_combobox.set_active ((int) virtual_monitor.transform); From 40bda0e4d27efee57fbaf5cf7a2d628583bdb8dc Mon Sep 17 00:00:00 2001 From: F David Date: Tue, 12 May 2026 15:55:24 +0200 Subject: [PATCH 2/2] Rename scaled to apply_current_scale --- src/Objects/VirtualMonitor.vala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Objects/VirtualMonitor.vala b/src/Objects/VirtualMonitor.vala index 533db2b5..a91d06a8 100644 --- a/src/Objects/VirtualMonitor.vala +++ b/src/Objects/VirtualMonitor.vala @@ -119,23 +119,23 @@ public class Display.VirtualMonitor : GLib.Object { // mode when the monitor is re-activated foreach (var mode in monitor.modes) { if (mode.is_preferred) { - width = scaled(mode.width); - height = scaled(mode.height); + width = apply_current_scale (mode.width); + height = apply_current_scale (mode.height); return; } } // Last resort fallback if no preferred mode - width = scaled(1280); - height = scaled(720); + width = apply_current_scale (1280); + height = apply_current_scale (720); } else if (is_mirror) { var current_mode = monitors[0].current_mode; - width = scaled(current_mode.width); - height = scaled(current_mode.height); + width = apply_current_scale (current_mode.width); + height = apply_current_scale (current_mode.height); } else { var current_mode = monitor.current_mode; - width = scaled(current_mode.width); - height = scaled(current_mode.height); + width = apply_current_scale (current_mode.width); + height = apply_current_scale (current_mode.height); } } @@ -217,7 +217,7 @@ public class Display.VirtualMonitor : GLib.Object { * @param dimension The monitor dimension to scale (width or height) by the current `scale` factor * @return the dimension scaled then rounded up and converted back to int */ - private int scaled (int dimension) { + private int apply_current_scale (int dimension) { return (int) Math.ceil (dimension / scale); } }