[gnome-settings-daemon/randr-hotplug: 7/13] Optionally do not ignore GNOME_RR_ERROR_NO_MATCHING_CONFIG



commit 0d3e808fe6248f673929e9a423913ee40c339265
Author: Federico Mena Quintero <federico novell com>
Date:   Sat May 30 23:05:57 2009 -0500

    Optionally do not ignore GNOME_RR_ERROR_NO_MATCHING_CONFIG
    
    Normally this is not an error; it means that there was no stored configuration that
    matched the current set of outputs.  In that case, we ignore the error and return
    'success'.
    
    However, in the case where we are reconfiguring the outputs due to a RANDR hotplug event,
    we *do* need to know if there was no matching configuration, so that we can fall back
    to doing what 'xrandr --auto' does.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>
---
 plugins/xrandr/gsd-xrandr-manager.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 373bdf5..68f1b42 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -144,11 +144,15 @@ show_timestamps_dialog (GsdXrandrManager *manager, const char *msg)
 #endif
 }
 
-/* Filters out GNOME_RR_ERROR_NO_MATCHING_CONFIG from
+/* Optionally filters out GNOME_RR_ERROR_NO_MATCHING_CONFIG from
  * gnome_rr_config_apply_from_filename_with_time(), since that is not usually an error.
  */
 static gboolean
-apply_configuration_from_filename (GsdXrandrManager *manager, const char *filename, guint32 timestamp, GError **error)
+apply_configuration_from_filename (GsdXrandrManager *manager,
+                                   const char       *filename,
+                                   gboolean          no_matching_config_is_an_error,
+                                   guint32           timestamp,
+                                   GError          **error)
 {
         struct GsdXrandrManagerPrivate *priv = manager->priv;
         GError *my_error;
@@ -165,6 +169,9 @@ apply_configuration_from_filename (GsdXrandrManager *manager, const char *filena
                 return TRUE;
 
         if (g_error_matches (my_error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_MATCHING_CONFIG)) {
+                if (no_matching_config_is_an_error)
+                        goto fail;
+
                 /* This is not an error; the user probably changed his monitors
                  * and so they don't match any of the stored configurations.
                  */
@@ -172,6 +179,7 @@ apply_configuration_from_filename (GsdXrandrManager *manager, const char *filena
                 return TRUE;
         }
 
+fail:
         g_propagate_error (error, my_error);
         return FALSE;
 }
@@ -192,7 +200,7 @@ restore_backup_configuration (GsdXrandrManager *manager, const char *backup_file
                 GError *error;
 
                 error = NULL;
-                if (!apply_configuration_from_filename (manager, intended_filename, timestamp, &error)) {
+                if (!apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, &error)) {
                         error_message (manager, _("Could not restore the display's configuration"), error, NULL);
 
                         if (error)
@@ -336,7 +344,7 @@ try_to_apply_intended_configuration (GsdXrandrManager *manager, GdkWindow *paren
         backup_filename = gnome_rr_config_get_backup_filename ();
         intended_filename = gnome_rr_config_get_intended_filename ();
 
-        result = apply_configuration_from_filename (manager, intended_filename, timestamp, error);
+        result = apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, error);
         if (!result) {
                 error_message (manager, _("The selected configuration for displays could not be applied"), error ? *error : NULL, NULL);
                 restore_backup_configuration_without_messages (backup_filename, intended_filename);
@@ -1472,7 +1480,7 @@ apply_intended_configuration (GsdXrandrManager *manager, const char *intended_fi
         GError *my_error;
 
         my_error = NULL;
-        if (!apply_configuration_from_filename (manager, intended_filename, timestamp, &my_error)) {
+        if (!apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, &my_error)) {
                 if (my_error) {
                         if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
                                 error_message (manager, _("Could not apply the stored configuration for monitors"), my_error, NULL);
@@ -1501,7 +1509,7 @@ apply_stored_configuration_at_startup (GsdXrandrManager *manager, guint32 timest
 
         my_error = NULL;
 
-        success = apply_configuration_from_filename (manager, backup_filename, timestamp, &my_error);
+        success = apply_configuration_from_filename (manager, backup_filename, FALSE, timestamp, &my_error);
         if (success) {
                 /* The backup configuration existed, and could be applied
                  * successfully, so we must restore it on top of the



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