Index: app/tools/gimprectangletool.c
===================================================================
--- app/tools/gimprectangletool.c	(revision 25183)
+++ app/tools/gimprectangletool.c	(working copy)
@@ -102,6 +102,11 @@
    */
 
   /*
+   * Is a rectangle currently being drawn?
+   */
+  gboolean                active;
+
+  /*
    * Wether or not the rectangle currently being rubber-banded was
    * created from scatch.
    */
@@ -777,6 +782,8 @@
   g_signal_connect_object (options, "notify",
                            G_CALLBACK (gimp_rectangle_tool_options_notify),
                            rect_tool, 0);
+
+  private->active = FALSE;
 }
 
 void
@@ -837,8 +844,12 @@
 
   gimp_draw_tool_pause (draw_tool);
 
-  if (display != tool->display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, display) ||
+      private->function == GIMP_RECTANGLE_TOOL_CREATING)
     {
+      if (gimp_rectangle_tool_rectangle_is_active (rect_tool, display))
+        gimp_rectangle_tool_halt (rect_tool);
+
       if (gimp_draw_tool_is_active (draw_tool))
         {
           gimp_display_shell_set_highlight (GIMP_DISPLAY_SHELL (draw_tool->display->shell),
@@ -921,7 +932,8 @@
 
   gimp_rectangle_tool_update_highlight (rect_tool);
 
-  gimp_tool_control_activate (tool->control);
+  if (! gimp_tool_control_is_active (tool->control))
+    gimp_tool_control_activate (tool->control);
 
   gimp_draw_tool_resume (draw_tool);
 }
@@ -944,6 +956,9 @@
   private   = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
   options   = GIMP_RECTANGLE_TOOL_GET_OPTIONS (tool);
 
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, display))
+    return;
+
   gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
   gimp_tool_control_halt (tool->control);
@@ -975,9 +990,8 @@
 
       /* When a dead area is clicked, don't execute. */
       if (private->function == GIMP_RECTANGLE_TOOL_DEAD)
-        break;
-
-      if (gimp_rectangle_tool_execute (rect_tool))
+        private->active = FALSE;
+      else if (gimp_rectangle_tool_execute (rect_tool))
         gimp_rectangle_tool_halt (rect_tool);
       break;
 
@@ -1340,12 +1354,12 @@
 
   g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), FALSE);
 
-  if (display != tool->display)
-    return FALSE;
-
   rect_tool = GIMP_RECTANGLE_TOOL (tool);
   private   = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
 
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, display))
+    return FALSE;
+
   switch (kevent->keyval)
     {
     case GDK_Up:
@@ -1479,7 +1493,7 @@
   private        = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
   rect_tool = GIMP_RECTANGLE_TOOL (tool);
 
-  if (tool->display != display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, display))
     return;
 
   if (private->suppress_updates)
@@ -1572,7 +1586,7 @@
   rect_tool = GIMP_RECTANGLE_TOOL (tool);
   private   = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
 
