[gnome-settings-daemon] sm



commit 40ccae58b1b5e61c8f66f86230416929909d5aad
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 28 16:22:56 2014 +0200

    sm

 plugins/common/gsd-device-mapper.c |   38 ++++++++++++++++++++++++++---------
 plugins/common/gsd-input-helper.h  |    1 -
 2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/plugins/common/gsd-device-mapper.c b/plugins/common/gsd-device-mapper.c
index fa782aa..4808c6c 100644
--- a/plugins/common/gsd-device-mapper.c
+++ b/plugins/common/gsd-device-mapper.c
@@ -626,7 +626,8 @@ input_info_find_size_match (GsdInputInfo  *input,
                            GnomeRRScreen *rr_screen)
 {
        guint i, input_width, input_height, output_width, output_height;
-       GnomeRROutput **outputs;
+       gdouble min_width_diff, min_height_diff;
+       GnomeRROutput **outputs, *match = NULL;
 
        g_return_val_if_fail (rr_screen != NULL, NULL);
 
@@ -634,27 +635,44 @@ input_info_find_size_match (GsdInputInfo  *input,
                                     &input_width, &input_height))
                return NULL;
 
+       /* Restrict the matches to be below a narrow percentage */
+       min_width_diff = min_height_diff = 0.05;
+
        g_debug ("Input device '%s' has %dx%d mm",
                 gdk_device_get_name (input->device), input_width, input_height);
 
        outputs = gnome_rr_screen_list_outputs (rr_screen);
 
        for (i = 0; outputs[i] != NULL; i++) {
+               gdouble width_diff, height_diff;
+
                if (!output_get_dimensions (outputs[i], &output_width, &output_height))
                        continue;
 
-#define MAX_DIFF 0.05
-               if (ABS (1 - ((gdouble) output_width / input_width)) < MAX_DIFF &&
-                   ABS (1 - ((gdouble) output_height / input_height)) < MAX_DIFF) {
-                       g_debug ("Output device '%s' is considered a match with %dx%d mm",
-                                gnome_rr_output_get_name (outputs[i]),
-                                output_width, output_height);
-                       return outputs[i];
+               width_diff = ABS (1 - ((gdouble) output_width / input_width));
+               height_diff = ABS (1 - ((gdouble) output_height / input_height));
+
+               g_debug ("Output '%s' has size %dx%d mm, deviation from "
+                        "input device size: %.2f width, %.2f height ",
+                        gnome_rr_output_get_name (outputs[i]),
+                        output_width, output_height, width_diff, height_diff);
+
+               if (width_diff <= min_width_diff && height_diff <= min_height_diff) {
+                       match = outputs[i];
+                       min_width_diff = width_diff;
+                       min_height_diff = height_diff;
                }
-#undef MAX_DIFF
        }
 
-       return NULL;
+       if (match) {
+               g_debug ("Output '%s' is considered a best size match (%.2f / %.2f)",
+                        gnome_rr_output_get_name (match),
+                        min_width_diff, min_height_diff);
+       } else {
+               g_debug ("No input/output size match was found\n");
+       }
+
+       return match;
 }
 
 static void
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index ce07f7c..85e8492 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -87,7 +87,6 @@ void      xdevice_close      (XDevice                *xdevice);
 
 const char * xdevice_get_wacom_tool_type (int               deviceid);
 
-
 G_END_DECLS
 
 #endif /* __GSD_INPUT_HELPER_H */


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