[gnome-settings-daemon/randr-hotplug: 8/13] Configure outputs in the case of hotplug



commit 38c489ece8e8e9c20bfcd4f6dc4ff1ed174d7ce0
Author: Federico Mena Quintero <federico novell com>
Date:   Sat May 30 23:11:38 2009 -0500

    Configure outputs in the case of hotplug
    
    First we try to apply one of the saved configurations, to go back to a 'known good'
    state.
    
    If that doesn't work, we autoconfigure the outputs like 'xrandr --auto' does.  For now,
    this is just a stub function.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>
---
 plugins/xrandr/gsd-xrandr-manager.c |   38 +++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 68f1b42..2546296 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -904,6 +904,12 @@ refresh_tray_icon_menu_if_active (GsdXrandrManager *manager, guint32 timestamp)
 }
 
 static void
+auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp)
+{
+        /* FMQ: implement */
+}
+
+static void
 on_randr_event (GnomeRRScreen *screen, gpointer data)
 {
         GsdXrandrManager *manager = GSD_XRANDR_MANAGER (data);
@@ -925,12 +931,44 @@ on_randr_event (GnomeRRScreen *screen, gpointer data)
                  */
                 show_timestamps_dialog (manager, "ignoring since change > config");
         } else {
+                char *intended_filename;
+                GError *error;
+                gboolean success;
+
                 /* Here, config_timestamp >= change_timestamp.  This means that
                  * the screen got reconfigured because of hotplug/unplug; the X
                  * server is just notifying us, and we need to configure the
                  * outputs in a sane way.
                  */
                 show_timestamps_dialog (manager, "need to deal with reconfiguration, as config >= change");
+
+                intended_filename = gnome_rr_config_get_intended_filename ();
+
+                error = NULL;
+                success = apply_configuration_from_filename (manager, intended_filename, TRUE, config_timestamp, &error);
+                g_free (intended_filename);
+
+                if (!success) {
+                        /* We don't bother checking the error type.
+                         *
+                         * Both G_FILE_ERROR_NOENT and
+                         * GNOME_RR_ERROR_NO_MATCHING_CONFIG would mean, "there
+                         * was no configuration to apply, or none that matched
+                         * the current outputs", and in that case we need to run
+                         * our fallback.
+                         *
+                         * Any other error means "we couldn't do the smart thing
+                         * of using a previously- saved configuration, anyway,
+                         * for some other reason.  In that case, we also need to
+                         * run our fallback to avoid leaving the user with a
+                         * bogus configuration.
+                         */
+
+                        if (error)
+                                g_error_free (error);
+
+                        auto_configure_outputs (manager, config_timestamp);
+                }
         }
 
         refresh_tray_icon_menu_if_active (manager, MAX (change_timestamp, config_timestamp));



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