-  if (tool->display == display)
+  if (gimp_rectangle_tool_rectangle_is_active (rect_tool, display))
     {
       switch (private->function)
         {
@@ -1905,7 +1919,7 @@
   GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
   GimpDisplayShell         *shell;
 
-  if (! tool->display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display))
     return TRUE;
 
   shell = GIMP_DISPLAY_SHELL (tool->display->shell);
@@ -1930,6 +1944,7 @@
   private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
 
   tool->display = display;
+  private->active = TRUE;
 
   g_signal_connect_object (tool->display->shell, "scrolled",
                            G_CALLBACK (gimp_rectangle_tool_shell_scrolled),
@@ -2009,11 +2024,16 @@
 {
   GimpTool                    *tool = GIMP_TOOL (rect_tool);
   GimpRectangleOptionsPrivate *options_private;
+  GimpRectangleToolPrivate    *private;
 
   options_private =
     GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (gimp_tool_get_options (tool));
 
-  if (tool->display)
+  private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
+  private->active = FALSE;
+  private->is_new = FALSE;
+
+  if (gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display))
     {
       gimp_display_shell_set_highlight (GIMP_DISPLAY_SHELL (tool->display->shell),
                                         NULL);
@@ -2029,9 +2049,6 @@
   if (gimp_tool_control_is_active (tool->control))
     gimp_tool_control_halt (tool->control);
 
-  tool->display  = NULL;
-  tool->drawable = NULL;
-
   gimp_rectangle_tool_set_function (rect_tool, GIMP_RECTANGLE_TOOL_INACTIVE);
 
   if (options_private->auto_shrink_button)
@@ -2190,7 +2207,7 @@
       return;
     }
 
-  if (! tool->display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display))
     return;
 
   if (! strcmp (pspec->name, "x"))
@@ -2272,8 +2289,8 @@
        * immedieately switch width and height of the pending
        * rectangle.
        */
-      if (options_private->fixed_rule_active                   &&
-          tool->display                              != NULL   &&
+      if (gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display) &&
+          options_private->fixed_rule_active                   &&
           tool->button_press_state                   == 0      &&
           tool->active_modifier_state                == 0      &&
           options_private->desired_fixed_size_width  == height &&
@@ -2330,8 +2347,8 @@
        * immedieately switch width and height of the pending
        * rectangle.
        */
-      if (options_private->fixed_rule_active               &&
-          tool->display               != NULL              &&
+      if (gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display) &&
+          options_private->fixed_rule_active               &&
           tool->button_press_state    == 0                 &&
           tool->active_modifier_state == 0                 &&
           lower_ratio                 <  new_inverse_ratio &&
@@ -2699,7 +2716,7 @@
   private   = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
   highlight = FALSE;
 
-  if (! tool->display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display))
     return;
 
   shell = GIMP_DISPLAY_SHELL (tool->display->shell);
@@ -3946,7 +3963,7 @@
   *max_x = 0;
   *max_y = 0;
 
-  if (! tool->display)
+  if (! gimp_rectangle_tool_rectangle_is_active (rect_tool, tool->display))
     return;
 
   switch (constraint)
@@ -4116,3 +4133,35 @@
         break;
     }
 }
+
+
+/**
+ * gimp_rectangle_tool_rectangle_is_active:
+ *
+ * Returns a Boolean telling the caller whether a rectangle
+ * is currently being drawn on the specified display.
+ */
+gboolean
+gimp_rectangle_tool_rectangle_is_active (GimpRectangleTool *rect_tool,
+                                         GimpDisplay       *display)
+{
+  GimpTool              *tool      = GIMP_TOOL (rect_tool);
+
+  if (display != tool->display)
+    return FALSE;
+
+  return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->active;
+}
+
+/**
+ * gimp_rectangle_tool_rectangle_is_narrow:
+ *
+ * Returns TRUE if the handles are being shown outside the
+ * rectangle, FALSE if they are inside
+ */
+gboolean
+gimp_rectangle_tool_rectangle_is_narrow (GimpRectangleTool *rect_tool)
+{
+  return GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool)->narrow_mode;
+}
+
Index: app/tools/gimprectangletool.h
===================================================================
--- app/tools/gimprectangletool.h	(revision 25183)
+++ app/tools/gimprectangletool.h	(working copy)
@@ -139,9 +139,12 @@
                                                      const gchar             *width_property,
                                                      const gchar             *height_property);
 gboolean    gimp_rectangle_tool_rectangle_is_new    (GimpRectangleTool       *rect_tool);
+gboolean    gimp_rectangle_tool_rectangle_is_narrow (GimpRectangleTool       *rect_tool);
 gboolean    gimp_rectangle_tool_point_in_rectangle  (GimpRectangleTool       *rect_tool,
                                                      gdouble                  x,
                                                      gdouble                  y);
+gboolean    gimp_rectangle_tool_rectangle_is_active (GimpRectangleTool       *rect_tool,
+                                                     GimpDisplay             *display);
 
 
 /*  convenience functions  */
