diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index c17dd0d45..4261653d7 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -36,6 +36,10 @@ #include "cc-night-light-dialog.h" #include "cc-display-resources.h" +/* The minimum supported size for the panel */ +#define MINIMUM_WIDTH 740 +#define MINIMUM_HEIGHT 530 + #define PANEL_PADDING 32 #define SECTION_PADDING 32 #define HEADING_PADDING 12 @@ -619,13 +623,30 @@ make_orientation_row (CcDisplayPanel *panel, CcDisplayMonitor *output) return row; } +static gboolean +display_mode_supported_at_scale (CcDisplayMode *mode, double scale) +{ + int width, height; + + cc_display_mode_get_resolution (mode, &width, &height); + + return width / scale >= MINIMUM_WIDTH && height / scale >= MINIMUM_HEIGHT; +} + static void resolution_row_activated (CcDisplayPanel *panel, GtkListBoxRow *row) { CcDisplayMode *mode = g_object_get_data (G_OBJECT (row), "mode"); + double scale = cc_display_monitor_get_scale (panel->current_output); cc_display_monitor_set_mode (panel->current_output, mode); + + /* Restore 1.0 scaling if the previous scale is not supported at the + * new resolution. */ + if (!display_mode_supported_at_scale (mode, scale)) + cc_display_monitor_set_scale (panel->current_output, 1.0); + update_apply_button (panel); } @@ -647,6 +668,10 @@ make_resolution_popover (CcDisplayPanel *panel) GtkWidget *row; GtkWidget *child; + /* Exclude unusable low resolutions */ + if (!display_mode_supported_at_scale (mode, 1.0)) + continue; + child = make_popover_label (get_resolution_string (mode)); gtk_widget_show (child); @@ -797,7 +822,7 @@ n_supported_scales (CcDisplayMode *mode) const double *scales = cc_display_mode_get_supported_scales (mode); guint n = 0; - while (scales[n] != 0.0) + while (scales[n] != 0.0 && display_mode_supported_at_scale (mode, scales[n])) n++; return n; @@ -890,6 +915,9 @@ setup_scale_buttons (GtkWidget *bbox, { GtkWidget *button, *label; + if (!display_mode_supported_at_scale (mode, *scale)) + continue; + button = gtk_radio_button_new_from_widget (group); gtk_widget_show (button); label = make_label_for_scale (*scale);