[Xfce4-commits] <xfce4-settings:nick/xsettingsd-merge> Add debugging to pointers object.

Nick Schermer noreply at xfce.org
Fri Feb 25 10:08:03 CET 2011


Updating branch refs/heads/nick/xsettingsd-merge
         to 0efbc1c5f3aebd82bed8d8c9c39b6a4ba0b9a8d3 (commit)
       from 0930886db67fef51c21a2396d868f7c6dc4f16c3 (commit)

commit 0efbc1c5f3aebd82bed8d8c9c39b6a4ba0b9a8d3
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Feb 25 10:05:07 2011 +0100

    Add debugging to pointers object.

 xfsettingsd/debug.c    |    1 +
 xfsettingsd/debug.h    |    1 +
 xfsettingsd/pointers.c |   36 ++++++++++++++++++++++++------------
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/xfsettingsd/debug.c b/xfsettingsd/debug.c
index e25e686..a981719 100644
--- a/xfsettingsd/debug.c
+++ b/xfsettingsd/debug.c
@@ -39,6 +39,7 @@ static const GDebugKey dbg_keys[] =
     { "keyboard-shortcuts", XFSD_DEBUG_KEYBOARD_SHORTCUTS },
     { "workspaces", XFSD_DEBUG_WORKSPACES },
     { "accessibility", XFSD_DEBUG_ACCESSIBILITY },
+    { "pointers", XFSD_DEBUG_POINTERS },
 };
 
 
diff --git a/xfsettingsd/debug.h b/xfsettingsd/debug.h
index b32cbbe..2d30177 100644
--- a/xfsettingsd/debug.h
+++ b/xfsettingsd/debug.h
@@ -31,6 +31,7 @@ typedef enum
    XFSD_DEBUG_KEYBOARD_SHORTCUTS = 1 << 5,
    XFSD_DEBUG_WORKSPACES         = 1 << 6,
    XFSD_DEBUG_ACCESSIBILITY      = 1 << 7,
+   XFSD_DEBUG_POINTERS           = 1 << 8,
 }
 XfsdDebugDomain;
 
diff --git a/xfsettingsd/pointers.c b/xfsettingsd/pointers.c
index 6e37202..ac606a6 100644
--- a/xfsettingsd/pointers.c
+++ b/xfsettingsd/pointers.c
@@ -36,6 +36,7 @@
 #include <xfconf/xfconf.h>
 #include <libxfce4util/libxfce4util.h>
 
+#include "debug.h"
 #include "pointers.h"
 
 
@@ -70,7 +71,8 @@ static void             xfce_pointers_helper_change_button_mapping          (XDe
                                                                              gint                     reverse_scrolling);
 static gint             xfce_pointers_helper_gcd                            (gint                     num,
                                                                              gint                     denom);
-static void             xfce_pointers_helper_change_feedback                (XDevice                 *device,
+static void             xfce_pointers_helper_change_feedback                (XDeviceInfo             *device_info,
+                                                                             XDevice                 *device,
                                                                              Display                 *xdisplay,
                                                                              gint                     threshold,
                                                                              gdouble                  acceleration);
@@ -192,11 +194,11 @@ xfce_pointers_helper_change_button_mapping_swap (guchar   *buttonmap,
                                                  gboolean  reverse)
 {
     gint n;
-    gint id_a;
-    gint id_b;
+    gint id_a = -1;
+    gint id_b = -1;
 
     /* figure out the position of the id_1 and id_2 buttons in the map */
-    for (n = 0, id_a = id_b = -1; n < num_buttons; n++)
+    for (n = 0; n < num_buttons; n++)
     {
         if (buttonmap[n] == id_1)
             id_a = n;
@@ -283,11 +285,15 @@ xfce_pointers_helper_change_button_mapping (XDeviceInfo *device_info,
 
         /* set the new button mapping */
         gdk_error_trap_push ();
+
         XSetDeviceButtonMapping (xdisplay, device, buttonmap, num_buttons);
+
         if (gdk_error_trap_pop ())
           g_warning ("Failed to set button mapping");
 
-        /* cleanup */
+        xfsettings_dbg (XFSD_DEBUG_POINTERS, "[%s] new buttonmap is \"%s\"",
+                        device_info->name, buttonmap);
+
 out:    g_free (buttonmap);
     }
 }
@@ -305,10 +311,11 @@ xfce_pointers_helper_gcd (gint num,
 
 
 static void
-xfce_pointers_helper_change_feedback (XDevice *device,
-                                      Display *xdisplay,
-                                      gint     threshold,
-                                      gdouble  acceleration)
+xfce_pointers_helper_change_feedback (XDeviceInfo *device_info,
+                                      XDevice     *device,
+                                      Display     *xdisplay,
+                                      gint         threshold,
+                                      gdouble      acceleration)
 {
     XFeedbackState      *states, *pt;
     gint                 num_feedbacks;
@@ -359,6 +366,9 @@ xfce_pointers_helper_change_feedback (XDevice *device,
                 /* change feedback for this device */
                 XChangeFeedbackControl (xdisplay, device, mask, (XFeedbackControl *)(void *)&feedback);
 
+                xfsettings_dbg (XFSD_DEBUG_POINTERS, "[%s] change feedback (threshold=%d, accelNum=%d, accelDenom=%d)",
+                                device_info->name, feedback.threshold, feedback.accelNum, feedback.accelDenom);
+
                 /* done */
                 break;
             }
@@ -455,13 +465,15 @@ xfce_pointers_helper_restore_devices (XfcePointersHelper *helper,
                     threshold_str = g_strdup_printf ("/%s/Threshold", device_name);
                     acceleration_str = g_strdup_printf ("/%s/Acceleration", device_name);
 
+                    xfsettings_dbg (XFSD_DEBUG_POINTERS, "[%s] reset values", device_info->name);
+
                     /* restore the button mapping */
                     xfce_pointers_helper_change_button_mapping (device_info, device, xdisplay,
                                                                 xfconf_channel_get_bool (helper->channel, righthanded_str, TRUE) ? 1 : 0,
                                                                 xfconf_channel_get_bool (helper->channel, reverse_scrolling_str, FALSE) ? 1 : 0);
 
                     /* restore the pointer feedback */
-                    xfce_pointers_helper_change_feedback (device, xdisplay,
+                    xfce_pointers_helper_change_feedback (device_info, device, xdisplay,
                                                           xfconf_channel_get_int (helper->channel, threshold_str, -1),
                                                           xfconf_channel_get_double (helper->channel, acceleration_str, -1.00));
 
@@ -540,9 +552,9 @@ xfce_pointers_helper_channel_property_changed (XfconfChannel *channel,
                         else if (strcmp (names[1], "ReverseScrolling") == 0)
                             xfce_pointers_helper_change_button_mapping (device_info, device, xdisplay, -1, !!g_value_get_boolean (value));
                         else if (strcmp (names[1], "Threshold") == 0)
-                            xfce_pointers_helper_change_feedback (device, xdisplay, g_value_get_int (value), -2.00);
+                            xfce_pointers_helper_change_feedback (device_info, device, xdisplay, g_value_get_int (value), -2.00);
                         else if (strcmp (names[1], "Acceleration") == 0)
-                            xfce_pointers_helper_change_feedback (device, xdisplay, -2, g_value_get_double (value));
+                            xfce_pointers_helper_change_feedback (device_info, device, xdisplay, -2, g_value_get_double (value));
 
                         /* close the device */
                         XCloseDevice (xdisplay, device);



More information about the Xfce4-commits mailing list