diff --git a/src/Objects/MonitorManager.vala b/src/Objects/MonitorManager.vala index 8524a56c..2c253beb 100644 --- a/src/Objects/MonitorManager.vala +++ b/src/Objects/MonitorManager.vala @@ -229,7 +229,7 @@ public class Display.MonitorManager : GLib.Object { } } - public void set_monitor_config () { + public void set_monitor_config () throws Error { MutterWriteLogicalMonitor[] logical_monitors = {}; foreach (var virtual_monitor in virtual_monitors) { if (virtual_monitor.is_active) { @@ -256,11 +256,7 @@ public class Display.MonitorManager : GLib.Object { } var properties = new GLib.HashTable (str_hash, str_equal); - try { - iface.apply_monitors_config (current_serial, MutterApplyMethod.PERSISTENT, logical_monitors, properties); - } catch (Error e) { - critical (e.message); - } + iface.apply_monitors_config (current_serial, MutterApplyMethod.PERSISTENT, logical_monitors, properties); } public static MutterWriteLogicalMonitor get_mutter_logical_monitor (Display.VirtualMonitor virtual_monitor) { @@ -335,7 +331,7 @@ public class Display.MonitorManager : GLib.Object { notify_property ("is-mirrored"); } - public void set_scale_on_all_monitors (double new_scale) { + public void set_scale_on_all_monitors (double new_scale) throws Error { if (new_scale <= 0.0) { return; } diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index d9fa8997..1485a827 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -107,14 +107,22 @@ public class Display.DisplaysView : Gtk.Box { detect_button.clicked.connect (() => displays_overlay.rescan_displays ()); apply_button.clicked.connect (() => { - monitor_manager.set_monitor_config (); + try { + monitor_manager.set_monitor_config (); + } catch (Error e) { + show_error_dialog (e.message); + } apply_button.sensitive = false; }); dpi_combo.active = (int)monitor_manager.virtual_monitors[0].scale - 1; dpi_combo.changed.connect (() => { - monitor_manager.set_scale_on_all_monitors ((double)(dpi_combo.active + 1)); + try { + monitor_manager.set_scale_on_all_monitors ((double)(dpi_combo.active + 1)); + } catch (Error e) { + show_error_dialog (e.message); + } }); mirror_switch.active = monitor_manager.is_mirrored; @@ -129,6 +137,17 @@ public class Display.DisplaysView : Gtk.Box { }); } + private void show_error_dialog (string details) { + var error_dialog = new Granite.MessageDialog.with_image_from_icon_name ( + _("Failed to apply display settings"), + _("This can be caused by an invalid configuration."), + "dialog-error" + ); + error_dialog.show_error_details (details); + error_dialog.response.connect (error_dialog.destroy); + error_dialog.present (); + } + private async void detect_accelerometer () { bool has_accelerometer = false;