[gimp] Bug 732160 - menu activation with alt-somekey makes tools stay...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 732160 - menu activation with alt-somekey makes tools stay...
- Date: Thu, 14 Apr 2016 23:22:46 +0000 (UTC)
commit 2a31b96f4bdc03389a1e7c4dc2be5402c1b4522f
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 15 00:17:00 2016 +0100
Bug 732160 - menu activation with alt-somekey makes tools stay...
...in "alt-pressed" mode
Menu activation doesn't cause a focus-out becaus menu keyboard
grabbing is implemented with a simple gtk_grab_add() (the menu popup
never gets the focus). Therefore, the canvas never gets a focus-out
event and the pressed modifiers are stuck.
Fixed by connecting to "grab-notify" on the canvas, and artificially
releasing all modifiers when the canvas is shadowed by a grab.
app/display/gimpdisplayshell-tool-events.c | 36 +++++++++++++++++++++++++++-
app/display/gimpdisplayshell-tool-events.h | 4 +++
app/display/gimpdisplayshell.c | 4 +++
3 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index fc811b5..e163bde 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -649,7 +649,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gimp);
- state &= ~gimp_display_shell_key_to_state (bevent->button);
+ state &= ~gimp_display_shell_button_to_state (bevent->button);
if (bevent->button == 1)
{
@@ -1234,6 +1234,36 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
void
+gimp_display_shell_canvas_grab_notify (GtkWidget *canvas,
+ gboolean was_grabbed,
+ GimpDisplayShell *shell)
+{
+ GimpDisplay *display;
+ GimpImage *image;
+ Gimp *gimp;
+
+ /* are we in destruction? */
+ if (! shell->display || ! gimp_display_get_shell (shell->display))
+ return;
+
+ display = shell->display;
+ gimp = gimp_display_get_gimp (display);
+ image = gimp_display_get_image (display);
+
+ if (! image)
+ return;
+
+ GIMP_LOG (TOOL_EVENTS, "grab_notify (display %p): was_grabbed = %s",
+ display, was_grabbed ? "TRUE" : "FALSE");
+
+ if (! was_grabbed)
+ {
+ if (! gimp_image_is_empty (image))
+ tool_manager_modifier_state_active (gimp, 0, display);
+ }
+}
+
+void
gimp_display_shell_buffer_stroke (GimpMotionBuffer *buffer,
const GimpCoords *coords,
guint32 time,
@@ -1359,17 +1389,21 @@ gimp_display_shell_key_to_state (gint key)
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
return GDK_MOD1_MASK;
+
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
return GDK_SHIFT_MASK;
+
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
return GDK_CONTROL_MASK;
+
#ifdef GDK_WINDOWING_QUARTZ
case GDK_KEY_Meta_L:
case GDK_KEY_Meta_R:
return GDK_MOD2_MASK;
#endif
+
default:
return 0;
}
diff --git a/app/display/gimpdisplayshell-tool-events.h b/app/display/gimpdisplayshell-tool-events.h
index 0ceeb6f..a736452 100644
--- a/app/display/gimpdisplayshell-tool-events.h
+++ b/app/display/gimpdisplayshell-tool-events.h
@@ -26,6 +26,10 @@ gboolean gimp_display_shell_events (GtkWidget *widget,
gboolean gimp_display_shell_canvas_tool_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
+void gimp_display_shell_canvas_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed,
+ GimpDisplayShell *shell);
+
void gimp_display_shell_buffer_stroke (GimpMotionBuffer *buffer,
const GimpCoords *coords,
guint32 time,
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 3be2c70..5aa2478 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -584,6 +584,10 @@ gimp_display_shell_constructed (GObject *object)
gimp_devices_add_widget (shell->display->gimp, shell->hrule);
gimp_devices_add_widget (shell->display->gimp, shell->vrule);
+ g_signal_connect (shell->canvas, "grab-notify",
+ G_CALLBACK (gimp_display_shell_canvas_grab_notify),
+ shell);
+
g_signal_connect (shell->canvas, "realize",
G_CALLBACK (gimp_display_shell_canvas_realize),
shell);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]