From 014fdb87e57dcd2bbba6b2aa18371475aef98b4e Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 16 Nov 2016 13:16:24 +0100 Subject: [PATCH] app: make switching paint tools to color picker mode more robust Don't rely on the exact modifier being pressed or released. Instead, check if only the right modifier is pressed after *each* modifier change, and switch to color picking if it is; disable color picking otherwise. This greatly reduces the risk of missing the user's wish to pick colors because of other modifiers being pressed and released in whatever order. Probably fixes bug #734743. --- app/tools/gimppainttool.c | 53 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index f80af50e5c..d1341dc09b 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -472,40 +472,41 @@ gimp_paint_tool_modifier_key (GimpTool *tool, GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); - if (key != gimp_get_constrain_behavior_mask ()) - return; - if (paint_tool->pick_colors && ! paint_tool->draw_line) { - if (press) + if ((state & gimp_get_all_modifiers_mask ()) == + gimp_get_constrain_behavior_mask ()) { - GimpToolInfo *info = gimp_get_tool_info (display->gimp, - "gimp-color-picker-tool"); - - if (GIMP_IS_TOOL_INFO (info)) + if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool))) { - if (gimp_draw_tool_is_active (draw_tool)) - gimp_draw_tool_stop (draw_tool); + GimpToolInfo *info = gimp_get_tool_info (display->gimp, + "gimp-color-picker-tool"); - gimp_color_tool_enable (GIMP_COLOR_TOOL (tool), - GIMP_COLOR_OPTIONS (info->tool_options)); - - switch (GIMP_COLOR_TOOL (tool)->pick_mode) + if (GIMP_IS_TOOL_INFO (info)) { - case GIMP_COLOR_PICK_MODE_FOREGROUND: - gimp_tool_push_status (tool, display, - _("Click in any image to pick the " - "foreground color")); - break; + if (gimp_draw_tool_is_active (draw_tool)) + gimp_draw_tool_stop (draw_tool); - case GIMP_COLOR_PICK_MODE_BACKGROUND: - gimp_tool_push_status (tool, display, - _("Click in any image to pick the " - "background color")); - break; + gimp_color_tool_enable (GIMP_COLOR_TOOL (tool), + GIMP_COLOR_OPTIONS (info->tool_options)); - default: - break; + switch (GIMP_COLOR_TOOL (tool)->pick_mode) + { + case GIMP_COLOR_PICK_MODE_FOREGROUND: + gimp_tool_push_status (tool, display, + _("Click in any image to pick the " + "foreground color")); + break; + + case GIMP_COLOR_PICK_MODE_BACKGROUND: + gimp_tool_push_status (tool, display, + _("Click in any image to pick the " + "background color")); + break; + + default: + break; + } } } }