Subject: bug#70086: Mouse clicks in tab-bar don't call commands bound in keymap properties

From: Adam Porter <[email-masked]>
Date: Fri, 3 May 2024 00:45:31 -0500

reopen 70086
thanks

Hi Juri,

On 5/2/24 12:55, Juri Linkov wrote:
> close 70086 30.0.50
> thanks
> 
>>> Do you think this could be fixed in time for Emacs 30?
>>
>> Please try out the following patch.  At least it works for your test case.
> 
> I guess this patch did the right thing.  So pushed now for Emacs 30.

Apologies for not replying yet, and thanks for following up.  I just 
tested your patch, and it almost works perfectly.  The problem now is 
that if there are multiple such constructs in the tab-bar, each with 
their own keymap, it seems that the first one in the global-mode-string 
catches the clicks that are made on the second one.

For example, given this value for global-mode-string:

((tab-bar-ecm-mode
   (:propertize tab-bar-ecm-lighter keymap
	       (keymap
		(tab-bar keymap
			 (mouse-1 lambda
				  (&rest _)
				  (interactive)
				  (message "tab-bar-ecm-lighter clicked with mouse-1"))))))
  (listen-mode
   (:propertize listen-mode-lighter keymap
	       (keymap
		(tab-bar keymap
			 (down-mouse-3 . listen-pause)
			 (down-mouse-2 . listen-pause)
			 (down-mouse-1 . listen-pause)
			 (mouse-3 . listen-pause)
			 (mouse-2 . listen-pause)
			 (mouse-1 . listen-pause))
		(mode-line keymap
			   (mouse-1 . listen-pause))))))

When I click on the text rendered by listen-mode-lighter, the lambda 
from the tab-bar-ecm-lighter keymap intercepts the mouse-1 event and 
prints the message rather than calling the listen-pause function.