[gnome-settings-daemon/gnome-3-0] mouse: Clean up error handling
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-0] mouse: Clean up error handling
- Date: Tue, 3 May 2011 16:17:51 +0000 (UTC)
commit 80057f64736ba5a91cee310387e2ef35c0790059
Author: Bastien Nocera <hadess hadess net>
Date: Tue May 3 17:11:19 2011 +0100
mouse: Clean up error handling
And make sure that we pair gdk_error_traps properly.
plugins/mouse/gsd-mouse-manager.c | 57 +++++++++++++++++++------------------
1 files changed, 29 insertions(+), 28 deletions(-)
---
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 869a6de..cccc00f 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -348,7 +348,7 @@ set_left_handed (GsdMouseManager *manager,
return;
xdevice = open_gdk_device (device);
- if (!xdevice)
+ if (xdevice == NULL)
return;
/* If the device is a touchpad, swap tap buttons
@@ -485,6 +485,7 @@ set_middle_button (GsdMouseManager *manager,
int format;
unsigned long nitems, bytes_after;
unsigned char *data;
+ int rc;
prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
"Evdev Middle Button Emulation", True);
@@ -498,26 +499,23 @@ set_middle_button (GsdMouseManager *manager,
gdk_error_trap_push ();
- XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
xdevice, prop, 0, 1, False, XA_INTEGER, &type, &format,
&nitems, &bytes_after, &data);
- if ((gdk_error_trap_pop () != 0)) {
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
- return;
- }
-
- if (format == 8 && type == XA_INTEGER && nitems == 1) {
+ if (rc == Success && format == 8 && type == XA_INTEGER && nitems == 1) {
data[0] = middle_button ? 1 : 0;
- gdk_error_trap_push ();
XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
xdevice, prop, type, format, PropModeReplace, data, nitems);
-
- gdk_error_trap_pop_ignored ();
}
- XFree (data);
+ if (gdk_error_trap_pop ())
+ g_warning ("Error in setting middle button emulation on \"%s\"", gdk_device_get_name (device));
+
+ if (rc == Success)
+ XFree (data);
+
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
}
@@ -600,10 +598,11 @@ set_tap_to_click (GdkDevice *device,
if (rc == Success)
XFree (data);
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
- if (gdk_error_trap_pop ()) {
+
+ if (gdk_error_trap_pop ())
g_warning ("Error in setting tap to click on \"%s\"", gdk_device_get_name (device));
- }
+
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
}
static void
@@ -659,11 +658,14 @@ set_horiz_scroll (GdkDevice *device,
PropModeReplace, data, nitems);
}
- XFree (data);
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
-
if (gdk_error_trap_pop ())
g_warning ("Error in setting horiz scroll on \"%s\"", gdk_device_get_name (device));
+
+ if (rc == Success)
+ XFree (data);
+
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
+
}
static void
@@ -719,11 +721,13 @@ set_edge_scroll (GdkDevice *device,
PropModeReplace, data, nitems);
}
- XFree (data);
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
-
if (gdk_error_trap_pop ())
g_warning ("Error in setting edge scroll on \"%s\"", gdk_device_get_name (device));
+
+ if (rc == Success)
+ XFree (data);
+
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
}
static void
@@ -752,14 +756,11 @@ set_touchpad_enabled (GdkDevice *device,
XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice,
prop_enabled, XA_INTEGER, 8,
PropModeReplace, &data, 1);
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
- gdk_flush ();
- if (gdk_error_trap_pop ()) {
- g_warning ("Error %s device \"%s\"",
- (state) ? "enabling" : "disabling",
- gdk_device_get_name (device));
- }
+ if (gdk_error_trap_pop ())
+ g_warning ("Error %s device \"%s\"", (state) ? "enabling" : "disabling", gdk_device_get_name (device));
+
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]