[mousetweaks] Check return values of gdk_error_trap_pop
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Check return values of gdk_error_trap_pop
- Date: Mon, 11 Oct 2010 10:57:28 +0000 (UTC)
commit 87eb80f566ca878a1f363236cd1c5f5eb88ac7f9
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Mon Oct 11 12:52:10 2010 +0200
Check return values of gdk_error_trap_pop
Adds 2 wrapper functions for gdk_error_trap_push/pop.
src/mt-common.c | 18 ++++++++++++++++++
src/mt-common.h | 3 +++
src/mt-listener.c | 16 +++++++---------
src/mt-main.c | 9 ++-------
4 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/src/mt-common.c b/src/mt-common.c
index b8b6482..d8cd642 100644
--- a/src/mt-common.c
+++ b/src/mt-common.c
@@ -26,6 +26,24 @@ mt_common_get_xdisplay (void)
}
void
+mt_common_xtrap_push (void)
+{
+ gdk_error_trap_push ();
+}
+
+void
+mt_common_xtrap_pop (void)
+{
+ gint xerror;
+
+ gdk_flush ();
+ if ((xerror = gdk_error_trap_pop ()))
+ {
+ g_warning ("Trapped X Error code %i.", xerror);
+ }
+}
+
+void
mt_common_show_help (GdkScreen *screen, guint32 timestamp)
{
GError *error = NULL;
diff --git a/src/mt-common.h b/src/mt-common.h
index 1ab9507..fd2d956 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -85,6 +85,9 @@ typedef enum
Display * mt_common_get_xdisplay (void);
+void mt_common_xtrap_push (void);
+void mt_common_xtrap_pop (void);
+
void mt_common_show_help (GdkScreen *screen,
guint32 timestamp);
diff --git a/src/mt-listener.c b/src/mt-listener.c
index 7bbbf0e..674e275 100644
--- a/src/mt-listener.c
+++ b/src/mt-listener.c
@@ -249,11 +249,11 @@ mt_listener_mouse_moved (MtListener *listener)
dpy = mt_common_get_xdisplay ();
- gdk_error_trap_push ();
- XQueryPointer (dpy, DefaultRootWindow (dpy),
+ mt_common_xtrap_push ();
+ XQueryPointer (dpy, XDefaultRootWindow (dpy),
&root_return, &child_return, &x, &y,
&win_x_return, &win_y_return, &mask_return);
- gdk_error_trap_pop ();
+ mt_common_xtrap_pop ();
while (mt_listener_maybe_emit (listener, mask_return));
@@ -297,14 +297,13 @@ mt_listener_grab_buttons (void)
Display *dpy;
dpy = mt_common_get_xdisplay ();
-
- gdk_error_trap_push ();
+ mt_common_xtrap_push ();
XGrabButton (dpy, AnyButton, AnyModifier,
XDefaultRootWindow (dpy),
True, ButtonPressMask | ButtonReleaseMask,
GrabModeSync, GrabModeAsync, None, None);
XSync (dpy, False);
- gdk_error_trap_pop ();
+ mt_common_xtrap_pop ();
}
static void
@@ -313,10 +312,9 @@ mt_listener_ungrab_buttons (void)
Display *dpy;
dpy = mt_common_get_xdisplay ();
-
- gdk_error_trap_push ();
+ mt_common_xtrap_push ();
XUngrabButton (dpy, AnyButton, AnyModifier, XDefaultRootWindow (dpy));
- gdk_error_trap_pop ();
+ mt_common_xtrap_pop ();
}
static void
diff --git a/src/mt-main.c b/src/mt-main.c
index 45d5dec..d2a1ce2 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -78,10 +78,7 @@ mt_main_current_screen (MtData *mt)
static void
mt_main_generate_motion_event (GdkScreen *screen, gint x, gint y)
{
- gdk_error_trap_push ();
gdk_display_warp_pointer (gdk_display_get_default (), screen, x, y);
- gdk_flush ();
- gdk_error_trap_pop ();
}
static void
@@ -93,8 +90,7 @@ mt_main_generate_button_event (MtData *mt,
Display *dpy;
dpy = mt_common_get_xdisplay ();
-
- gdk_error_trap_push ();
+ mt_common_xtrap_push ();
switch (type)
{
case PRESS:
@@ -117,8 +113,7 @@ mt_main_generate_button_event (MtData *mt,
g_warning ("Unknown button sequence.");
break;
}
- gdk_flush ();
- gdk_error_trap_pop ();
+ mt_common_xtrap_pop ();
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]