From 114b45c7ebb03b6b63dcbb51855d5ea87f634171 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 9 Mar 2012 13:20:41 +0100 Subject: [PATCH] gdk: Make query_state() vfunc a void vfunc ... and make sure the backends implement it that way. query_state() return value was ignored in all of GDK and caused crashes when it failed. --- gdk/gdkdevice.c | 20 ++++++------ gdk/gdkdeviceprivate.h | 4 +-- gdk/quartz/gdkdevice-core-quartz.c | 22 ++++++------- gdk/wayland/gdkdevice-wayland.c | 4 +-- gdk/win32/gdkdevice-win32.c | 4 +-- gdk/win32/gdkdevice-wintab.c | 22 ++++++------- gdk/x11/gdkdevice-core-x11.c | 42 +++++++++++------------- gdk/x11/gdkdevice-xi2.c | 51 +++++++++++++----------------- 8 files changed, 76 insertions(+), 93 deletions(-) diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 693cedb9b2..cd8bda2494 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -1588,7 +1588,7 @@ _gdk_device_translate_axis (GdkDevice *device, return TRUE; } -gboolean +void _gdk_device_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -1599,15 +1599,15 @@ _gdk_device_query_state (GdkDevice *device, gint *win_y, GdkModifierType *mask) { - return GDK_DEVICE_GET_CLASS (device)->query_state (device, - window, - root_window, - child_window, - root_x, - root_y, - win_x, - win_y, - mask); + GDK_DEVICE_GET_CLASS (device)->query_state (device, + window, + root_window, + child_window, + root_x, + root_y, + win_x, + win_y, + mask); } GdkWindow * diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h index 0e5f673471..ff92ea4b41 100644 --- a/gdk/gdkdeviceprivate.h +++ b/gdk/gdkdeviceprivate.h @@ -82,7 +82,7 @@ struct _GdkDeviceClass GdkScreen *screen, gint x, gint y); - gboolean (* query_state) (GdkDevice *device, + void (* query_state) (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, GdkWindow **child_window, @@ -151,7 +151,7 @@ void _gdk_device_add_slave (GdkDevice *device, GdkDevice *slave); void _gdk_device_remove_slave (GdkDevice *device, GdkDevice *slave); -gboolean _gdk_device_query_state (GdkDevice *device, +void _gdk_device_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, GdkWindow **child_window, diff --git a/gdk/quartz/gdkdevice-core-quartz.c b/gdk/quartz/gdkdevice-core-quartz.c index 9a78527350..8598cf62a7 100644 --- a/gdk/quartz/gdkdevice-core-quartz.c +++ b/gdk/quartz/gdkdevice-core-quartz.c @@ -54,15 +54,15 @@ static void gdk_quartz_device_core_warp (GdkDevice *device, GdkScreen *screen, gint x, gint y); -static gboolean gdk_quartz_device_core_query_state (GdkDevice *device, - GdkWindow *window, - GdkWindow **root_window, - GdkWindow **child_window, - gint *root_x, - gint *root_y, - gint *win_x, - gint *win_y, - GdkModifierType *mask); +static void gdk_quartz_device_core_query_state (GdkDevice *device, + GdkWindow *window, + GdkWindow **root_window, + GdkWindow **child_window, + gint *root_x, + gint *root_y, + gint *win_x, + gint *win_y, + GdkModifierType *mask); static GdkGrabStatus gdk_quartz_device_core_grab (GdkDevice *device, GdkWindow *window, gboolean owner_events, @@ -255,7 +255,7 @@ gdk_quartz_device_core_query_state_helper (GdkWindow *window, return found_window; } -static gboolean +static void gdk_quartz_device_core_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -288,8 +288,6 @@ gdk_quartz_device_core_query_state (GdkDevice *device, if (root_y) *root_y = y_tmp; - - return TRUE; } static GdkGrabStatus diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 1d6d0448a6..dcd92a2d5e 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -177,7 +177,7 @@ gdk_device_core_warp (GdkDevice *device, { } -static gboolean +static void gdk_device_core_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -208,8 +208,6 @@ gdk_device_core_query_state (GdkDevice *device, *win_y = wd->surface_y; if (mask) *mask = wd->modifiers; - - return TRUE; } static GdkGrabStatus diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c index 6bdd7e31c8..e3d8106ca2 100644 --- a/gdk/win32/gdkdevice-win32.c +++ b/gdk/win32/gdkdevice-win32.c @@ -238,7 +238,7 @@ get_current_mask (void) return mask; } -static gboolean +static void gdk_device_win32_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -303,8 +303,6 @@ gdk_device_win32_query_state (GdkDevice *device, if (mask) *mask = get_current_mask (); - - return TRUE; } static GdkGrabStatus diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c index 122787d3dc..0a4474229d 100644 --- a/gdk/win32/gdkdevice-wintab.c +++ b/gdk/win32/gdkdevice-wintab.c @@ -52,15 +52,15 @@ static void gdk_device_wintab_warp (GdkDevice *device, GdkScreen *screen, gint x, gint y); -static gboolean gdk_device_wintab_query_state (GdkDevice *device, - GdkWindow *window, - GdkWindow **root_window, - GdkWindow **child_window, - gint *root_x, - gint *root_y, - gint *win_x, - gint *win_y, - GdkModifierType *mask); +static void gdk_device_wintab_query_state (GdkDevice *device, + GdkWindow *window, + GdkWindow **root_window, + GdkWindow **child_window, + gint *root_x, + gint *root_y, + gint *win_x, + gint *win_y, + GdkModifierType *mask); static GdkGrabStatus gdk_device_wintab_grab (GdkDevice *device, GdkWindow *window, gboolean owner_events, @@ -161,7 +161,7 @@ gdk_device_wintab_warp (GdkDevice *device, { } -static gboolean +static void gdk_device_wintab_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -172,7 +172,7 @@ gdk_device_wintab_query_state (GdkDevice *device, gint *win_y, GdkModifierType *mask) { - return FALSE; + g_warning ("query_state unimplemented for wintab devices. Expect bad things."); } static GdkGrabStatus diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c index fcb8d7d21a..51cacb8ce6 100644 --- a/gdk/x11/gdkdevice-core-x11.c +++ b/gdk/x11/gdkdevice-core-x11.c @@ -52,15 +52,15 @@ static void gdk_x11_device_core_warp (GdkDevice *device, GdkScreen *screen, gint x, gint y); -static gboolean gdk_x11_device_core_query_state (GdkDevice *device, - GdkWindow *window, - GdkWindow **root_window, - GdkWindow **child_window, - gint *root_x, - gint *root_y, - gint *win_x, - gint *win_y, - GdkModifierType *mask); +static void gdk_x11_device_core_query_state (GdkDevice *device, + GdkWindow *window, + GdkWindow **root_window, + GdkWindow **child_window, + gint *root_x, + gint *root_y, + gint *win_x, + gint *win_y, + GdkModifierType *mask); static GdkGrabStatus gdk_x11_device_core_grab (GdkDevice *device, GdkWindow *window, gboolean owner_events, @@ -235,7 +235,7 @@ gdk_x11_device_core_warp (GdkDevice *device, XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y); } -static gboolean +static void gdk_x11_device_core_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -255,17 +255,15 @@ gdk_x11_device_core_query_state (GdkDevice *device, display = gdk_window_get_display (window); default_screen = gdk_display_get_default_screen (display); - if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client)) - { - if (!XQueryPointer (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XID (window), - &xroot_window, - &xchild_window, - &xroot_x, &xroot_y, - &xwin_x, &xwin_y, - &xmask)) - return FALSE; - } + if (GDK_X11_DISPLAY (display)->trusted_client && + XQueryPointer (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + &xroot_window, + &xchild_window, + &xroot_x, &xroot_y, + &xwin_x, &xwin_y, + &xmask)) + return; else { XSetWindowAttributes attributes; @@ -308,8 +306,6 @@ gdk_x11_device_core_query_state (GdkDevice *device, if (mask) *mask = xmask; - - return TRUE; } static GdkGrabStatus diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c index 263b3f3a67..dc13f83379 100644 --- a/gdk/x11/gdkdevice-xi2.c +++ b/gdk/x11/gdkdevice-xi2.c @@ -78,15 +78,15 @@ static void gdk_x11_device_xi2_warp (GdkDevice *device, GdkScreen *screen, gint x, gint y); -static gboolean gdk_x11_device_xi2_query_state (GdkDevice *device, - GdkWindow *window, - GdkWindow **root_window, - GdkWindow **child_window, - gint *root_x, - gint *root_y, - gint *win_x, - gint *win_y, - GdkModifierType *mask); +static void gdk_x11_device_xi2_query_state (GdkDevice *device, + GdkWindow *window, + GdkWindow **root_window, + GdkWindow **child_window, + gint *root_x, + gint *root_y, + gint *win_x, + gint *win_y, + GdkModifierType *mask); static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device, GdkWindow *window, @@ -306,7 +306,7 @@ gdk_x11_device_xi2_warp (GdkDevice *device, 0, 0, 0, 0, x, y); } -static gboolean +static void gdk_x11_device_xi2_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, @@ -326,26 +326,21 @@ gdk_x11_device_xi2_query_state (GdkDevice *device, XIModifierState mod_state; XIGroupState group_state; - if (!window || GDK_WINDOW_DESTROYED (window)) - return FALSE; - display = gdk_window_get_display (window); default_screen = gdk_display_get_default_screen (display); - if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client)) - { - if (!XIQueryPointer (GDK_WINDOW_XDISPLAY (window), - device_xi2->device_id, - GDK_WINDOW_XID (window), - &xroot_window, - &xchild_window, - &xroot_x, &xroot_y, - &xwin_x, &xwin_y, - &button_state, - &mod_state, - &group_state)) - return FALSE; - } + if (GDK_X11_DISPLAY (display)->trusted_client && + XIQueryPointer (GDK_WINDOW_XDISPLAY (window), + device_xi2->device_id, + GDK_WINDOW_XID (window), + &xroot_window, + &xchild_window, + &xroot_x, &xroot_y, + &xwin_x, &xwin_y, + &button_state, + &mod_state, + &group_state)) + return; else { XSetWindowAttributes attributes; @@ -393,8 +388,6 @@ gdk_x11_device_xi2_query_state (GdkDevice *device, *mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state); free (button_state.mask); - - return TRUE; } static GdkGrabStatus