[gnome-settings-daemon] common: Refactor output-from-settings input device configuration.



commit 6597c3632f1617901a9ed6988136e8b426e6ca18
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Nov 10 15:24:40 2014 +0100

    common: Refactor output-from-settings input device configuration.
    
    The code that handled this when creating a GsdInputInfo and whenever
    the settings changed were almost the same, put it in a common place.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739891

 plugins/common/gsd-device-mapper.c |   58 ++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/plugins/common/gsd-device-mapper.c b/plugins/common/gsd-device-mapper.c
index 844e293..a1f1e45 100644
--- a/plugins/common/gsd-device-mapper.c
+++ b/plugins/common/gsd-device-mapper.c
@@ -921,25 +921,39 @@ input_info_update_capabilities (GsdInputInfo *info)
 }
 
 static void
+input_info_update_settings_output (GsdInputInfo *info)
+{
+       GsdOutputInfo *output = NULL;
+       GnomeRROutput *rr_output;
+
+       if (!info->settings || !info->mapper->rr_screen)
+               return;
+
+       rr_output = settings_get_display (info->settings, info->mapper);
+
+       if (rr_output)
+               output = g_hash_table_lookup (info->mapper->output_devices,
+                                             rr_output);
+
+       if (output == info->output)
+               return;
+
+       if (output) {
+               input_info_set_output (info, output, FALSE, FALSE);
+               input_info_remap (info);
+       } else {
+               /* Guess an output for this device */
+               mapper_recalculate_input (info->mapper, info);
+       }
+}
+
+static void
 device_settings_changed_cb (GSettings   *settings,
                            gchar        *key,
                            GsdInputInfo *input)
 {
        if (g_str_equal (key, KEY_DISPLAY)) {
-               GnomeRROutput *rr_output;
-               GsdOutputInfo *output;
-
-               rr_output = settings_get_display (settings, input->mapper);
-
-               if (rr_output) {
-                       output = g_hash_table_lookup (input->mapper->output_devices,
-                                                     rr_output);
-                       input_info_set_output (input, output, FALSE, FALSE);
-                       input_info_remap (input);
-               } else if (input->mapper->rr_screen) {
-                       /* Guess an output for this device */
-                       mapper_recalculate_input (input->mapper, input);
-               }
+               input_info_update_settings_output (input);
        } else if (g_str_equal (key, KEY_ROTATION)) {
                /* Remap the device so the new rotation is applied */
                input_info_remap (input);
@@ -951,8 +965,6 @@ input_info_new (GdkDevice   *device,
                GSettings       *settings,
                GsdDeviceMapper *mapper)
 {
-       GnomeRROutput *rr_output = NULL;
-       GsdOutputInfo *output = NULL;
        GsdInputInfo *info;
 
        info = g_new0 (GsdInputInfo, 1);
@@ -964,22 +976,10 @@ input_info_new (GdkDevice *device,
                info->changed_id = g_signal_connect (info->settings, "changed",
                                                     G_CALLBACK (device_settings_changed_cb),
                                                     info);
-
-               /* Assign output from config */
-               if (mapper->rr_screen)
-                       rr_output = settings_get_display (settings, mapper);
        }
 
        input_info_update_capabilities (info);
-
-       if (rr_output) {
-               output = g_hash_table_lookup (mapper->output_devices,
-                                             rr_output);
-               input_info_set_output (info, output, FALSE, FALSE);
-               input_info_remap (info);
-       } else if (mapper->rr_screen) {
-               mapper_recalculate_input (mapper, info);
-       }
+       input_info_update_settings_output (info);
 
        return info;
 }


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