[gnome-control-center/benzea/only-show-appliable-scales: 260/262] display: Use the new API to determine whether a scale is valid



commit 9e4c6e89a0525e7b6ba0d8bdf5b5c00a33a5a006
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Feb 22 15:44:18 2019 +0100

    display: Use the new API to determine whether a scale is valid

 panels/display/cc-display-panel.c    |  1 +
 panels/display/cc-display-settings.c | 20 ++++----------------
 2 files changed, 5 insertions(+), 16 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index b15a774f3..b13bb5975 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -870,6 +870,7 @@ reset_current_config (CcDisplayPanel *panel)
   panel->current_output = NULL;
 
   current = cc_display_config_manager_get_current (panel->manager);
+  cc_display_config_set_minimum_size (current, MINIMUM_WIDTH, MINIMUM_HEIGHT);
   panel->current_config = current;
 
   g_list_store_remove_all (panel->primary_display_list);
diff --git a/panels/display/cc-display-settings.c b/panels/display/cc-display-settings.c
index 6ab1ac832..a3f7ee171 100644
--- a/panels/display/cc-display-settings.c
+++ b/panels/display/cc-display-settings.c
@@ -27,10 +27,6 @@
 #include "cc-display-settings.h"
 #include "cc-display-config.h"
 
-/* The minimum supported size a monitor may have */
-#define MINIMUM_WIDTH 740
-#define MINIMUM_HEIGHT 530
-
 #define MAX_SCALE_BUTTONS 5
 
 struct _CcDisplaySettings
@@ -191,16 +187,6 @@ get_frequency_string (CcDisplayMode *mode)
   return g_strdup_printf (_("%.2lf Hz"), cc_display_mode_get_freq_f (mode));
 }
 
-static gboolean
-display_mode_supported_at_scale (CcDisplayMode *mode, double scale)
-{
-  int width, height;
-
-  cc_display_mode_get_resolution (mode, &width, &height);
-
-  return round (width / scale) >= MINIMUM_WIDTH && round (height / scale) >= MINIMUM_HEIGHT;
-}
-
 static double
 round_scale_for_ui (double scale)
 {
@@ -368,7 +354,7 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
       CcDisplayMode *mode = CC_DISPLAY_MODE (item->data);
 
       /* Exclude unusable low resolutions */
-      if (!display_mode_supported_at_scale (mode, 1.0))
+      if (!cc_display_config_is_scaled_mode_valid (self->config, mode, 1.0))
         continue;
 
       cc_display_mode_get_resolution (mode, &w, &h);
@@ -413,7 +399,9 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
           g_autofree gchar *scale_str = NULL;
           GtkWidget *scale_btn;
 
-          if (!display_mode_supported_at_scale (current_mode, *scale) &&
+          if (!cc_display_config_is_scaled_mode_valid (self->config,
+                                                       cc_display_monitor_get_mode (self->selected_output),
+                                                       *scale) &&
               cc_display_monitor_get_scale (self->selected_output) != *scale)
             continue;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]