@@ -59,7 +59,7 @@ public class Display.VirtualMonitor : GLib.Object {
5959 }
6060 }
6161
62- /*
62+ /**
6363 * Used to distinguish two VirtualMonitors from each other.
6464 * We make up and ID by sum all hashes of
6565 * monitors that a VirtualMonitor has.
@@ -83,7 +83,7 @@ public class Display.VirtualMonitor : GLib.Object {
8383
8484 public bool is_active { get ; set ; default = true ; }
8585
86- /*
86+ /**
8787 * Get the first monitor of the list, handy in non-mirror context.
8888 */
8989 public Display . Monitor monitor {
@@ -119,23 +119,23 @@ public class Display.VirtualMonitor : GLib.Object {
119119 // mode when the monitor is re-activated
120120 foreach (var mode in monitor. modes) {
121121 if (mode. is_preferred) {
122- width = mode. width;
123- height = mode. height;
122+ width = apply_current_scale ( mode. width) ;
123+ height = apply_current_scale ( mode. height) ;
124124 return ;
125125 }
126126 }
127127
128128 // Last resort fallback if no preferred mode
129- width = 1280 ;
130- height = 720 ;
129+ width = apply_current_scale ( 1280 ) ;
130+ height = apply_current_scale ( 720 ) ;
131131 } else if (is_mirror) {
132132 var current_mode = monitors[0 ]. current_mode;
133- width = current_mode. width;
134- height = current_mode. height;
133+ width = apply_current_scale ( current_mode. width) ;
134+ height = apply_current_scale ( current_mode. height) ;
135135 } else {
136136 var current_mode = monitor. current_mode;
137- width = current_mode. width;
138- height = current_mode. height;
137+ width = apply_current_scale ( current_mode. width) ;
138+ height = apply_current_scale ( current_mode. height) ;
139139 }
140140 }
141141
@@ -211,4 +211,13 @@ public class Display.VirtualMonitor : GLib.Object {
211211
212212 return val. to_string ();
213213 }
214+
215+ /**
216+ * Apply scaling, to avoid gaps between virtual monitors in the configuration
217+ * @param dimension The monitor dimension to scale (width or height) by the current `scale` factor
218+ * @return the dimension scaled then rounded up and converted back to int
219+ */
220+ private int apply_current_scale (int dimension ) {
221+ return (int ) Math . ceil (dimension / scale);
222+ }
214223}
0 commit comments