[mutter] Filter mirrored monitors from the monitors list



commit c573523c4de8445d2579d094658c0e3c0142a374
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue May 3 13:04:01 2011 -0400

    Filter mirrored monitors from the monitors list
    
    For the purposes of window placement or arranging window manager or
    plugin controls, screens that are just mirrors of other screens should
    be ignored, so filter them out of the monitors list.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649299

 src/core/screen.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index cbfcdb8..4f73b9d 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -349,6 +349,43 @@ set_wm_icon_size_hint (MetaScreen *screen)
 #undef N_VALS
 }
 
+/* The list of monitors reported by the windowing system might include
+ * mirrored monitors with identical bounds. Since mirrored monitors
+ * shouldn't be treated as separate monitors for most purposes, we
+ * filter them out here. (We ignore the possibility of partially
+ * overlapping monitors because they are rare and it's hard to come
+ * up with any sensible interpretation.)
+ */
+static void
+filter_mirrored_monitors (MetaScreen *screen)
+{
+  int i, j;
+
+  /* Currently always true and simplifies things */
+  g_assert (screen->primary_monitor_index == 0);
+
+  for (i = 1; i < screen->n_monitor_infos; i++)
+    {
+      /* In case we've filtered previous monitors */
+      screen->monitor_infos[i].number = i;
+
+      for (j = 0; j < i; j++)
+        {
+          if (meta_rectangle_equal (&screen->monitor_infos[i].rect,
+                                    &screen->monitor_infos[j].rect))
+            {
+              memmove (&screen->monitor_infos[i],
+                       &screen->monitor_infos[i + 1],
+                       (screen->n_monitor_infos - i - 1) * sizeof (MetaMonitorInfo));
+              screen->n_monitor_infos--;
+              i--;
+
+              continue;
+            }
+        }
+    }
+}
+
 static void
 reload_monitor_infos (MetaScreen *screen)
 {
@@ -538,6 +575,8 @@ reload_monitor_infos (MetaScreen *screen)
       screen->monitor_infos[0].rect = screen->rect;
     }
 
+  filter_mirrored_monitors (screen);
+
   g_assert (screen->n_monitor_infos > 0);
   g_assert (screen->monitor_infos != NULL);
 }



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