Subject: bug#53249: closed (Re: bug#53249: Context menu in other window)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 15 Jan 2022 18:42:02 +0000

Your bug report

#53249: Context menu in other window

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
53249: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53249
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#53249: Context menu in other window
From: Juri Linkov <[email-masked]>
To: Lars Ingebrigtsen <[email-masked]>
Cc: [email-masked]
Date: Sat, 15 Jan 2022 20:38:11 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>> So the safest thing to do here is to select the window where
>> the context menu is invoked:
>
> Makes sense to me.

So pushed to master and closed.

Subject: Context menu in other window
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Fri, 14 Jan 2022 10:42:43 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

When clicking the right mouse button in another window,
some context-menu functions break the window configuration.
For example, when two windows show different parts of the same buffer,
this code in `prog-context-menu':

  (let ((identifier (save-excursion
                      (mouse-set-point click)
                      (xref-backend-identifier-at-point
                       (xref-find-backend)))))

moves window point of another window to the same position of the
selected window.

So the safest thing to do here is to select the window where
the context menu is invoked:

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 0d8d7d6175..45b7d51da7 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -320,6 +320,8 @@ context-menu-map
          (fun (mouse-posn-property (event-start click)
                                    'context-menu-function)))
 
+    (select-window (posn-window (event-start click)))
+
     (if (functionp fun)
         (setq menu (funcall fun menu click))
       (run-hook-wrapped 'context-menu-functions
--