Subject: Re: bug#50993: 29.0.50; Problems when dragging the mouse over the toolbar

From: martin rudalics <[email-masked]>
Date: Mon, 11 Oct 2021 11:21:15 +0200

>> I'm too silly to understand how this is related to the issue at hand.
 >> Can you please elaborate?
 >
 > AFAIU, mouse-movement events generated by moving the mouse over the
 > toolbar don't contain a window, but rather the frame the toolbar belongs
 > to.

Yes, but how does 'mouse-minibuffer-check' enter this picture?

 > However, mouse-drag-track wants START-EVENT to contain a window.
 >
 >> So far I've been unable to reproduce this issue on Emacs 28.  Doesn't
 >> 'mouse-drag-track', once started, conceptually have to get through
 >> wherever the mouse pointer is - a child frame, the tool bar, another
 >> frame, no frame at all?  Like scroll bar dragging with the mouse?
 >
 > You need a build without toolkit tool bars, I think.

I see.  Dragging the secondary selection seems to work here with the
trivial patch below.  Can you try it?

martin

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5d4e05fa25..6da4635114 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -2121,6 +2121,7 @@ mouse-drag-secondary
  	  (while (progn
  		   (setq event (read--potential-mouse-event))
  		   (or (mouse-movement-p event)
+		       (eq event 'tool-bar)
  		       (memq (car-safe event) '(switch-frame select-window))))

  	    (if (memq (car-safe event) '(switch-frame select-window))
@@ -2129,7 +2130,8 @@ mouse-drag-secondary
  		    end-point (posn-point end))
  	      (cond
  	       ;; Are we moving within the original window?
-	       ((and (eq (posn-window end) start-window)
+	       ((and (not (eq event 'tool-bar))
+		     (eq (posn-window end) start-window)
  		     (integer-or-marker-p end-point))
  		(let ((range (mouse-start-end start-point end-point
  					      click-count)))