[gimp] Bug 796073 - Zero-size selections affect movement of pasted content...



commit 918f60836ded0a5516576e5a82bd22ca51982f68
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 15 23:55:48 2018 +0200

    Bug 796073 - Zero-size selections affect movement of pasted content...
    
    ...in weird ways
    
    In gimp_rectangle_tool_button_press(), when the press triggers a
    GimpEditSelectionTool operation (like moving a floating selection),
    make sure we don't call COMMIT on a zero-size rectangle, because that
    would get special treatment by commit(). Instead, CANCEL a zero-size
    rectangle so stuff behaves as if it has never been there.

 app/tools/gimprectangleselecttool.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c
index 92c0b6b..5d4934b 100644
--- a/app/tools/gimprectangleselecttool.c
+++ b/app/tools/gimprectangleselecttool.c
@@ -244,7 +244,29 @@ gimp_rectangle_select_tool_button_press (GimpTool            *tool,
       /* In some cases we want to finish the rectangle select tool
        * and hand over responsibility to the selection tool
        */
-      gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
+
+      gboolean zero_rect = FALSE;
+
+      if (private->widget)
+        {
+          gdouble x1, y1, x2, y2;
+
+          gimp_tool_rectangle_get_public_rect (GIMP_TOOL_RECTANGLE (private->widget),
+                                               &x1, &y1, &x2, &y2);
+          if (x1 == x2 && y1 == y2)
+            zero_rect = TRUE;
+        }
+
+      /* Don't commit a zero-size rectangle, it would look like a
+       * click to commit() and that could anchor the floating
+       * selection or do other evil things. Instead, simply cancel a
+       * zero-size rectangle. See bug #796073.
+       */
+      if (zero_rect)
+        gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
+      else
+        gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
+
       gimp_rectangle_select_tool_update_option_defaults (rect_tool, TRUE);
       return;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]