[Xfce4-commits] <xfce4-settings:xfce-4.6> Improve error handling when setting the button map (part of bug #5004).
Nick Schermer
noreply at xfce.org
Sun Oct 11 14:26:02 CEST 2009
Updating branch refs/heads/xfce-4.6
to 49198c7b4559a61c3ca25e2e55789ed862cdbd0e (commit)
from 041cb4450d1d7c525c3fde20c38e293665619bd3 (commit)
commit 49198c7b4559a61c3ca25e2e55789ed862cdbd0e
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 b8718ba..37a0e5a 100644
--- a/xfce4-settings-helper/pointers.c
+++ b/xfce4-settings-helper/pointers.c
@@ -278,15 +278,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)
@@ -296,10 +302,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