[gnome-control-center/benzea/fix-panel-size-check] display: Consider monitors in landscape mode for minimum size



commit 1f9d3c8692723947ab98695c7e52bdad90fb23cd
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Aug 12 11:43:30 2019 +0200

    display: Consider monitors in landscape mode for minimum size
    
    Some devices have panels with a native resolution in portrait mode. In
    these cases the monitor will likely be used in landscape mode.
    
    Accept the modes as if they are landscape rather than portrait. A
    further improvement would be to restrict the orientation setting.
    
    Fixes #639

 panels/display/cc-display-config-dbus.c | 9 +++++++--
 panels/display/cc-display-panel.c       | 5 ++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/panels/display/cc-display-config-dbus.c b/panels/display/cc-display-config-dbus.c
index 3a40ac783..81b2c46f7 100644
--- a/panels/display/cc-display-config-dbus.c
+++ b/panels/display/cc-display-config-dbus.c
@@ -1211,13 +1211,18 @@ is_scaled_mode_allowed (CcDisplayConfigDBus *self,
                         CcDisplayMode       *pmode,
                         double               scale)
 {
+  gint width, height;
   CcDisplayModeDBus *mode = CC_DISPLAY_MODE_DBUS (pmode);
 
   if (!cc_display_mode_dbus_is_supported_scale (pmode, scale))
     return FALSE;
 
-  return (round (mode->width / scale) >= self->min_width &&
-          round (mode->height / scale) >= self->min_height);
+  /* Do the math as if the monitor is always in landscape mode. */
+  width = round (mode->width / scale);
+  height = round (mode->height / scale);
+
+  return (MAX (width, height) >= self->min_width &&
+          MIN (width, height) >= self->min_height);
 }
 
 static gboolean
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 701728376..03dad5b27 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -40,7 +40,10 @@
 #include "cc-display-resources.h"
 #include "cc-display-settings.h"
 
-/* The minimum supported size for the panel */
+/* The minimum supported size for the panel
+ * Note that WIDTH is assumed to be the larger size and we accept portrait
+ * mode too effectively (in principle we should probably restrict the rotation
+ * setting in that case). */
 #define MINIMUM_WIDTH 740
 #define MINIMUM_HEIGHT 530
 


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