Skip to content

Commit 4e22c98

Browse files
committed
Avoid resetting rotation and scale on refresh rate modification
1 parent 8c425b4 commit 4e22c98

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎src/Objects/VirtualMonitor.vala‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ public class Display.VirtualMonitor : GLib.Object {
200200
}
201201
}
202202

203-
scale = current_mode.preferred_scale;
203+
// Set default scale if the current scale is not present anymore in the available ones
204+
if (!is_scale_available ()) {
205+
info ("Previous scaling is not present in the new availables scales, defaulting to the preferred one\n");
206+
scale = current_mode.preferred_scale;
207+
}
204208
}
205209

206210
public static string generate_id_from_monitors (MutterReadMonitorInfo[] infos) {
@@ -220,4 +224,18 @@ public class Display.VirtualMonitor : GLib.Object {
220224
private int apply_current_scale (int dimension) {
221225
return (int) Math.ceil (dimension / scale);
222226
}
227+
228+
/**
229+
* Check if the current scale value is available in current available scales
230+
* @return true if the current scale value is present in available_scales_store, false otherwise
231+
*/
232+
private bool is_scale_available () {
233+
for (uint i = available_scales_store.get_n_items (); i-- > 0; ) {
234+
var new_scale = (Scale) available_scales_store.get_item (i);
235+
if (new_scale != null && scale == new_scale.scale) {
236+
return true;
237+
}
238+
}
239+
return false;
240+
}
223241
}

‎src/Widgets/DisplayWidget.vala‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ public class Display.DisplayWidget : Gtk.Box {
423423
refresh_list_store.get_value (iter, RefreshColumns.VALUE, out val);
424424
Display.MonitorMode new_mode = (Display.MonitorMode) val;
425425
virtual_monitor.set_current_mode (new_mode);
426-
rotation_combobox.set_active (0);
427426
configuration_changed ();
428427
check_position ();
429428
}

0 commit comments

Comments
 (0)