[Xfce4-commits] <xfce4-settings:master> Improve error handling when setting the button map (part of bug #5004).

Nick Schermer noreply at xfce.org
Sun Oct 11 14:26:05 CEST 2009


Updating branch refs/heads/master
         to 7bade5b2ab79b0c4ebacf2f0ad0edac61419c8c8 (commit)
       from 22bc922adac9f1d87dc5114ea4f65bc027932baa (commit)

commit 7bade5b2ab79b0c4ebacf2f0ad0edac61419c8c8
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Oct 11 13:54:44 2009 +0200

    Improve error handling when setting the button map (part of bug #5004).

 xfce4-settings-helper/pointers.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/xfce4-settings-helper/pointers.c b/xfce4-settings-helper/pointers.c
index aaa81ba..3813bc9 100644
--- a/xfce4-settings-helper/pointers.c
+++ b/xfce4-settings-helper/pointers.c
@@ -276,15 +276,21 @@ xfce_pointers_helper_change_button_mapping (XDeviceInfo *device_info,
         buttonmap = g_new0 (guchar, num_buttons);
 
         /* get the button mapping */
+        gdk_error_trap_push ();
         XGetDeviceButtonMapping (xdisplay, device, buttonmap, num_buttons);
+        if (gdk_error_trap_pop ())
+        {
+            g_warning ("Failed to get button mapping");
+            goto out;
+        }
 
         if (right_handed != -1)
         {
             /* get the right button number */
-            right_button = num_buttons < 3 ? 2 : 3;
+            right_button = MIN (num_buttons, 3);
 
             /* check the buttons and swap them if needed */
-            xfce_pointers_helper_change_button_mapping_swap (buttonmap, num_buttons, 1, right_button, !!right_handed);
+            xfce_pointers_helper_change_button_mapping_swap (buttonmap, num_buttons, 1, right_button, right_handed);
         }
 
         if (reverse_scrolling != -1 && num_buttons >= 5)
@@ -294,10 +300,13 @@ 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 */
-        g_free (buttonmap);
+out:    g_free (buttonmap);
     }
 }
 



More information about the Xfce4-commits mailing list