[mutter] monitors: change find_primary to return an index



commit 5c9846c53ae695d188854d01f27957d607cdc900
Author: Dave Airlie <airlied redhat com>
Date:   Tue Mar 31 10:55:10 2015 +1000

    monitors: change find_primary to return an index
    
    This will make it easier to add tiling support.

 src/backends/meta-monitor-config.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/meta-monitor-config.c b/src/backends/meta-monitor-config.c
index c129c53..a03cc39 100644
--- a/src/backends/meta-monitor-config.c
+++ b/src/backends/meta-monitor-config.c
@@ -1074,12 +1074,12 @@ meta_monitor_config_apply_stored (MetaMonitorConfig  *self,
  * which are internal monitors), or failing that, the one with the
  * best resolution
  */
-static MetaOutput *
+static int
 find_primary_output (MetaOutput *outputs,
                      unsigned    n_outputs)
 {
   unsigned i;
-  MetaOutput *best;
+  int best;
   int best_width, best_height;
 
   g_assert (n_outputs >= 1);
@@ -1087,23 +1087,23 @@ find_primary_output (MetaOutput *outputs,
   for (i = 0; i < n_outputs; i++)
     {
       if (outputs[i].is_primary)
-        return &outputs[i];
+        return i;
     }
 
   for (i = 0; i < n_outputs; i++)
     {
       if (output_is_laptop (&outputs[i]))
-        return &outputs[i];
+        return i;
     }
 
-  best = NULL;
+  best = -1;
   best_width = 0; best_height = 0;
   for (i = 0; i < n_outputs; i++)
     {
       if (outputs[i].preferred_mode->width * outputs[i].preferred_mode->height >
           best_width * best_height)
         {
-          best = &outputs[i];
+          best = i;
           best_width = outputs[i].preferred_mode->width;
           best_height = outputs[i].preferred_mode->height;
         }
@@ -1141,7 +1141,7 @@ make_suggested_config (MetaMonitorConfig *self,
                        MetaConfiguration *config)
 {
   unsigned int i;
-  MetaOutput *primary;
+  int primary;
   GList *region = NULL;
 
   g_return_val_if_fail (config != NULL, FALSE);
@@ -1149,7 +1149,7 @@ make_suggested_config (MetaMonitorConfig *self,
 
   for (i = 0; i < n_outputs; i++)
     {
-      gboolean is_primary = (&outputs[i] == primary);
+      gboolean is_primary = ((int)i == primary);
 
       if (outputs[i].suggested_x < 0 || outputs[i].suggested_y < 0)
           return FALSE;
@@ -1184,7 +1184,7 @@ make_linear_config (MetaMonitorConfig *self,
                     int                max_height,
                     MetaConfiguration *config)
 {
-  MetaOutput *primary;
+  int primary;
   unsigned i;
   int x;
 
@@ -1192,10 +1192,10 @@ make_linear_config (MetaMonitorConfig *self,
 
   primary = find_primary_output (outputs, n_outputs);
 
-  x = primary->preferred_mode->width;
+  x = outputs[primary].preferred_mode->width;
   for (i = 0; i < n_outputs; i++)
     {
-      gboolean is_primary = (&outputs[i] == primary);
+      gboolean is_primary = ((int)i == primary);
 
       init_config_from_preferred_mode (&config->outputs[i], &outputs[i]);
       config->outputs[i].is_primary = is_primary;
@@ -1332,7 +1332,7 @@ ensure_at_least_one_output (MetaMonitorConfig  *self,
                             unsigned            n_outputs)
 {
   MetaConfiguration *config;
-  MetaOutput *primary;
+  int primary;
   unsigned i;
 
   /* Check that we have at least one active output */
@@ -1350,7 +1350,7 @@ ensure_at_least_one_output (MetaMonitorConfig  *self,
 
   for (i = 0; i < n_outputs; i++)
     {
-      gboolean is_primary = (&outputs[i] == primary);
+      gboolean is_primary = ((int)i == primary);
 
       if (is_primary)
         {


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