All pastes #1283938 Raw Edit

unoverlap the monitors

public text v1 · immutable
#1283938 ·published 2008-12-12 22:46 UTC
rendered paste body
commit c03899e3069f538f048a6f5cfc836be2428bfe06
Author: Federico Mena Quintero <federico@novell.com>
Date:   Fri Dec 12 15:17:39 2008 -0600

    Un-overlap the monitors when turning off mirrored screens
    2008-12-12  Federico Mena Quintero  <federico@novell.com>
    
    	    * xrandr-capplet.c (on_clone_changed): If we turn off "mirror
    	    screens", and if the monitors are still overlapping, lay out the
    	    monitors from left to right so that the user will know that all
    	    the monitors are present.  Previously you had to know that you had
    	    to un-overlap them by hand.
    
    Signed-off-by: Federico Mena Quintero <federico@novell.com>

diff --git a/capplets/display/ChangeLog b/capplets/display/ChangeLog
index bb1b832..6c059cb 100644
--- a/capplets/display/ChangeLog
+++ b/capplets/display/ChangeLog
@@ -1,3 +1,11 @@
+2008-12-12  Federico Mena Quintero  <federico@novell.com>
+
+	* xrandr-capplet.c (on_clone_changed): If we turn off "mirror
+	screens", and if the monitors are still overlapping, lay out the
+	monitors from left to right so that the user will know that all
+	the monitors are present.  Previously you had to know that you had
+	to un-overlap them by hand.
+
 2008-12-03  Federico Mena Quintero  <federico@novell.com>
 
 	* xrandr-capplet.c (rebuild_rotation_combo): Pass a NULL error
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index a23bb00..d0b9242 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -62,6 +62,7 @@ struct App
 
 static void rebuild_gui (App *app);
 static void on_rate_changed (GtkComboBox *box, gpointer data);
+static gboolean output_overlaps (GnomeOutputInfo *output, GnomeRRConfig *config);
 
 static void
 error_message (App *app, const char *primary_text, const char *secondary_text)
@@ -669,6 +670,29 @@ on_clone_changed (GtkWidget *box, gpointer data)
 	    }
 	}
     }
+    else
+    {
+	if (output_overlaps (app->current_output, app->current_configuration))
+	{
+	    int i;
+	    int x;
+
+	    /* Lay out all the monitors horizontally when "mirror screens" is turned
+	     * off, to avoid having all of them overlapped initially.
+	     */
+
+	    x = 0;
+
+	    for (i = 0; app->current_configuration->outputs[i]; ++i)
+	    {
+		if (app->current_configuration->outputs[i]->connected) {
+		    app->current_configuration->outputs[i]->x = x;
+		    app->current_configuration->outputs[i]->y = 0;
+		    x += app->current_configuration->outputs[i]->width;
+		}
+	    }
+	}
+    }
 
     rebuild_gui (app);
 }