From bd194c9a572bae0e13468c8dbca63d5a64af192a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 16 Sep 2025 19:48:43 +0300 Subject: Context menu related fixes (bug#64980) * etc/PROBLEMS: Suggest how to keep context menus open on Lucid. * lisp/mouse.el (context-menu-mode-map): Bind [mouse-3] to 'ignore' instead of 'nil' to not fallback to the default binding. (mouse--drag-start-event): Remove unused variable. (mouse-undouble-last-event): Remove unused function. --- etc/PROBLEMS | 9 +++++++++ lisp/mouse.el | 25 +------------------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 5da83fefeb1..be023b3d5ce 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -2012,6 +2012,15 @@ Very long popup menus cannot be shown in their entirety, and don't have a scroll bar to scroll them vertically. Lucid does not support this feature. A workaround is to use other toolkits (GTK, LessTif, etc.). +*** In Emacs built with Lucid cannot keep context menus open. + +After enabling context-menu-mode, when the menu is opened by +, it closes right away when the right mouse button +is released. It's possible to keep the context menu open +after releasing the mouse button by disabling XInput 2 support: + + ./configure --with-x-toolkit=lucid --without-xinput2 + *** Emacs running under X Window System does not handle mouse clicks. *** 'emacs -geometry 80x20' finds a file named '80x20'. diff --git a/lisp/mouse.el b/lisp/mouse.el index 907a4883230..b8d46d8dbed 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -687,7 +687,7 @@ Some context functions add menu items below the separator." (defvar context-menu-mode-map (let ((map (make-sparse-keymap))) - (define-key map [mouse-3] nil) + (define-key map [mouse-3] #'ignore) (define-key map [down-mouse-3] context-menu-entry) (define-key map [menu] #'context-menu-open) (if (featurep 'w32) @@ -1520,8 +1520,6 @@ point determined by `mouse-select-region-move-to-beginning'." (eq mouse-last-region-end (region-end)) (eq mouse-last-region-tick (buffer-modified-tick)))) -(defvar mouse--drag-start-event nil) - (defun mouse-set-region (click) "Set the region to the text dragged over, and copy to kill ring. This should be bound to a mouse drag event. @@ -2064,27 +2062,6 @@ If MODE is 2 then do the same for lines." (if (numberp (posn-point posn)) (push-mark (posn-point posn) t t)))) -(defun mouse-undouble-last-event (events) - (let* ((index (1- (length events))) - (last (nthcdr index events)) - (event (car last)) - (basic (event-basic-type event)) - (old-modifiers (event-modifiers event)) - (modifiers (delq 'double (delq 'triple (copy-sequence old-modifiers)))) - (new - (if (consp event) - ;; Use reverse, not nreverse, since event-modifiers - ;; does not copy the list it returns. - (cons (event-convert-list (reverse (cons basic modifiers))) - (cdr event)) - event))) - (setcar last new) - (if (and (not (equal modifiers old-modifiers)) - (key-binding (apply #'vector events))) - t - (setcar last event) - nil))) - ;; Momentarily show where the mark is, if highlighting doesn't show it. (defun mouse-set-mark (click) -- cgit v1.2.1