[gnome-flashback] monitor: never return fractional scale values when NO_FRAC is used



commit 00e516fd31bc9b64c837d4f7ccd668b59c1548af
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Sep 12 23:15:32 2021 +0300

    monitor: never return fractional scale values when NO_FRAC is used
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/98f3f9697863

 backends/gf-monitor.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/backends/gf-monitor.c b/backends/gf-monitor.c
index bd5674c..5831150 100644
--- a/backends/gf-monitor.c
+++ b/backends/gf-monitor.c
@@ -1097,28 +1097,28 @@ gf_monitor_calculate_supported_scales (GfMonitor                 *monitor,
        i <= ceilf (MAXIMUM_SCALE_FACTOR);
        i++)
     {
-      for (j = 0; j < SCALE_FACTORS_PER_INTEGER; j++)
+      if (constraints & GF_MONITOR_SCALES_CONSTRAINT_NO_FRAC)
         {
-          gfloat scale;
-          gfloat scale_value = i + j * SCALE_FACTORS_STEPS;
-
-          if (constraints & GF_MONITOR_SCALES_CONSTRAINT_NO_FRAC)
+          if (is_scale_valid_for_size (width, height, i))
             {
-              if (fmodf (scale_value, 1.0) != 0.0f ||
-                  !is_scale_valid_for_size (width, height, scale_value))
-                continue;
-
-              scale = scale_value;
+              float scale = i;
+              g_array_append_val (supported_scales, scale);
             }
-          else
+        }
+      else
+        {
+          for (j = 0; j < SCALE_FACTORS_PER_INTEGER; j++)
             {
+              gfloat scale;
+              gfloat scale_value = i + j * SCALE_FACTORS_STEPS;
+
               scale = get_closest_scale_factor_for_resolution (width,
                                                                height,
                                                                scale_value);
-            }
 
-          if (scale > 0.0f)
-            g_array_append_val (supported_scales, scale);
+              if (scale > 0.0f)
+                g_array_append_val (supported_scales, scale);
+            }
         }
     }
 


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