mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-22 07:09:54 +00:00
xt-mouse.el: Obey mouse-wheel-*-event
variables (bug#68698)
* lisp/xt-mouse.el (xterm-mouse--same-button-p): New function. (xterm-mouse--read-event-sequence): Use it to obey `mouse-wheel-*-event` variables. * lisp/mwheel.el (mouse-wheel-obey-old-style-wheel-buttons): Update docstring.
This commit is contained in:
parent
71b5d5a979
commit
e734f8e502
6
etc/NEWS
6
etc/NEWS
@ -430,6 +430,12 @@ only to specify the 'mouse-4/5/6/7' events generated by older
|
||||
configurations such as X11 when the X server does not support at least
|
||||
version 2.1 of the X Input Extension, and 'xterm-mouse-mode'.
|
||||
|
||||
** 'xterm-mouse-mode'
|
||||
This mode now emits `wheel-up/down/right/left' events instead of
|
||||
'mouse-4/5/6/7' events for the mouse wheel.
|
||||
It uses the 'mouse-wheel-up/down/left/right-event'
|
||||
variables to decide which button maps to which wheel event (if any).
|
||||
|
||||
** Info
|
||||
|
||||
---
|
||||
|
@ -59,7 +59,7 @@
|
||||
(defvar mouse-wheel-obey-old-style-wheel-buttons t
|
||||
"If non-nil, treat mouse-4/5/6/7 events as mouse wheel events.
|
||||
These are the event names used historically in X11 before XInput2.
|
||||
They are sometimes generated by things like `xterm-mouse-mode' as well.")
|
||||
They are sometimes generated by things like text-terminals as well.")
|
||||
|
||||
(defcustom mouse-wheel-down-event
|
||||
(if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4)
|
||||
|
@ -40,6 +40,8 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'mwheel)
|
||||
|
||||
(defvar xterm-mouse-debug-buffer nil)
|
||||
|
||||
(defun xterm-mouse-translate (_event)
|
||||
@ -193,6 +195,12 @@ single byte."
|
||||
(cons n c))
|
||||
(cons (- (setq c (xterm-mouse--read-coordinate)) 32) c))))
|
||||
|
||||
(defun xterm-mouse--button-p (event btn)
|
||||
(and (symbolp event)
|
||||
(string-prefix-p "mouse-" (symbol-name event))
|
||||
(eq btn (car (read-from-string (symbol-name event)
|
||||
(length "mouse-"))))))
|
||||
|
||||
;; XTerm reports mouse events as
|
||||
;; <EVENT-CODE> <X> <Y> in default mode, and
|
||||
;; <EVENT-CODE> ";" <X> ";" <Y> <"M" or "m"> in extended mode.
|
||||
@ -230,13 +238,22 @@ single byte."
|
||||
;; Spurious release event without previous button-down
|
||||
;; event: assume, that the last button was button 1.
|
||||
(t 1)))
|
||||
(sym (if move 'mouse-movement
|
||||
(intern (concat (if ctrl "C-" "")
|
||||
(if meta "M-" "")
|
||||
(if shift "S-" "")
|
||||
(if down "down-" "")
|
||||
"mouse-"
|
||||
(number-to-string btn))))))
|
||||
(sym
|
||||
(if move 'mouse-movement
|
||||
(intern
|
||||
(concat
|
||||
(if ctrl "C-" "")
|
||||
(if meta "M-" "")
|
||||
(if shift "S-" "")
|
||||
(if down "down-" "")
|
||||
(cond
|
||||
;; BEWARE: `mouse-wheel-UP-event' corresponds to
|
||||
;; `wheel-DOWN' events and vice versa!!
|
||||
((xterm-mouse--button-p mouse-wheel-down-event btn) "wheel-up")
|
||||
((xterm-mouse--button-p mouse-wheel-up-event btn) "wheel-down")
|
||||
((xterm-mouse--button-p mouse-wheel-left-event btn) "wheel-left")
|
||||
((xterm-mouse--button-p mouse-wheel-right-event btn) "wheel-right")
|
||||
(t (format "mouse-%d" btn))))))))
|
||||
(list sym (1- x) (1- y))))
|
||||
|
||||
(defun xterm-mouse--set-click-count (event click-count)
|
||||
|
Loading…
Reference in New Issue
Block a user