Subject: Re: bug#48409: Text runs away before user can copy it

From: martin rudalics <[email-masked]>
Date: Wed, 19 May 2021 19:40:06 +0200

> The above is the basic scenario.  If the mouse is on the top line of the
 > miniwindow when the mouse is clicked, the returned y coordinate at (ii)
 > is in the mode line of the window above, and is determined relative to
 > that window.

Are you sure?  If the click happens on the bottom line, it's still here
reported for the minibuffer window only that now the double click fuzz
rigmarole breaks in and says that the mouse has moved.

 > I don't have any workable ideas on how to fix this bug.  The only idea
 > which springs to mind is to move from expressing mouse positions
 > relative to a window to expressing it relative to a frame.  Or, maybe
 > the resizing of the miniwindow could be postponed till after the
 > up-mouse event.

For clicks into the bottom line the attached might help.  Clicks above
must be caught elsewhere.  But you don't get a drag event and no error
message for them.

martin
diff --git a/src/keyboard.c b/src/keyboard.c
index 47b5e59024..2aa47b57fa 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5727,9 +5727,21 @@ make_lispy_event (struct input_event *event)
 			  it's probably OK to ignore it as well.  */
 		       && EQ (Fcar (Fcdr (start_pos)), Fcar (Fcdr (position)))))
 		  {
-		    /* Mouse has moved enough.  */
-		    button_down_time = 0;
-		    click_or_drag_modifier = drag_modifier;
+		    Lisp_Object pos_window = XCAR (position);
+
+		    if (EQ (XCAR (start_pos), pos_window)
+			&& (!WINDOW_LIVE_P (pos_window)
+			  /* Make sure down has still valid coordinates
+			     within position's window.  */
+			    || ((XWINDOW (pos_window)->pixel_height
+				 >= XFIXNUM (XCDR (down)))
+				&& (XWINDOW (pos_window)->pixel_width
+				    >= XFIXNUM (XCAR (down))))))
+		      /* Mouse has moved enough.  */
+		      {
+			button_down_time = 0;
+			click_or_drag_modifier = drag_modifier;
+		      }
 		  }
 	      }