Commit 2a31b96f authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 2db14d05
......@@ -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)
{
......@@ -1233,6 +1233,36 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
return return_val;
}
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,
......@@ -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;
}
......
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment