[gimp/soc-2010-cage-2] app: g_printerr() a warning if grabbing fails
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage-2] app: g_printerr() a warning if grabbing fails
- Date: Thu, 30 Dec 2010 18:14:17 +0000 (UTC)
commit 69d45b45dc0609a1566c488122dc0a1d2e522255
Author: Michael Natterer <mitch gimp org>
Date: Tue Dec 7 19:57:13 2010 +0100
app: g_printerr() a warning if grabbing fails
This should not happen, but happens anyway on GTK+ 3.x, so better warn
about it to make debugging easier.
app/display/gimpdisplayshell-callbacks.c | 47 ++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 879236b..67bab2f 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -1845,6 +1845,8 @@ gimp_display_shell_ruler_button_press (GtkWidget *widget,
if (active_tool)
{
+ GdkGrabStatus status;
+
if (! gtk_widget_has_focus (shell->canvas))
{
gimp_display_shell_update_focus (shell, NULL, event->state);
@@ -1858,21 +1860,42 @@ gimp_display_shell_ruler_button_press (GtkWidget *widget,
gdk_event_get_time ((GdkEvent *) event));
}
- gdk_pointer_grab (gtk_widget_get_window (shell->canvas), FALSE,
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK,
- NULL, NULL, event->time);
+ status = gdk_pointer_grab (gtk_widget_get_window (shell->canvas), FALSE,
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_BUTTON_RELEASE_MASK,
+ NULL, NULL, event->time);
- gdk_keyboard_grab (gtk_widget_get_window (shell->canvas),
- FALSE, event->time);
+ if (status == GDK_GRAB_SUCCESS)
+ {
+ status = gdk_keyboard_grab (gtk_widget_get_window (shell->canvas),
+ FALSE, event->time);
- if (sample_point)
- gimp_color_tool_start_sample_point (active_tool, display);
- else if (horizontal)
- gimp_move_tool_start_hguide (active_tool, display);
+ if (status == GDK_GRAB_SUCCESS)
+ {
+ if (sample_point)
+ gimp_color_tool_start_sample_point (active_tool, display);
+ else if (horizontal)
+ gimp_move_tool_start_hguide (active_tool, display);
+ else
+ gimp_move_tool_start_vguide (active_tool, display);
+
+ return TRUE;
+ }
+ else
+ {
+ g_printerr ("%s: gdk_keyboard_grab failed with status %d\n",
+ G_STRFUNC, status);
+
+ gdk_display_pointer_ungrab (gtk_widget_get_display (shell->canvas),
+ event->time);
+ }
+ }
else
- gimp_move_tool_start_vguide (active_tool, display);
+ {
+ g_printerr ("%s: gdk_pointer_grab failed with status %d\n",
+ G_STRFUNC, status);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]