From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Jan 2024 14:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68796@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170653954732691 (code B ref -1); Mon, 29 Jan 2024 14:46:01 +0000 Received: (at submit) by debbugs.gnu.org; 29 Jan 2024 14:45:47 +0000 Received: from localhost ([127.0.0.1]:59372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUStO-0008VB-GE for submit@debbugs.gnu.org; Mon, 29 Jan 2024 09:45:47 -0500 Received: from lists.gnu.org ([2001:470:142::17]:34822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUStM-0008Ux-4f for submit@debbugs.gnu.org; Mon, 29 Jan 2024 09:45:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUSt5-0000hZ-80 for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 09:45:30 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUSt2-0000RM-C9 for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 09:45:26 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3CCB4440976 for ; Mon, 29 Jan 2024 09:45:22 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1706539517; bh=xixryesPc0jyKV6gaBPu7LC/WGmhuV5g0W2ImPSjdek=; h=From:To:Subject:Date:From; b=g75fjC/U61TWXGsEmjtHmxt1agHNFYBwC7/6jPpA7z58DBuLDMqaS3VLXU3ycHjXh uQoyMt+3W26rmNsX/NjOiXXzvjIQgk7712K0pZyuu0i70q4wD3igmznHUQES4bpHB1 Z6aczg9Z59IZG9q/F/tz+k30KQ/9OMK98tij8/fkgAKN7+jdE5DivuCgV2mPka+mYK bZaravxRfRvClzQ4KYBljVELCbOAXFj/ob0+R6IpB994b/Kz9W2bhZXmOM2/bq4LBi GfCtP3iCGOylShyEPJHf2/t/lHFReOIjgCIYM5UbPCclXVB5tMwlzxRohaoKrzSq5N emYsgmRc2RjpQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C187C442415 for ; Mon, 29 Jan 2024 09:45:17 -0500 (EST) Received: from pastel (unknown [45.72.206.68]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A43BB120C8F for ; Mon, 29 Jan 2024 09:45:17 -0500 (EST) From: Stefan Monnier Date: Mon, 29 Jan 2024 09:45:01 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.000 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Tags: patch Following up on the `xt-mouse.el` patch (bug#68698), I now propose we do the same for those `mouse-4/5/6/7` events generated by old-style X11 input. IIUC Po Lu wasn't favorable to the idea, but maybe seeing the code will make a convert? Beside that, the patch has 2 remaining issues: - Lack of corresponding updates to `etc/NEWS` and `doc/lispref/commands.texi`. - Lack of testing for the left/right remapping. This is *really* necessary because even after (re)reading the various parts of the code that handle horizontal scrolling, I'm still very much unsure if I got the direction right[left?], so if you have a mouse with a horizontal wheel, please compare the `wheel-left/right` events generated with and without building `--without-xinput2`. Stefan In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2024-01-25 built on pastel Repository revision: 5945fab9af0b52cc55f06b2c7e911d51e34a9cdf Repository branch: work Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign' --without-native-compilation PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-xterm.c-Map-old-style-wheel-buttons-to-actual-wheel-.patch >From 60e6903ae12546db93f149b1f184ffc7ccdc30c2 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 29 Jan 2024 09:35:09 -0500 Subject: [PATCH] xterm.c: Map old-style wheel buttons to actual wheel events Change the handling of the old X11 convention to use mouse-4/5/6/7 events to represent wheel events: instead of asking downstream packages to use the `mouse-wheel-*-event` variables to know which events represent wheel events, use those variables in `xterm.c` to directly convert those events into the standard `wheel-up/down/left/right` events used everywhere else. This simplifies the work of packages which can now just bind their commands to `wheel-up/down/left/right`. * src/keyboard.c (base_mouse_symbol): New function. * src/keyboard.h (base_mouse_symbol): Declare. * src/xterm.c (x_construct_mouse_click): Obey `mouse-wheel-*-event` vars. (syms_of_xterm): Define the `mouse-wheel-*-event` symbols. * lisp/completion-preview.el (completion-preview--mouse-map): Don't bind to `mouse-wheel-*-event`s any more. * lisp/edmacro.el (edmacro-fix-menu-commands): Remove special casing of `mouse-wheel-*-event`s. * lisp/mwheel.el (mouse-wheel-down-event, mouse-wheel-up-event): Remove :set. (mouse-wheel--setup-bindings): Don't bind to `mouse-wheel-*-event`s any more. * lisp/progmodes/flymake.el (flymake--mode-line-counter-map): Don't bind to `mouse-wheel-*-event`s any more if Emacs is recent enough. --- lisp/completion-preview.el | 10 +--------- lisp/edmacro.el | 8 +------- lisp/mwheel.el | 31 +++++++++++-------------------- lisp/progmodes/flymake.el | 19 +++++++++---------- src/fns.c | 1 + src/keyboard.c | 9 +++++++++ src/keyboard.h | 2 +- src/xterm.c | 31 +++++++++++++++++++++++++++++-- 8 files changed, 62 insertions(+), 49 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 6fd60f3c416..6bbf1246a9a 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -52,8 +52,6 @@ ;;; Code: -(require 'mwheel) - (defgroup completion-preview nil "In-buffer completion preview." :group 'completion) @@ -135,14 +133,8 @@ completion-preview--mouse-map "" #'completion-preview-insert "C-" #'completion-at-point "" #'completion-at-point - ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events - ;; and vice versa!! "" #'completion-preview-prev-candidate - "" #'completion-preview-next-candidate - (key-description (vector mouse-wheel-up-event)) - #'completion-preview-next-candidate - (key-description (vector mouse-wheel-down-event)) - #'completion-preview-prev-candidate) + "" #'completion-preview-next-candidate) (defvar-local completion-preview--overlay nil) diff --git a/lisp/edmacro.el b/lisp/edmacro.el index abfc380d154..a80fe973240 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -725,10 +725,6 @@ edmacro-fix-menu-commands (let (result) ;; Not preloaded in a --without-x build. (require 'mwheel) - (defvar mouse-wheel-down-event) - (defvar mouse-wheel-up-event) - (defvar mouse-wheel-right-event) - (defvar mouse-wheel-left-event) ;; Make a list of the elements. (setq macro (append macro nil)) (dolist (ev macro) @@ -744,9 +740,7 @@ edmacro-fix-menu-commands ;; info is recorded in macros to make this possible. ((or (mouse-event-p ev) (mouse-movement-p ev) (memq (event-basic-type ev) - `( ,mouse-wheel-down-event ,mouse-wheel-up-event - ,mouse-wheel-right-event ,mouse-wheel-left-event - wheel-down wheel-up wheel-left wheel-right))) + '(wheel-down wheel-up wheel-left wheel-right))) nil) (noerror nil) (t diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 66a1fa1a706..82a2c48fd5d 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -65,15 +65,13 @@ mouse-wheel-down-event (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) "Event used for scrolling down, beside `wheel-up', if any." :group 'mouse - :type 'symbol - :set #'mouse-wheel-change-button) + :type 'symbol) (defcustom mouse-wheel-up-event (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5) "Event used for scrolling up, beside `wheel-down', if any." :group 'mouse - :type 'symbol - :set #'mouse-wheel-change-button) + :type 'symbol) (defcustom mouse-wheel-click-event 'mouse-2 "Event that should be temporarily inhibited after mouse scrolling. @@ -464,25 +462,18 @@ mouse-wheel--setup-bindings (cond ;; Bindings for changing font size. ((and (consp binding) (eq (cdr binding) 'text-scale)) - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - 'wheel-down 'wheel-up)) - (when event - (mouse-wheel--add-binding `[,(append (car binding) (list event))] - 'mouse-wheel-text-scale)))) + (dolist (event '(wheel-down wheel-up)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-text-scale))) ((and (consp binding) (eq (cdr binding) 'global-text-scale)) - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - 'wheel-down 'wheel-up)) - (when event - (mouse-wheel--add-binding `[,(append (car binding) (list event))] - 'mouse-wheel-global-text-scale)))) + (dolist (event '(wheel-down wheel-up)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-global-text-scale))) ;; Bindings for scrolling. (t - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - mouse-wheel-left-event mouse-wheel-right-event - 'wheel-down 'wheel-up 'wheel-left 'wheel-right)) - (when event - (dolist (key (mouse-wheel--create-scroll-keys binding event)) - (mouse-wheel--add-binding key 'mwheel-scroll)))))))) + (dolist (event '(wheel-down wheel-up wheel-left wheel-right)) + (dolist (key (mouse-wheel--create-scroll-keys binding event)) + (mouse-wheel--add-binding key 'mwheel-scroll))))))) (when mouse-wheel-mode (mouse-wheel--setup-bindings)) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 5974f076556..1411a669891 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -114,10 +114,6 @@ (require 'thingatpt) ; end-of-thing (require 'warnings) ; warning-numeric-level, display-warning (require 'compile) ; for some faces -;; We need the next `require' to avoid compiler warnings and run-time -;; errors about mouse-wheel-up/down-event in builds --without-x, where -;; mwheel is not preloaded. -(require 'mwheel) ;; when-let*, if-let*, hash-table-keys, hash-table-values: (eval-when-compile (require 'subr-x)) (require 'project) @@ -1637,16 +1633,19 @@ flymake--mode-line-counter-scroll-next (defvar flymake--mode-line-counter-map (let ((map (make-sparse-keymap))) - ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events - ;; and vice versa!! - (define-key map (vector 'mode-line mouse-wheel-down-event) - #'flymake--mode-line-counter-scroll-prev) (define-key map [mode-line wheel-down] #'flymake--mode-line-counter-scroll-next) - (define-key map (vector 'mode-line mouse-wheel-up-event) - #'flymake--mode-line-counter-scroll-next) (define-key map [mode-line wheel-up] #'flymake--mode-line-counter-scroll-prev) + (when (< emacs-major-version 30) + (require 'mwheel) + (defvar mouse-wheel-down-event) (defvar mouse-wheel-up-event) + ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events + ;; and vice versa!! + (define-key map (vector 'mode-line mouse-wheel-down-event) + #'flymake--mode-line-counter-scroll-prev) + (define-key map (vector 'mode-line mouse-wheel-up-event) + #'flymake--mode-line-counter-scroll-next)) map)) (defun flymake--mode-line-counter-1 (type) diff --git a/src/fns.c b/src/fns.c index e4fa8157000..48d7b217cb6 100644 --- a/src/fns.c +++ b/src/fns.c @@ -4855,6 +4855,7 @@ check_mutable_hash_table (Lisp_Object obj, struct Lisp_Hash_Table *h) HASH is a previously computed hash code of KEY. Value is the index of the entry in H matching KEY. */ +/* FIXME: Callers shouldn't care about the return value! */ ptrdiff_t hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, hash_hash_t hash) diff --git a/src/keyboard.c b/src/keyboard.c index 1f7253a7da1..7c1822b3423 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7597,6 +7597,15 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, Lisp_Object symbol_kin /* Apply modifiers to that symbol. */ return apply_modifiers (modifiers, value); } + +Lisp_Object +base_mouse_symbol (int button) +{ + return modify_event_symbol (button, 0, + Qmouse_click, Vlispy_mouse_stem, + NULL, &mouse_syms, ASIZE (mouse_syms)); +} + /* Convert a list that represents an event type, such as (ctrl meta backspace), into the usual representation of that diff --git a/src/keyboard.h b/src/keyboard.h index 68e68bc2ae3..083b16e4896 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -456,7 +456,7 @@ #define EVENT_HEAD_KIND(event_head) \ extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, bool *, struct timespec *); extern int parse_solitary_modifier (Lisp_Object symbol); - +extern Lisp_Object base_mouse_symbol (int button); /* This is like Vthis_command, except that commands never set it. */ extern Lisp_Object real_this_command; diff --git a/src/xterm.c b/src/xterm.c index c8a43785564..fcbe7a1ec4f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14553,8 +14553,6 @@ x_construct_mouse_click (struct input_event *result, int x = event->x; int y = event->y; - /* Make the event type NO_EVENT; we'll change that when we decide - otherwise. */ result->kind = MOUSE_CLICK_EVENT; result->code = event->button - Button1; result->timestamp = event->time; @@ -14564,6 +14562,30 @@ x_construct_mouse_click (struct input_event *result, ? up_modifier : down_modifier)); + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ +#ifdef HAVE_XINPUT2 + if (!dpyinfo->supports_xi2) +#endif + { + Lisp_Object base = base_mouse_symbol (result->code); + int wheel + /* BEWARE: `mouse-wheel-UP-event' corresponds to + `wheel-DOWN' events and vice versa!! */ + = BASE_EQ (base, find_symbol_value (Qmouse_wheel_up_event)) ? 0 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_down_event)) ? 1 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_left_event)) ? 2 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_right_event)) ? 3 + : -1; + if (wheel >= 0) + { + result->kind = (event->type != ButtonRelease ? NO_EVENT + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); + result->code = 0; /* Not used. */ + result->modifiers &= ~(up_modifier || down_modifier); + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; + } + } + /* If result->window is not the frame's edit widget (which can happen with GTK+ scroll bars, for example), translate the coordinates so they appear at the correct position. */ @@ -32444,6 +32466,11 @@ syms_of_xterm (void) DEFSYM (Qexpose, "expose"); DEFSYM (Qdont_save, "dont-save"); + DEFSYM (Qmouse_wheel_down_event, "mouse-wheel-down-event"); + DEFSYM (Qmouse_wheel_up_event, "mouse-wheel-up-event"); + DEFSYM (Qmouse_wheel_left_event, "mouse-wheel-left-event"); + DEFSYM (Qmouse_wheel_right_event, "mouse-wheel-right-event"); + #ifdef USE_GTK xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); staticpro (&xg_default_icon_file); -- 2.43.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 29 19:42:31 2024 Received: (at control) by debbugs.gnu.org; 30 Jan 2024 00:42:32 +0000 Received: from localhost ([127.0.0.1]:33963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUcCt-0005s3-Lu for submit@debbugs.gnu.org; Mon, 29 Jan 2024 19:42:31 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:44137) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUcCr-0005rf-Sr for control@debbugs.gnu.org; Mon, 29 Jan 2024 19:42:30 -0500 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2cf591d22dfso22929371fa.0 for ; Mon, 29 Jan 2024 16:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706575335; x=1707180135; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=nNFdMfff8mvCrPzLl4G766XkEdkJJvTTKzTrE2QXWb0=; b=JOnb1Ibw30ZyDUvSsIgKhLTlU/E7128hzggWNCcbG2anKOvFf+S3dArOICFTsOqxfp +qxDgrNIMNQVHfXcqfO42IcTcHf/ojdbNiUd+CS8Ne28oE7Grw1D32g/f2rcOwQUltwR IVHN77G60aCpYs1C+O8qpeJIND5CmIoybXpsgsZFT3pec2wNDHKBs6IFM7P7eO88DGf3 B5phm98me8VbwG5uWy5dehVALqATCeFivo0W3sR5w73FtGoi3d3+WA3FsSYflBhNhkFC nkW/5ohnoF+pOHRE529f4wLKpWMPVKuSl8Ytjw+ML8AGAlt9pT0Z2Ib0+dhye32OKq82 HO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706575335; x=1707180135; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nNFdMfff8mvCrPzLl4G766XkEdkJJvTTKzTrE2QXWb0=; b=UwDy0y6tAB5jO+BKuntaFMqZ4KmaVyt818YRb5K1JiPNBPi+swZAUqSkZqDyqzyVnW xGm1KPCXfNJgZGIDd6BcaeeLpXr5WjJtB15DteeyavUkxv0yNsiOd2gnqlRqYN0qHmee 3wYbEFjIwkJLAyIo041JM/QnZI2+Womy5R4q0x4SmwTx+RS9r50OIFn7l23t8k1GJfXh FYuUZWrZFskNVBGLFGl8bWxx5ujeUN9gJ7EijqCDJpPImwwNwhe5izPBIFaq96QCKE9l aBlrEYgoDIuk36FuuzoBgStATTkTRxELJhQWFrXtiExQ6DyemMsf552umoDCu3qpLuNq 36KA== X-Gm-Message-State: AOJu0YxGvjM6Dp4EvfOzQhHW24G7aH/s/wM2Q8Qk9L+xOHVr0poKawpN L/ZN9a33lYqvnTfQVg7YgBncG/e9VNdtDaAXJ7ZTqOnXDldMkqb2kaTq2BndeoPNkiCayqoGmMb UXhsl3ZPyPs9Si16Fhp32vDp20tfvYmxn9WA= X-Google-Smtp-Source: AGHT+IEahMiBTCaVMTDwc4JlHostRkz3UsZCmz4M+xtLX78+M8tDOZ8ZMe7YL0veoTBj5rmgymUBaxThV4BFNY7AASI= X-Received: by 2002:a2e:bc85:0:b0:2d0:49f6:2f47 with SMTP id h5-20020a2ebc85000000b002d049f62f47mr3471506ljf.38.1706575335283; Mon, 29 Jan 2024 16:42:15 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 29 Jan 2024 19:42:15 -0500 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 29 Jan 2024 19:42:15 -0500 Message-ID: Subject: control message for bug #68796 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 68796 wishlist quit From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jan 2024 02:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170658005720151 (code B ref 68796); Tue, 30 Jan 2024 02:01:03 +0000 Received: (at 68796) by debbugs.gnu.org; 30 Jan 2024 02:00:57 +0000 Received: from localhost ([127.0.0.1]:34076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUdQm-0005Ew-Sh for submit@debbugs.gnu.org; Mon, 29 Jan 2024 21:00:57 -0500 Received: from sonic308-10.consmr.mail.ne1.yahoo.com ([66.163.187.33]:34144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUdQk-0005Eh-Aa for 68796@debbugs.gnu.org; Mon, 29 Jan 2024 21:00:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1706580038; bh=gzy5P9ZVUiwUTEQUotATTA8FXbVArI9Zq6zL2wtJhd0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=ChEqgQ78SknNpmUPat/piLqqB9JHPIln6TlzeNa0Lgc8YrAP4l17x+XJUkJrSzdkLY6wgfG8WqbRNtwghOJIIdjXjomrTWI+s7LrDT7/cQNCxCH5FzvdT+DFncZgCXjcrfC51N1sGiA/ZRT1U/ry73yJHLEnIVSTo1oSvHG977wCB3MP5mQYExlECPzssGSlYfsMbaKv/bdymFWtO6yRbBG3U4o1Izc3N3oUBUZqxwY/iEBerCXQgbxSvUYUVflQA2/1sVmzxsA/y83hUaxZcCNq6ZilJvfGFzvM23KZsK5Fip/jSbmtbljCMZrPlqNSX4suusUv34CPPL+gVIQDMQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1706580038; bh=x3baItDJcRmivA9/Pl0P5EKk6nGNAVXHxqZsTJRTf1H=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=THlJ3uYjXgJmZ1E3t7SufNsxHYG/1Yk/td8TVkcjg0/91uGhQm4a4NaOYyjlnXGNe+9TO5rTEBeHppGq7D0Csb57JwJfN53OI3mGGY4beh9oHQCi1VOeiY6g1Mxc3MruEM6a0k8yejSm3Uo1RGcSDpQCzKB5Uy8jSueOluwJd0vCyNUHy4cRkEiqXW3D4B5Y2MLerNWUyzHofTUOpAJg/Cayia5hAah7KUzsPmdCbErwGn6wTTZBKRNR5YBoYHvVZMqz17UWp2YeeuXAdxOLltf5/pkol+FBMQO2aEZLhxiaygWJD/jfJ09LPqMTMV9cpXx1j7ImLf5WQ6m/7qvaRg== X-YMail-OSG: dmr08T0VM1mubSZI9ewD59gnhRgbTblIeSDB4.YZYfV_tI1eqVoCIp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ffdB8beUnvNPoHtlZuLKe4pJBzhNAtldkGTKyKQAG5PO6bPHI.cmr7i9YAHYNZOBC4_4_LfQWpl v7CVOTiDHXkokUm0YvzbD2dVq9b35gRgRMYWORBM5VxR9oR3UXZ_eZagrpdyO_fw0llTdqciSKOX dHu2le.0- X-Sonic-MF: X-Sonic-ID: 1e8b4973-028e-4ca0-91f7-501408d63369 Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Tue, 30 Jan 2024 02:00:38 +0000 Received: by hermes--production-sg3-6dc75bc8fb-dgkh5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID f2e1ce3e8951fe762de0f19ab4da2102; Tue, 30 Jan 2024 02:00:29 +0000 (UTC) From: Po Lu In-Reply-To: (Stefan Monnier's message of "Mon, 29 Jan 2024 09:45:01 -0500") References: Date: Tue, 30 Jan 2024 10:00:17 +0800 Message-ID: <871q9zh972.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22046 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 3194 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >>>From 60e6903ae12546db93f149b1f184ffc7ccdc30c2 Mon Sep 17 00:00:00 2001 > From: Stefan Monnier > Date: Mon, 29 Jan 2024 09:35:09 -0500 > Subject: [PATCH] xterm.c: Map old-style wheel buttons to actual wheel events > > Change the handling of the old X11 convention to use mouse-4/5/6/7 > events to represent wheel events: instead of asking downstream > packages to use the `mouse-wheel-*-event` variables to know which events > represent wheel events, use those variables in `xterm.c` to directly > convert those events into the standard `wheel-up/down/left/right` events > used everywhere else. > > This simplifies the work of packages which can now just bind their > commands to `wheel-up/down/left/right`. I'm still opposed to this for reasons I will try to communicate below. First, there are several logic errors in this patch: > + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ > +#ifdef HAVE_XINPUT2 > + if (!dpyinfo->supports_xi2) > +#endif dpyinfo->supports_xi2 is no guarantee that exclusively input extension events will be received, but only indicates that the X display supports the input extension. There are several scenarios where it may be true while core events are still delivered to windows, such as a combination of GTK 3 and GDK_CORE_DEVICE_EVENTS=1's being enabled. The correct test of event type is whether x_construct_mouse_click is being called from the XI_ButtonPress or XI_ButtonRelease label in handle_one_xevent. Incidentally, servers with the input extension always assign buttons 4 through 7 to wheel movement. > + Lisp_Object base = base_mouse_symbol (result->code); > + int wheel > + /* BEWARE: `mouse-wheel-UP-event' corresponds to > + `wheel-DOWN' events and vice versa!! */ > + = BASE_EQ (base, find_symbol_value (Qmouse_wheel_up_event)) ? 0 > + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_down_event)) ? 1 > + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_left_event)) ? 2 > + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_right_event)) ? 3 > + : -1; > + if (wheel >= 0) > + { > + result->kind = (event->type != ButtonRelease ? NO_EVENT > + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); > + result->code = 0; /* Not used. */ > + result->modifiers &= ~(up_modifier || down_modifier); > + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; > + } > + } Isn't this insufficient to completely supersede mouse events by wheel events, considering that such events will still be delivered as mouse button events to tab bars? Lastly, plenty of old code that binds just the button events will be broken, and the code that keeps track of button-down and up events in read_key_sequence and friends will cease applying to X wheel events. This area has given me a lot of grief over the years (as it has given you), so I'm reluctant to see any change there, as no matter how well the argument in favor of its safety is posed, some unforeseen problem invariably emerges afterwards. From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jan 2024 03:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170658557028916 (code B ref 68796); Tue, 30 Jan 2024 03:33:02 +0000 Received: (at 68796) by debbugs.gnu.org; 30 Jan 2024 03:32:50 +0000 Received: from localhost ([127.0.0.1]:34093 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUerh-0007WJ-Ha for submit@debbugs.gnu.org; Mon, 29 Jan 2024 22:32:50 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUere-0007W3-IP for 68796@debbugs.gnu.org; Mon, 29 Jan 2024 22:32:47 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 85FBA100134; Mon, 29 Jan 2024 22:32:31 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1706585550; bh=RJ0LQpGjdoCsuxgbgxWRKsgbPbpL+nl8GuZpvmRo8a0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Thr3tXD+qBBGoqYWnbzP3cmusJ2ceDSNDdw7kXLb1ONv5assiRbCwEOL+bPDBs2Ye nOXSBiCbE7bFZr6Q+E3tZXxkfRtvsIwYZjBuY/FLI20WGT+gkpkOc9QRq/gVp/Plm0 pqv8RL0oOILkJ7eukJ++EtL7ROahfvlQi7T7BWqoKNlpIhkf0ptr+2dTe3oeCsB3SL iLX3+yxAclCA+qaA4iIwaW905k5ncIwjBerYtn0ltcemQzGlzQC22goSO+/K/xzabc zEerVyG8dmg6ECV57exTVUxx7SUv2EnNN0UgrZJW6UTO+Q9gEDiYwAvB/u05XMhl4R /UUE+RlSTFBMQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3A21C10009E; Mon, 29 Jan 2024 22:32:30 -0500 (EST) Received: from pastel (unknown [45.72.206.68]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 04BF1120403; Mon, 29 Jan 2024 22:32:29 -0500 (EST) From: Stefan Monnier In-Reply-To: <871q9zh972.fsf@yahoo.com> (Po Lu's message of "Tue, 30 Jan 2024 10:00:17 +0800") Message-ID: References: <871q9zh972.fsf@yahoo.com> Date: Mon, 29 Jan 2024 22:32:29 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.116 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ >> +#ifdef HAVE_XINPUT2 >> + if (!dpyinfo->supports_xi2) >> +#endif > > dpyinfo->supports_xi2 is no guarantee that exclusively input extension > events will be received, but only indicates that the X display supports > the input extension. There are several scenarios where it may be true > while core events are still delivered to windows, such as a combination > of GTK 3 and GDK_CORE_DEVICE_EVENTS=3D1's being enabled. Hmm... so IIUC you're saying that even when `dpyinfo->supports_xi2` is true, we may receive `mouse-4/5/6/7` events for wheel motions? Yuck! > The correct test of event type is whether x_construct_mouse_click is > being called from the XI_ButtonPress or XI_ButtonRelease label in > handle_one_xevent. OK, that sounds fixable. See additional patch below. > Incidentally, servers with the input extension always assign buttons 4 > through 7 to wheel movement. Interesting. >> + Lisp_Object base =3D base_mouse_symbol (result->code); >> + int wheel >> + /* BEWARE: `mouse-wheel-UP-event' corresponds to >> + `wheel-DOWN' events and vice versa!! */ >> + =3D BASE_EQ (base, find_symbol_value (Qmouse_wheel_up_event))= ? 0 >> + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_down_event))= ? 1 >> + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_left_event))= ? 2 >> + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_right_event)= ) ? 3 >> + : -1; >> + if (wheel >=3D 0) >> + { >> + result->kind =3D (event->type !=3D ButtonRelease ? NO_EVENT >> + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); >> + result->code =3D 0; /* Not used. */ >> + result->modifiers &=3D ~(up_modifier || down_modifier); >> + result->modifiers |=3D wheel & 1 ? up_modifier : down_modifie= r; >> + } >> + } > > Isn't this insufficient to completely supersede mouse events by wheel > events, considering that such events will still be delivered as mouse > button events to tab bars? Hmm... indeed there was a crash here, which I just fixed in the patch below. But with that fix, I do see `wheel-up/down` events on the tab-tab as well. Am I missing something? > Lastly, plenty of old code that binds just the button events will be > broken, Indeed. But that should be a disappearing breed because such bindings never worked under non-X11 GUIs and now they don't work either under X11 builds that use XInput2, which I expect is the vast majority of Emacs=E2=89= =A529 builds in GNU/Linux distributions. > and the code that keeps track of button-down and up events in > read_key_sequence and friends will cease applying to X wheel events. Hmm... the only code I can think of in `read_key_sequence` which cares about button up/down is the code that drops the button down events and the one that turns pairs into drag events. Is that ever useful currently with the `mouse-4/5/6/7` events? No one has lamented this under non-X11 builds so far nor under XInput2, so it seems unlikely to be a problem. > This area has given me a lot of grief over the years (as it has given > you), so I'm reluctant to see any change there, as no matter how well > the argument in favor of its safety is posed, some unforeseen problem > invariably emerges afterwards. There's no doubt that event representation is a delicate/nasty part of Emacs code, but I think it's really a trade-off between possible short-term pain and the longer term simplification of unifying all wheel handling under `wheel-*` events. Also, I think we *will* have go through that pain sooner or later. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=xterm-wheel-events.patch diff --git a/src/keyboard.c b/src/keyboard.c index 7c1822b3423..a881c3d6117 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6628,8 +6628,13 @@ make_lispy_event (struct input_event *event) if (CONSP (event->arg)) return list5 (head, position, make_fixnum (double_click_count), - XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)), - XCAR (XCDR (XCDR (event->arg))))); + XCAR (event->arg), + /* FIXME: I don't know what I'm doing here. */ + (CONSP (XCDR (event->arg)) + && CONSP (XCDR (XCDR (event->arg)))) + ? Fcons (XCAR (XCDR (event->arg)), + XCAR (XCDR (XCDR (event->arg)))) + : Qnil); else if (NUMBERP (event->arg)) return list4 (head, position, make_fixnum (double_click_count), event->arg); diff --git a/src/xterm.c b/src/xterm.c index fcbe7a1ec4f..237b705b555 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14548,7 +14548,7 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, static Lisp_Object x_construct_mouse_click (struct input_event *result, const XButtonEvent *event, - struct frame *f) + struct frame *f, bool xi2) { int x = event->x; int y = event->y; @@ -14563,9 +14563,7 @@ x_construct_mouse_click (struct input_event *result, : down_modifier)); /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ -#ifdef HAVE_XINPUT2 - if (!dpyinfo->supports_xi2) -#endif + if (!xi2) { Lisp_Object base = base_mouse_symbol (result->code); int wheel @@ -21895,13 +21893,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, f, false); *finish = X_EVENT_DROP; goto OTHER; @@ -21971,13 +21970,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; @@ -23754,13 +23755,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, && xev->time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); } if (xev->evtype == XI_ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; --=-=-=-- From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jan 2024 03:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170658686931462 (code B ref 68796); Tue, 30 Jan 2024 03:55:01 +0000 Received: (at 68796) by debbugs.gnu.org; 30 Jan 2024 03:54:29 +0000 Received: from localhost ([127.0.0.1]:34107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUfCf-0008BN-0T for submit@debbugs.gnu.org; Mon, 29 Jan 2024 22:54:29 -0500 Received: from sonic315-22.consmr.mail.ne1.yahoo.com ([66.163.190.148]:40139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUfCb-0008B8-QO for 68796@debbugs.gnu.org; Mon, 29 Jan 2024 22:54:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1706586851; bh=427KdDbdSrydUSORnNJ6hXC+DZtQVToHuwfA1w0TLIM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=ctps7cpFIDvMfWUtC8CHtcRUJGapEQyu2yMvZLDzA/NwsYncz3tAVXoU2/hpToihFHLQ0qCu1OHTS46RQhz612MzUBJNAsq686vPV61j1Q9Fz6UVnaPIGT4UG1V7it3Q9i2/IHYe+CVPk7MtPKI4+fB097vz55eEjFF9UZWptjzXd/nDfahgke0DKChme5V8HaTXenoc18bH5OQlpPN31HGhlJ0epwNiR0jyqV6Q3oeiclLLDzEn2uuM6ZanN4WTw3+/KRfNw1SRMQbUI/rxdqTB/7v6hiUTDPj1Cmc7t91S4wTDYjipvfztiQJiMBIoOR2qMacCfVl29iBdpmO6HA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1706586851; bh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1ZkOp9TPPCFvWo3NrT8kkdaTkPSvJfPvXIEMXlZAZ5Rl0q4KNSBJWfWdwNBeTFG.lfBs15xg2tMb 2fIgIdHnIBlAVgi5BmNZvuVqOr7K3uSuvBqNv5POVjfUOjHtIHNUcAosNmqXKipoRA0xGWOQSTck QJAlyvaz1G2v5gcY9GP7wITsWbkElHEE73EFV31huizu2c8gEZcqbgAgbxCdejrtSJh724lyEzhe kuMXtXd64f94zYnXDiShV46xakDTFw5SsJXrJMk71DI2Q6n9mhvu8J9ux.VmTDgU0wS1Nb5zUvVd T.DSMwOwMC6HU2IIV.Tz7P8Lb0ASLuYa4ECvvmzfTH8gTSp4a5piREC.vDnjrNLcfvc5yg2M57GG Ouch67NHKKPaW_ek3vawfESf7xWNnspyJrijUe_HRc6OS0f4fQDBGemdmcPNv4a9Osylo949h9ka M0nGvXTqMf8Pmxydu7tvUsN9XdF5uBMhtR_sFtUliVnCCd4UTqL2sGve8aLqeNknrv9KU0SN1I2f C2DpCvnAHO9OspClH5diSYue0mUIFbMadSGQNvwhKRnsJSuz_Br1l1JlpZXsMDhcKew-- X-Sonic-MF: X-Sonic-ID: 3163baba-c965-4c31-a142-d8849268d9c1 Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Tue, 30 Jan 2024 03:54:11 +0000 Received: by hermes--production-sg3-6dc75bc8fb-r5vvk (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 894b0a61197c296d3dd2f07d2395652a; Tue, 30 Jan 2024 03:54:03 +0000 (UTC) From: Po Lu In-Reply-To: (Stefan Monnier's message of "Mon, 29 Jan 2024 22:32:29 -0500") References: <871q9zh972.fsf@yahoo.com> Date: Tue, 30 Jan 2024 11:53:58 +0800 Message-ID: <87r0hzfpd5.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22046 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 618 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > Hmm... so IIUC you're saying that even when `dpyinfo->supports_xi2` is > true, we may receive `mouse-4/5/6/7` events for wheel motions? > Yuck! Yes, and as always other clients may send whatever they want, although Emacs is not obliged to handle those events correctly. >> The correct test of event type is whether x_construct_mouse_click is >> being called from the XI_ButtonPress or XI_ButtonRelease label in >> handle_one_xevent. > > OK, that sounds fixable. See additional patch below. Thanks. I'm short on time at the moment, but will get around to this. From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2024 08:56:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: monnier@iro.umontreal.ca, 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170755532230287 (code B ref 68796); Sat, 10 Feb 2024 08:56:03 +0000 Received: (at 68796) by debbugs.gnu.org; 10 Feb 2024 08:55:22 +0000 Received: from localhost ([127.0.0.1]:53639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYj8r-0007sK-KW for submit@debbugs.gnu.org; Sat, 10 Feb 2024 03:55:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYj7h-0007mm-3y for 68796@debbugs.gnu.org; Sat, 10 Feb 2024 03:54:09 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rYif4-0006Cz-TZ; Sat, 10 Feb 2024 03:24:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=pBpYAwAlSPEGRm4j9NhnVtNoi2o2recHUnDxNJfbuhg=; b=lQQRnstZafWs m8AYIqVQHZAteph3HaatMcY8KNmaa1S0rXwigTRDtU2OeHgB/iK/9p+5sOoE9Wl+EL/IuAs7h0qKc ShX08EUepqGL0oFbk4Njk+DUw2H0vxOXKFqi9XlOFy6tREMWHix3w4wOMB1K+FIXP9+HBeEWixZo1 righz4UwgJ+jxk3z0D2IVqOh1nVALDmQuRRQ59U6LSfZKNeD1bFTf0Ff7QzBkyxH8LGnP+JqPQnVc r3uj/Qj35XPg3JyKaUOzVlQhOQS4yyJr38FRQXOCQ4pHcS33vbgoryZQXmeVNVHu0nOh6rELCn89I 4ogCRkkiysDnBwyfyGHSeQ==; Date: Sat, 10 Feb 2024 10:24:32 +0200 Message-Id: <86cyt4vi9r.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87r0hzfpd5.fsf@yahoo.com> (bug-gnu-emacs@gnu.org) References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! Can we make some progress here? > Cc: 68796@debbugs.gnu.org > Date: Tue, 30 Jan 2024 11:53:58 +0800 > From: Po Lu via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Stefan Monnier writes: > > > Hmm... so IIUC you're saying that even when `dpyinfo->supports_xi2` is > > true, we may receive `mouse-4/5/6/7` events for wheel motions? > > Yuck! > > Yes, and as always other clients may send whatever they want, although > Emacs is not obliged to handle those events correctly. > > >> The correct test of event type is whether x_construct_mouse_click is > >> being called from the XI_ButtonPress or XI_ButtonRelease label in > >> handle_one_xevent. > > > > OK, that sounds fixable. See additional patch below. > > Thanks. I'm short on time at the moment, but will get around to this. > > > > From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2024 09:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: monnier@iro.umontreal.ca, 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.17075567911969 (code B ref 68796); Sat, 10 Feb 2024 09:20:01 +0000 Received: (at 68796) by debbugs.gnu.org; 10 Feb 2024 09:19:51 +0000 Received: from localhost ([127.0.0.1]:55136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYjWZ-0000Vg-Ef for submit@debbugs.gnu.org; Sat, 10 Feb 2024 04:19:51 -0500 Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]:40299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYjWX-0000VL-AG for 68796@debbugs.gnu.org; Sat, 10 Feb 2024 04:19:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1707556767; bh=QoP+3jO5W9G1VWaqcvh9AB/mAYlVNAtvyLZB66GUrnM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=fY5rgy03174+i96i0VzS6KofEJagUV3tWEFvfHnBvJjSB10LbZUSaTvlBsOx7EZPoXTA173qOO5g7MEDCMQrKove9CvhitjxpoPQiqWDowpzZfnO5h8/7+9mDPxGt9ySyPQ5bZB6Q+JPX/rYUX5WHloU1JkZ3I7egz4HhLcR9EMtgwCMZVw4CfhlhWXl8jQMbawiSwvgBx7vhiEnxQrpSio0TYVV7Nm7D27dvx3xVwVbpwK5pKZnhUR+H56Jagq5NpMUKcs+Qr3i6zAlzRojhDl5ByORY0wz+wa0ElV2g/HLOKF6RmqbDtnf0eof/OCoxAOVHyttLX8roNTenfz2KQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1707556767; bh=RElXFWg4zxdzP+xv5zbpOHGposaK7yFqt7PopmLQWcT=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=EEZB5sGsmL9Z2z7NPiWDefyBmo6zkeMB1oa24LtXs4NCIG8YjpKGD//BBSxaIm465tX3q5WdKabCrPRR6B5FXzkquK+PBRQsgZxRF3G+7xY1Ck0s3jmfKPPwctCO2o2MFuPuASG78dGdM0pDO8rar9j+NsOPZZECh7Ol+bkc/eL23ibRfVcmS3d/PYVHytVWdt6ZsFIrsiiGiLevFwgX9QMUbEv9CbIkBiaIAAY5vjdOFCwXsgBJ6Ne4+oMqEkpbYIPcqArdN29ZXZ0HzsEi540FcVC+QaGxb0Zmv219ALw6V01/B8q2mOvHC1hENGfnjTHOua5mvOnpcf5eOm51HQ== X-YMail-OSG: w7_FydUVM1nvyxwyAUTqW33sQa3rhyLK43X.oBlKlrfoxiIX5gjRMhB1dI2V6GU smuZ0jL3iCckd_m9.q5SOseiPvTIyuh0bcgg5S9afIcO7L8qX6zADwV6tTt6bwbCVGga8ZHAoCm_ QXcMObyPkOnykLklVuyoQUJdckM.yA3fIU6qFpDphM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F: X-Sonic-ID: 416d25bc-a31a-4ce1-9e52-7b3599d46a1f Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Sat, 10 Feb 2024 09:19:27 +0000 Received: by hermes--production-sg3-6dc75bc8fb-qvr7d (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b89bdd9c87a11a1cb550996be7b5b701; Sat, 10 Feb 2024 09:09:21 +0000 (UTC) From: Po Lu In-Reply-To: <86cyt4vi9r.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 10 Feb 2024 10:24:32 +0200") References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> Date: Sat, 10 Feb 2024 17:09:14 +0800 Message-ID: <87y1bs1y9x.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22077 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 781 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Ping! Can we make some progress here? I converted most of the Lisp code at my organization (where X servers are configured with the input extension disabled) to use wheel events under Emacs 30 and arranged for a modified version of Stefan's patch to be built. Which was incidentally not straightforward to do cleanly, as the code in question assumed that events it received would be pairs of button press and release events, and was very much designed around that assumption. Unfortunately the holidays are in full swing, and conclusions from this cannot be drawn until once enough experience accumulates some time after they end. To complicate matters, users at my site don't often work with Emacs 30, except for a few early adopters. From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2024 14:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.17075749498969 (code B ref 68796); Sat, 10 Feb 2024 14:23:01 +0000 Received: (at 68796) by debbugs.gnu.org; 10 Feb 2024 14:22:29 +0000 Received: from localhost ([127.0.0.1]:43872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYoFQ-0002KZ-JV for submit@debbugs.gnu.org; Sat, 10 Feb 2024 09:22:28 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:33087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYoFO-0002K9-IK for 68796@debbugs.gnu.org; Sat, 10 Feb 2024 09:22:27 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 34791442CC3; Sat, 10 Feb 2024 09:22:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1707574923; bh=U3PieQLpGbahdazXdEz1t64NhRpLrPBrH/ipbA0o9RE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MF8r8IoJ7+PNWN7vXOfEDFZbEwpuhbf7m6w/ZgqJ/o5E6WwqCVMtAQlqCOBq5Iwst TtCM+ZnHvtKBbCMz6guaWZlmPf8pog3NCu5lxRgB7j4OfiGbARek+7B7ka4zylLXmw R9kllBVPpws9s2XUNWcu0s5qnlRCdk/lsNd4B3gwlnE9WAqPJ3BLlmucUcNFUlckdu tgzM21FwprfyP4R4FU6aeaP/U1uq01N/MCPCh5B06gBjVAMtbJ3blOVpSCCgwLjL9g zuOzeLiOEjUyrr8pFdt9wc5Vlhy5iMDgFpPCehXlpKOy23sFab0cG4SeRiLs1VQVvJ jPMsOvfqBok7w== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D24E7442CB4; Sat, 10 Feb 2024 09:22:03 -0500 (EST) Received: from pastel (unknown [104.247.238.113]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A7A1F12021A; Sat, 10 Feb 2024 09:22:03 -0500 (EST) From: Stefan Monnier In-Reply-To: <87y1bs1y9x.fsf@yahoo.com> (Po Lu's message of "Sat, 10 Feb 2024 17:09:14 +0800") Message-ID: References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> <87y1bs1y9x.fsf@yahoo.com> Date: Sat, 10 Feb 2024 09:22:02 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.013 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Po Lu [2024-02-10 17:09:14] wrote: > Eli Zaretskii writes: >> Ping! Can we make some progress here? > I converted most of the Lisp code at my organization (where X servers > are configured with the input extension disabled) to use wheel events > under Emacs 30 and arranged for a modified version of Stefan's patch to > be built. Which was incidentally not straightforward to do cleanly, as > the code in question assumed that events it received would be pairs of > button press and release events, and was very much designed around that > assumption. Fascinating. Is there any way I could get to peek at that code? Also interested in the backstory about why your X11 servers are configured without XInput2. Maybe we should provide a better "reverse" story: with the current patch users can recover their old `mouse-4/5/6/7` events by setting `mouse-wheel-*-event` to nil, but then they lose mwheel-based scrolling (plus a few other bindings, mostly one in completion-preview and one in flymake), so the etc/NEWS entry should describe how to recover that scrolling behavior. Or maybe we should keep `mouse-wheel-*-event` untouched (tho, maybe mark them obsolete) and instead introduce a new set of variables that control the remapping of `mouse-4/5/6/7` to `wheel-*` events. That would provide a smoother transition: users can set those new vars to nil to recover the old behavior. Another benefit is that the new var(s) could hold just the button numbers (i.e. an integer) instead of a symbol, which should simplify the remapping code (both in the `xterm.c` and the `xt-mouse.el` cases). Stefan From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2024 15:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170757976322923 (code B ref 68796); Sat, 10 Feb 2024 15:43:01 +0000 Received: (at 68796) by debbugs.gnu.org; 10 Feb 2024 15:42:43 +0000 Received: from localhost ([127.0.0.1]:49682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYpV4-0005xX-8D for submit@debbugs.gnu.org; Sat, 10 Feb 2024 10:42:43 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28987) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYpV0-0005xB-Bq for 68796@debbugs.gnu.org; Sat, 10 Feb 2024 10:42:39 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 32655442CCB; Sat, 10 Feb 2024 10:33:12 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1707579189; bh=JfHqg/t2J9oREE+9M3+jQwi4+g5fexMFeFuR1gfIvI0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=hhLBd06NWGP1KdXaUlbMMVqH61pTCvUKSn19v5ZmzEhmAZrzkR03Ah1mYi4PwSi83 flEZxynXBE4vOIWQNx2LEw+c/OR4MwVkPxIcLnJXI5cbT7Jyx7/rB/5feuhmPhWiiN 0rpZH7GUnGsuAUTELLnTPmURU5tB1RhG0WDxnJQc2cXa6x1xiv8Wa5YoXRa6v1hZ+2 DAksHyecre4XjLxS7GZ/xsWQHWOS+1vPLF9j6vfUREvcUBhb+qR1hyewI1iRNo5feM PDH8lhg6Nofpg7zTTMWEyfvsP7E59JOygrYw8bMf4JMVD6gI+QOniOYrFl7ZC8/tFo oWklXj1g3C2lA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5C6B7440CBC; Sat, 10 Feb 2024 10:33:09 -0500 (EST) Received: from pastel (unknown [104.247.238.113]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2E7911202FC; Sat, 10 Feb 2024 10:33:09 -0500 (EST) From: Stefan Monnier In-Reply-To: (Stefan Monnier's message of "Sat, 10 Feb 2024 09:22:02 -0500") Message-ID: References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> <87y1bs1y9x.fsf@yahoo.com> Date: Sat, 10 Feb 2024 10:33:01 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.013 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain > Or maybe we should keep `mouse-wheel-*-event` untouched (tho, maybe mark > them obsolete) and instead introduce a new set of variables that control > the remapping of `mouse-4/5/6/7` to `wheel-*` events. See patch below. It would need etc/NEWS and doc changes, of course, and probably some warning-silencing in those packages using `mouse-wheel-*-event`s. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-mouse-wheel-buttons-Map-old-style-wheel-buttons-to-a.patch >From 0e94e1140a8ec72bd068648eb5ec1dc861f0884b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 29 Jan 2024 09:35:09 -0500 Subject: [PATCH] (mouse-wheel-buttons): Map old-style wheel buttons to actual wheel events Change the handling of the old X11 convention to use mouse-4/5/6/7 events to represent wheel events: instead of asking downstream packages to use the `mouse-wheel-*-event` variables to know which events represent wheel events, use new var `mouse-wheel-buttons` to directly convert those events into the standard `wheel-up/down/left/right` events used everywhere else. This will simplify the work of packages which can thus just bind their commands to `wheel-up/down/left/right`. * lisp/mouse.el (mouse-wheel-buttons): New custom variable. * src/keyboard.c (make_lispy_event): Adjust for "wheel-clicks" on the tab-bar. * src/xterm.c (x_construct_mouse_click): Add `xi2` argument and obey `mouse-wheel-buttons` variable. (handle_one_xevent): Adjust calls accordingly. (syms_of_xterm): Define the `mouse-wheel-buttons` and the `wheel-up/down/left/right`symbols. * lisp/xt-mouse.el: Don't require `mwheel` any more. (xterm-mouse--same-button-p): Delete function. (xterm-mouse--read-event-sequence): Use `mouse-wheel-buttons`. * lisp/mwheel.el (mouse-wheel-up-event, mouse-wheel-down-event) (mouse-wheel-left-event, mouse-wheel-right-event): Make obsolete. (mouse-wheel-obey-old-style-wheel-buttons): Delete variable. --- lisp/mouse.el | 13 ++++++++++++ lisp/mwheel.el | 21 ++++++++----------- lisp/xt-mouse.el | 20 ++++-------------- src/keyboard.c | 9 ++++++-- src/xterm.c | 53 +++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 75 insertions(+), 41 deletions(-) diff --git a/lisp/mouse.el b/lisp/mouse.el index d1b06c2040d..585891bf699 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -133,6 +133,19 @@ mouse-drag-mode-line-buffer :type 'boolean :version "29.1") +(defcustom mouse-wheel-buttons + '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right)) + "Buttons to remap to wheel events. +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel +events represented as mouse button events. It remaps mouse button event +NUMBER to the event SYMBOL. SYMBOL must be one of `wheel-up', `wheel-down', +`wheel-left', or `wheel-right'. +This is used only for events that come from sources known to generate such +events, such as X11 events when XInput2 is not used, or events coming from +a text terminal." + :type '(alist) + :version "30.1") + (defvar mouse--last-down nil) (defun mouse--down-1-maybe-follows-link (&optional _prompt) diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 66a1fa1a706..9fc922eebc9 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -56,20 +56,17 @@ mouse-wheel-change-button (bound-and-true-p mouse-wheel-mode)) (mouse-wheel-mode 1))) -(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 text-terminals as well.") +(make-obsolete-variable 'mouse-wheel-up-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-down-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-left-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-right-event 'mouse-wheel-buttons "30.1") -(defcustom mouse-wheel-down-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) +(defcustom mouse-wheel-down-event 'mouse-4 "Event used for scrolling down, beside `wheel-up', if any." :group 'mouse :type 'symbol :set #'mouse-wheel-change-button) - -(defcustom mouse-wheel-up-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5) +(defcustom mouse-wheel-up-event 'mouse-5 "Event used for scrolling up, beside `wheel-down', if any." :group 'mouse :type 'symbol @@ -223,12 +220,10 @@ mwheel-scroll-left-function (defvar mwheel-scroll-right-function 'scroll-right "Function that does the job of scrolling right.") -(defvar mouse-wheel-left-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-6) +(defvar mouse-wheel-left-event 'mouse-6 "Event used for scrolling left, beside `wheel-left', if any.") -(defvar mouse-wheel-right-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-7) +(defvar mouse-wheel-right-event 'mouse-7 "Event used for scrolling right, beside `wheel-right', if any.") (defun mouse-wheel--get-scroll-window (event) diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 081b8f32456..c27dee7e249 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -40,8 +40,6 @@ ;;; Code: -(require 'mwheel) - (defvar xterm-mouse-debug-buffer nil) (defun xterm-mouse-translate (_event) @@ -195,12 +193,6 @@ xterm-mouse--read-number-from-terminal (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 ;; in default mode, and ;; ";" ";" <"M" or "m"> in extended mode. @@ -246,14 +238,10 @@ xterm-mouse--read-event-sequence (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)))))))) + (let ((remap (alist-get btn mouse-wheel-buttons))) + (if remap + (symbol-name remap) + (format "mouse-%d" btn)))))))) (list sym (1- x) (1- y)))) (defun xterm-mouse--set-click-count (event click-count) diff --git a/src/keyboard.c b/src/keyboard.c index 1f7253a7da1..4c3e33762af 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6628,8 +6628,13 @@ make_lispy_event (struct input_event *event) if (CONSP (event->arg)) return list5 (head, position, make_fixnum (double_click_count), - XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)), - XCAR (XCDR (XCDR (event->arg))))); + XCAR (event->arg), + /* FIXME: I don't know what I'm doing here. */ + (CONSP (XCDR (event->arg)) + && CONSP (XCDR (XCDR (event->arg)))) + ? Fcons (XCAR (XCDR (event->arg)), + XCAR (XCDR (XCDR (event->arg)))) + : Qnil); else if (NUMBERP (event->arg)) return list4 (head, position, make_fixnum (double_click_count), event->arg); diff --git a/src/xterm.c b/src/xterm.c index c8a43785564..e75b64ed3d4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14543,18 +14543,19 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, `x', `y', `x_root' and `y_root'. This function should not access any other fields in EVENT without also initializing the corresponding fields in `bv' under the XI_ButtonPress and - XI_ButtonRelease labels inside `handle_one_xevent'. */ + XI_ButtonRelease labels inside `handle_one_xevent'. + + XI2 indicates that this click comes from XInput2 rather than core + event. */ static Lisp_Object x_construct_mouse_click (struct input_event *result, const XButtonEvent *event, - struct frame *f) + struct frame *f, bool xi2) { int x = event->x; int y = event->y; - /* Make the event type NO_EVENT; we'll change that when we decide - otherwise. */ result->kind = MOUSE_CLICK_EVENT; result->code = event->button - Button1; result->timestamp = event->time; @@ -14564,6 +14565,29 @@ x_construct_mouse_click (struct input_event *result, ? up_modifier : down_modifier)); + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ + if (!xi2) + { + Lisp_Object base + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), + Fsymbol_value (Qmouse_wheel_buttons))); + int wheel + = NILP (base) ? -1 + : BASE_EQ (base, Qwheel_down) ? 0 + : BASE_EQ (base, Qwheel_up) ? 1 + : BASE_EQ (base, Qwheel_left) ? 2 + : BASE_EQ (base, Qwheel_right) ? 3 + : -1; + if (wheel >= 0) + { + result->kind = (event->type != ButtonRelease ? NO_EVENT + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); + result->code = 0; /* Not used. */ + result->modifiers &= ~(up_modifier || down_modifier); + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; + } + } + /* If result->window is not the frame's edit widget (which can happen with GTK+ scroll bars, for example), translate the coordinates so they appear at the correct position. */ @@ -21873,13 +21897,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, f, false); *finish = X_EVENT_DROP; goto OTHER; @@ -21949,13 +21974,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; @@ -23732,13 +23759,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, && xev->time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); } if (xev->evtype == XI_ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; @@ -32444,6 +32471,12 @@ syms_of_xterm (void) DEFSYM (Qexpose, "expose"); DEFSYM (Qdont_save, "dont-save"); + DEFSYM (Qmouse_wheel_buttons, "mouse-wheel-buttons"); + DEFSYM (Qwheel_up, "wheel-up"); + DEFSYM (Qwheel_down, "wheel-down"); + DEFSYM (Qwheel_left, "wheel-left"); + DEFSYM (Qwheel_right, "wheel-right"); + #ifdef USE_GTK xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); staticpro (&xg_default_icon_file); -- 2.43.0 --=-=-=-- From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Mar 2024 16:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170948300031389 (code B ref 68796); Sun, 03 Mar 2024 16:24:01 +0000 Received: (at 68796) by debbugs.gnu.org; 3 Mar 2024 16:23:20 +0000 Received: from localhost ([127.0.0.1]:41015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgocR-0008AC-CI for submit@debbugs.gnu.org; Sun, 03 Mar 2024 11:23:20 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgocO-00089y-JR for 68796@debbugs.gnu.org; Sun, 03 Mar 2024 11:23:18 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A123780A90; Sun, 3 Mar 2024 11:22:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1709482959; bh=lB4KMugO219+731pOueNyNlYHVTQ+OwCC7Lhszl3t04=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=XDHxVpYDFsODtwmtV4dDeQZFwo+mk6CCukL9xpizLRTZkn9hVD4fr/A4f5rl5JiMz IRuAEMKK4d3Pj9wYEjq1V15eSAvU6v8F/HvaoVX8wlR2PxklKNb73DiH937UEBe+YR P5uUPEqup4cO7VHKT3Wen9psZw4xu6aO/4l+iS6y/sdk6fnNpmA0x331MJC6LeZBpC SShzGiltydL/Z9xsL6ixoIRygreP9IZiZCn3995wugb1NYevBeJXQwdkU6d5VPCWwq Mc8Jbjkfui+h7dkeIumZR0Ox/CSCoJsVW2hrK4kE4Jx8R5wrYKQAdQUOHiMeA9duHQ cU50uK0HOtEyQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id ACE30806A3; Sun, 3 Mar 2024 11:22:39 -0500 (EST) Received: from pastel (unknown [216.154.1.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7E7581202E4; Sun, 3 Mar 2024 11:22:39 -0500 (EST) From: Stefan Monnier In-Reply-To: (Stefan Monnier's message of "Sat, 10 Feb 2024 10:33:01 -0500") Message-ID: References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> <87y1bs1y9x.fsf@yahoo.com> Date: Sun, 03 Mar 2024 11:22:39 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.118 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping? I believe this patch should be much less controversial since it allows users to get the old behavior back and still keeps the same semantics for existing `mouse-wheel-*-event` variables in case some other code still generates such events. It's basically a half-way step between what I proposed at first and the status quot. But I'd like some confirmation that you think it's acceptable, and maybe if you could comment on the FIXME included in there (I needed it for clicks on the tab-bar, but I don't understand that code). Stefan Stefan Monnier [2024-02-10 10:33:01] wrote: >> Or maybe we should keep `mouse-wheel-*-event` untouched (tho, maybe mark >> them obsolete) and instead introduce a new set of variables that control >> the remapping of `mouse-4/5/6/7` to `wheel-*` events. > > See patch below. > It would need etc/NEWS and doc changes, of course, and probably some > warning-silencing in those packages using `mouse-wheel-*-event`s. > > > Stefan > > From 0e94e1140a8ec72bd068648eb5ec1dc861f0884b Mon Sep 17 00:00:00 2001 > From: Stefan Monnier > Date: Mon, 29 Jan 2024 09:35:09 -0500 > Subject: [PATCH] (mouse-wheel-buttons): Map old-style wheel buttons to actual > wheel events > > Change the handling of the old X11 convention to use mouse-4/5/6/7 > events to represent wheel events: instead of asking downstream > packages to use the `mouse-wheel-*-event` variables to know which events > represent wheel events, use new var `mouse-wheel-buttons` to directly > convert those events into the standard `wheel-up/down/left/right` events > used everywhere else. > > This will simplify the work of packages which can thus just bind their > commands to `wheel-up/down/left/right`. > > * lisp/mouse.el (mouse-wheel-buttons): New custom variable. > > * src/keyboard.c (make_lispy_event): Adjust for "wheel-clicks" on the tab-bar. > * src/xterm.c (x_construct_mouse_click): Add `xi2` argument and > obey `mouse-wheel-buttons` variable. > (handle_one_xevent): Adjust calls accordingly. > (syms_of_xterm): Define the `mouse-wheel-buttons` and the > `wheel-up/down/left/right`symbols. > > * lisp/xt-mouse.el: Don't require `mwheel` any more. > (xterm-mouse--same-button-p): Delete function. > (xterm-mouse--read-event-sequence): Use `mouse-wheel-buttons`. > > * lisp/mwheel.el (mouse-wheel-up-event, mouse-wheel-down-event) > (mouse-wheel-left-event, mouse-wheel-right-event): Make obsolete. > (mouse-wheel-obey-old-style-wheel-buttons): Delete variable. > --- > lisp/mouse.el | 13 ++++++++++++ > lisp/mwheel.el | 21 ++++++++----------- > lisp/xt-mouse.el | 20 ++++-------------- > src/keyboard.c | 9 ++++++-- > src/xterm.c | 53 +++++++++++++++++++++++++++++++++++++++--------- > 5 files changed, 75 insertions(+), 41 deletions(-) > > diff --git a/lisp/mouse.el b/lisp/mouse.el > index d1b06c2040d..585891bf699 100644 > --- a/lisp/mouse.el > +++ b/lisp/mouse.el > @@ -133,6 +133,19 @@ mouse-drag-mode-line-buffer > :type 'boolean > :version "29.1") > > +(defcustom mouse-wheel-buttons > + '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right)) > + "Buttons to remap to wheel events. > +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel > +events represented as mouse button events. It remaps mouse button event > +NUMBER to the event SYMBOL. SYMBOL must be one of `wheel-up', `wheel-down', > +`wheel-left', or `wheel-right'. > +This is used only for events that come from sources known to generate such > +events, such as X11 events when XInput2 is not used, or events coming from > +a text terminal." > + :type '(alist) > + :version "30.1") > + > (defvar mouse--last-down nil) > > (defun mouse--down-1-maybe-follows-link (&optional _prompt) > diff --git a/lisp/mwheel.el b/lisp/mwheel.el > index 66a1fa1a706..9fc922eebc9 100644 > --- a/lisp/mwheel.el > +++ b/lisp/mwheel.el > @@ -56,20 +56,17 @@ mouse-wheel-change-button > (bound-and-true-p mouse-wheel-mode)) > (mouse-wheel-mode 1))) > > -(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 text-terminals as well.") > +(make-obsolete-variable 'mouse-wheel-up-event 'mouse-wheel-buttons "30.1") > +(make-obsolete-variable 'mouse-wheel-down-event 'mouse-wheel-buttons "30.1") > +(make-obsolete-variable 'mouse-wheel-left-event 'mouse-wheel-buttons "30.1") > +(make-obsolete-variable 'mouse-wheel-right-event 'mouse-wheel-buttons "30.1") > > -(defcustom mouse-wheel-down-event > - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) > +(defcustom mouse-wheel-down-event 'mouse-4 > "Event used for scrolling down, beside `wheel-up', if any." > :group 'mouse > :type 'symbol > :set #'mouse-wheel-change-button) > - > -(defcustom mouse-wheel-up-event > - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5) > +(defcustom mouse-wheel-up-event 'mouse-5 > "Event used for scrolling up, beside `wheel-down', if any." > :group 'mouse > :type 'symbol > @@ -223,12 +220,10 @@ mwheel-scroll-left-function > (defvar mwheel-scroll-right-function 'scroll-right > "Function that does the job of scrolling right.") > > -(defvar mouse-wheel-left-event > - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-6) > +(defvar mouse-wheel-left-event 'mouse-6 > "Event used for scrolling left, beside `wheel-left', if any.") > > -(defvar mouse-wheel-right-event > - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-7) > +(defvar mouse-wheel-right-event 'mouse-7 > "Event used for scrolling right, beside `wheel-right', if any.") > > (defun mouse-wheel--get-scroll-window (event) > diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el > index 081b8f32456..c27dee7e249 100644 > --- a/lisp/xt-mouse.el > +++ b/lisp/xt-mouse.el > @@ -40,8 +40,6 @@ > > ;;; Code: > > -(require 'mwheel) > - > (defvar xterm-mouse-debug-buffer nil) > > (defun xterm-mouse-translate (_event) > @@ -195,12 +193,6 @@ xterm-mouse--read-number-from-terminal > (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 > ;; in default mode, and > ;; ";" ";" <"M" or "m"> in extended mode. > @@ -246,14 +238,10 @@ xterm-mouse--read-event-sequence > (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)))))))) > + (let ((remap (alist-get btn mouse-wheel-buttons))) > + (if remap > + (symbol-name remap) > + (format "mouse-%d" btn)))))))) > (list sym (1- x) (1- y)))) > > (defun xterm-mouse--set-click-count (event click-count) > diff --git a/src/keyboard.c b/src/keyboard.c > index 1f7253a7da1..4c3e33762af 100644 > --- a/src/keyboard.c > +++ b/src/keyboard.c > @@ -6628,8 +6628,13 @@ make_lispy_event (struct input_event *event) > > if (CONSP (event->arg)) > return list5 (head, position, make_fixnum (double_click_count), > - XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)), > - XCAR (XCDR (XCDR (event->arg))))); > + XCAR (event->arg), > + /* FIXME: I don't know what I'm doing here. */ > + (CONSP (XCDR (event->arg)) > + && CONSP (XCDR (XCDR (event->arg)))) > + ? Fcons (XCAR (XCDR (event->arg)), > + XCAR (XCDR (XCDR (event->arg)))) > + : Qnil); > else if (NUMBERP (event->arg)) > return list4 (head, position, make_fixnum (double_click_count), > event->arg); > diff --git a/src/xterm.c b/src/xterm.c > index c8a43785564..e75b64ed3d4 100644 > --- a/src/xterm.c > +++ b/src/xterm.c > @@ -14543,18 +14543,19 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, > `x', `y', `x_root' and `y_root'. This function should not access > any other fields in EVENT without also initializing the > corresponding fields in `bv' under the XI_ButtonPress and > - XI_ButtonRelease labels inside `handle_one_xevent'. */ > + XI_ButtonRelease labels inside `handle_one_xevent'. > + > + XI2 indicates that this click comes from XInput2 rather than core > + event. */ > > static Lisp_Object > x_construct_mouse_click (struct input_event *result, > const XButtonEvent *event, > - struct frame *f) > + struct frame *f, bool xi2) > { > int x = event->x; > int y = event->y; > > - /* Make the event type NO_EVENT; we'll change that when we decide > - otherwise. */ > result->kind = MOUSE_CLICK_EVENT; > result->code = event->button - Button1; > result->timestamp = event->time; > @@ -14564,6 +14565,29 @@ x_construct_mouse_click (struct input_event *result, > ? up_modifier > : down_modifier)); > > + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ > + if (!xi2) > + { > + Lisp_Object base > + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), > + Fsymbol_value (Qmouse_wheel_buttons))); > + int wheel > + = NILP (base) ? -1 > + : BASE_EQ (base, Qwheel_down) ? 0 > + : BASE_EQ (base, Qwheel_up) ? 1 > + : BASE_EQ (base, Qwheel_left) ? 2 > + : BASE_EQ (base, Qwheel_right) ? 3 > + : -1; > + if (wheel >= 0) > + { > + result->kind = (event->type != ButtonRelease ? NO_EVENT > + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); > + result->code = 0; /* Not used. */ > + result->modifiers &= ~(up_modifier || down_modifier); > + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; > + } > + } > + > /* If result->window is not the frame's edit widget (which can > happen with GTK+ scroll bars, for example), translate the > coordinates so they appear at the correct position. */ > @@ -21873,13 +21897,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, > && event->xbutton.time > ignore_next_mouse_click_timeout) > { > ignore_next_mouse_click_timeout = 0; > - x_construct_mouse_click (&inev.ie, &event->xbutton, f); > + x_construct_mouse_click (&inev.ie, &event->xbutton, > + f, false); > } > if (event->type == ButtonRelease) > ignore_next_mouse_click_timeout = 0; > } > else > - x_construct_mouse_click (&inev.ie, &event->xbutton, f); > + x_construct_mouse_click (&inev.ie, &event->xbutton, f, false); > > *finish = X_EVENT_DROP; > goto OTHER; > @@ -21949,13 +21974,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, > && event->xbutton.time > ignore_next_mouse_click_timeout) > { > ignore_next_mouse_click_timeout = 0; > - x_construct_mouse_click (&inev.ie, &event->xbutton, f); > + x_construct_mouse_click (&inev.ie, &event->xbutton, > + f, false); > } > if (event->type == ButtonRelease) > ignore_next_mouse_click_timeout = 0; > } > else > - x_construct_mouse_click (&inev.ie, &event->xbutton, f); > + x_construct_mouse_click (&inev.ie, &event->xbutton, > + f, false); > > if (!NILP (tab_bar_arg)) > inev.ie.arg = tab_bar_arg; > @@ -23732,13 +23759,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, > && xev->time > ignore_next_mouse_click_timeout) > { > ignore_next_mouse_click_timeout = 0; > - x_construct_mouse_click (&inev.ie, &bv, f); > + x_construct_mouse_click (&inev.ie, &bv, f, true); > } > if (xev->evtype == XI_ButtonRelease) > ignore_next_mouse_click_timeout = 0; > } > else > - x_construct_mouse_click (&inev.ie, &bv, f); > + x_construct_mouse_click (&inev.ie, &bv, f, true); > > if (!NILP (tab_bar_arg)) > inev.ie.arg = tab_bar_arg; > @@ -32444,6 +32471,12 @@ syms_of_xterm (void) > DEFSYM (Qexpose, "expose"); > DEFSYM (Qdont_save, "dont-save"); > > + DEFSYM (Qmouse_wheel_buttons, "mouse-wheel-buttons"); > + DEFSYM (Qwheel_up, "wheel-up"); > + DEFSYM (Qwheel_down, "wheel-down"); > + DEFSYM (Qwheel_left, "wheel-left"); > + DEFSYM (Qwheel_right, "wheel-right"); > + > #ifdef USE_GTK > xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); > staticpro (&xg_default_icon_file); From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Mar 2024 01:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: Eli Zaretskii , 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170951694329200 (code B ref 68796); Mon, 04 Mar 2024 01:50:02 +0000 Received: (at 68796) by debbugs.gnu.org; 4 Mar 2024 01:49:03 +0000 Received: from localhost ([127.0.0.1]:41420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgxRv-0007at-9T for submit@debbugs.gnu.org; Sun, 03 Mar 2024 20:49:03 -0500 Received: from sonic305-22.consmr.mail.ne1.yahoo.com ([66.163.185.148]:44482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgxRt-0007ZX-6t for 68796@debbugs.gnu.org; Sun, 03 Mar 2024 20:49:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1709516905; bh=t7BSgtN3a7kE/O0I/MBOW/bQhffNSLCfY8e90wcowDI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=qi5fD7VdSMSus1Zdq9sW+fOc3y0YWOY1XWIH9352SaEMaf10CuKmnrNeGexDGUsjh/EAo3Mh0LYfNlPsEgGRqP7FhfjNTdATMQIyiCrWyN9qMk+wK8KfINnIVnaxAYGoOpWdZxXk8B79syT3j2gx3BbSf6RaT6dlUkahHQbT058S1S2sO+h8p+QMWjIluGQ8H5Njd1OgvcSOg13tj0Llac4lxCNjzFrs/bV1mMZWuECJMAu3jho1aHYL5u+OiMdgmGIWJAP2g+kZ3ZCKJxVUHE2QXMdnaOFXdzEGM0b7wZUVJcHv6FxR+Xo4cMLrtlkQOuDtSsHIyW0oOkOzYpuNxg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1709516905; bh=CuypshGJfNbjJTGATzl01V/2UGiiaVeCalk8TeYJCfQ=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=LhnBBrZ7gqaCwN6sUeUX+5Aez1BbU0R0TFNg2I0mMuH70d5rAiiss+oc15HLUAIo4ts4+AUOFLGKIpVXjL2ITjLBXkV336nevW9h7EkwalV/TRbs5KAHIVSZRx4sIAG85rvz4mR8ZokRk/XNLlJipmblCyb7yhgF/x6VTS1reywvjnU8hnJQXVNi0qd5SDjIpDWSnafrTyGwxu/zu1MXhRs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UDztu.8t1ZzlxECQ1NWfTvjjuqrx8zc3TA 0a0oBhyZnoc.nIVvUBPWt4ezDPHgkZMKwQbpI5yG4KdEqJZi08BpRLyJk9IpoDObj5z6NbtDVkkz 2Xr8t5utyPPYyHLLGAtAd.sKNUW1bI6rzQL2ziBPOiwniTwlklB6RQ8K37_RYjZC4hi8VgKnxTZi 7CetYmZCGVZF3WXI9a9zT.PeP0UJ5hGbKsyLKCuckva_QKR4FF.01c9OC6cLOhQWsbM5bziDTyrE w585cnvct.7.oKtqddqUhV5gJkrofa5jFCzKUb_m88qOvNwi4PKiN.9U3O.NqbQWHOn4- X-Sonic-MF: X-Sonic-ID: 28fa4467-3ab2-42cf-b9fd-0a75fccfc2b8 Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Mon, 4 Mar 2024 01:48:25 +0000 Received: by hermes--production-sg3-6dc75bc8fb-zp62z (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 45cbc9bac2fcd6e1d8093ee5bbb128ae; Mon, 04 Mar 2024 01:48:20 +0000 (UTC) From: Po Lu In-Reply-To: (Stefan Monnier's message of "Sun, 03 Mar 2024 11:22:39 -0500") References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> <87y1bs1y9x.fsf@yahoo.com> Date: Mon, 04 Mar 2024 09:47:54 +0800 Message-ID: <871q8q3gz9.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22103 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 1299 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > Ping? > > I believe this patch should be much less controversial since it allows > users to get the old behavior back and still keeps the same semantics > for existing `mouse-wheel-*-event` variables in case some other code > still generates such events. It's basically a half-way step between > what I proposed at first and the status quot. > > But I'd like some confirmation that you think it's acceptable, and maybe > if you could comment on the FIXME included in there (I needed it for > clicks on the tab-bar, but I don't understand that code). That would be simple if I could find the FIXME, but it doesn't appear to be present anywhere in that patch... >> + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ >> + if (!xi2) >> + { >> + Lisp_Object base >> + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), >> + Fsymbol_value (Qmouse_wheel_buttons))); >> + int wheel >> + = NILP (base) ? -1 >> + : BASE_EQ (base, Qwheel_down) ? 0 >> + : BASE_EQ (base, Qwheel_up) ? 1 >> + : BASE_EQ (base, Qwheel_left) ? 2 >> + : BASE_EQ (base, Qwheel_right) ? 3 >> + : -1; This should be surrounded by parentheses. Thanks. From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Mar 2024 03:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.17095217008842 (code B ref 68796); Mon, 04 Mar 2024 03:09:01 +0000 Received: (at 68796) by debbugs.gnu.org; 4 Mar 2024 03:08:20 +0000 Received: from localhost ([127.0.0.1]:41462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgyge-0002IW-4Y for submit@debbugs.gnu.org; Sun, 03 Mar 2024 22:08:20 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53401) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgygc-0002ID-GS for 68796@debbugs.gnu.org; Sun, 03 Mar 2024 22:08:19 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EB46E100196; Sun, 3 Mar 2024 22:07:42 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1709521662; bh=cBZfMsxWpetwh3qFzSGoP6Etq0WdgexpfaqFNmocJkk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LbEJ3BXVI6lhiHTEI4hW5MnH9XCSU8rZyEwVGSwObGaWy7Z47b5eV2o9Fss2Ep59/ hjE4ZnUkzDEREQmuaK9SD0PG9cXbLsjnzC7kXi5QPCtMbzKjtOh+gxoCRtlUP1Ldfg cKNIsBlLVo9CVfYhgwpcumDc8Ax4djadAUru9tKuUWZ05ZBwNMVUlLZW4NAOAoBwgB phxnbFT1HbUkLB305cWZ9uX3pwA2Iadqhu5zpo2nOR17KZDDTZeWsh5eK2yyGQNZ2B CMx1LfWTvWrbIhJxD/zmErvVvUIlNcHiNicaUZVagNttf9dau8lvHndzgOKeJDPpvG O6pYCgjXQ4mKg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id F0A9E1000D6; Sun, 3 Mar 2024 22:07:41 -0500 (EST) Received: from pastel (unknown [104.247.233.29]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C34AB120223; Sun, 3 Mar 2024 22:07:41 -0500 (EST) From: Stefan Monnier In-Reply-To: <871q8q3gz9.fsf@yahoo.com> (Po Lu's message of "Mon, 04 Mar 2024 09:47:54 +0800") Message-ID: References: <871q9zh972.fsf@yahoo.com> <87r0hzfpd5.fsf@yahoo.com> <86cyt4vi9r.fsf@gnu.org> <87y1bs1y9x.fsf@yahoo.com> <871q8q3gz9.fsf@yahoo.com> Date: Sun, 03 Mar 2024 22:07:40 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.159 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > That would be simple if I could find the FIXME, but it doesn't appear to > be present anywhere in that patch... [ Hmm... not sure what happened: `C-s FIXME` finds it for me: ] diff --git a/src/keyboard.c b/src/keyboard.c index 1f7253a7da1..4c3e33762af 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6628,8 +6628,13 @@ make_lispy_event (struct input_event *event) if (CONSP (event->arg)) return list5 (head, position, make_fixnum (double_click_count), - XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)), - XCAR (XCDR (XCDR (event->arg))))); + XCAR (event->arg), + /* FIXME: I don't know what I'm doing here. */ + (CONSP (XCDR (event->arg)) + && CONSP (XCDR (XCDR (event->arg)))) + ? Fcons (XCAR (XCDR (event->arg)), + XCAR (XCDR (XCDR (event->arg)))) + : Qnil); else if (NUMBERP (event->arg)) return list4 (head, position, make_fixnum (double_click_count), event->arg); >>> + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ >>> + if (!xi2) >>> + { >>> + Lisp_Object base >>> + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), >>> + Fsymbol_value (Qmouse_wheel_buttons))); >>> + int wheel >>> + = NILP (base) ? -1 >>> + : BASE_EQ (base, Qwheel_down) ? 0 >>> + : BASE_EQ (base, Qwheel_up) ? 1 >>> + : BASE_EQ (base, Qwheel_left) ? 2 >>> + : BASE_EQ (base, Qwheel_right) ? 3 >>> + : -1; > > This should be surrounded by parentheses. Ah, it might be need for CC-mode, indeed, thanks. `sm-c-mode` gets this right without the parens :-) Stefan From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: Stefan's wheel event change Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Apr 2024 19:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.171217264023938 (code B ref 68796); Wed, 03 Apr 2024 19:31:02 +0000 Received: (at 68796) by debbugs.gnu.org; 3 Apr 2024 19:30:40 +0000 Received: from localhost ([127.0.0.1]:59706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs6Jj-0006E1-PJ for submit@debbugs.gnu.org; Wed, 03 Apr 2024 15:30:40 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs6Jg-0006Dm-VM for 68796@debbugs.gnu.org; Wed, 03 Apr 2024 15:30:38 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 63A6D80BC1; Wed, 3 Apr 2024 15:30:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712172624; bh=IWORR7EAqojU5Hhu1zEBtQ6ly1MPoFngKkrMiiNowiQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=luiVf4L/2q2t6Y8M261YnwkyenwltLCIUD1VlZRj8XcbjlyG7mK+khjeaWj4KvI7/ qjzsAJ0WNbUzQpFJepMR32wGBcPcuUOgeWF6Z8iBgNJ1boZqipUlqtk9pnlwEwmk96 Yddm6oKmGNy0m64L13Uk5cw1snq3p4IPhz2+p59cKHYfMjUxYHYS0rZn3ljisQ6WPn HrboBXuHVO1QeEniKA1l6OHAajF27Rr1n6+8XoU2q01CUqfC8NVAj0hO0YrstGaCM3 FTgidBXrov99zMTf1pISUpRFC6vITMgldhLlbFKkfVf+HcsDfW9tNWmA2tvYjzkVpx mw11bsUiJ1lUA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 66F5980966; Wed, 3 Apr 2024 15:30:24 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 53975120672; Wed, 3 Apr 2024 15:30:24 -0400 (EDT) From: Stefan Monnier In-Reply-To: <877che34wk.fsf@yahoo.com> (Po Lu's message of "Wed, 03 Apr 2024 22:19:23 +0800") Message-ID: References: <877che34wk.fsf.ref@yahoo.com> <877che34wk.fsf@yahoo.com> Date: Wed, 03 Apr 2024 15:27:54 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.161 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain > I'm now satisfied that Stefan's change to return wheel events on all > platforms does not produce the adverse effects I feared, but I have also > misplaced the number of the bug report where it was discussed, so, > Stefan, please post your version of the patch again before it is > installed. Thanks in advance. Here it is, with a brand new etc/NEWS, Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-mouse-wheel-buttons-Map-old-style-wheel-buttons-to-a.patch >From 56559400277d5535713349431ca0cda967e8e281 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 29 Jan 2024 09:35:09 -0500 Subject: [PATCH] (mouse-wheel-buttons): Map old-style wheel buttons to actual wheel events Change the handling of the old X11 convention to use mouse-4/5/6/7 events to represent wheel events: instead of asking downstream packages to use the `mouse-wheel-*-event` variables to know which events represent wheel events, use new var `mouse-wheel-buttons` to directly convert those events into the standard `wheel-up/down/left/right` events used everywhere else. This will simplify the work of packages which can thus just bind their commands to `wheel-up/down/left/right`. * lisp/mouse.el (mouse-wheel-buttons): New custom variable. * src/keyboard.c (make_lispy_event): Adjust for "wheel-clicks" on the tab-bar. * src/xterm.c (x_construct_mouse_click): Add `xi2` argument and obey `mouse-wheel-buttons` variable. (handle_one_xevent): Adjust calls accordingly. (syms_of_xterm): Define the `mouse-wheel-buttons` and the `wheel-up/down/left/right`symbols. * lisp/xt-mouse.el: Don't require `mwheel` any more. (xterm-mouse--same-button-p): Delete function. (xterm-mouse--read-event-sequence): Use `mouse-wheel-buttons`. * lisp/mwheel.el (mouse-wheel-up-event, mouse-wheel-down-event) (mouse-wheel-left-event, mouse-wheel-right-event): Make obsolete. (mouse-wheel-obey-old-style-wheel-buttons): Delete variable. --- etc/NEWS | 16 ++++++++++----- lisp/mouse.el | 13 ++++++++++++ lisp/mwheel.el | 21 ++++++++----------- lisp/xt-mouse.el | 20 ++++-------------- src/keyboard.c | 13 ++++++++++-- src/xterm.c | 53 +++++++++++++++++++++++++++++++++++++++--------- 6 files changed, 90 insertions(+), 46 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2654d9d7995..d1054d4337b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -68,6 +68,12 @@ more details. * Incompatible Changes in Emacs 30.1 +** Mouse wheel events should now always be 'wheel-up/down/left/right'. +At those places where the old 'mouse-4/5/6/7' events could still occur +(i.e. X11 input in the absence of XInput2, and `xterm-mouse-mode`), +we remap them to the corresponding 'wheel-up/down/left/right' event, +according to the new variable 'mouse-wheel-buttons'. + ** Tree-Sitter modes are now declared as submodes of the non-TS modes. In order to help the use of those Tree-Sitter modes, they are now declared to have the corresponding non-Tree-Sitter mode as an @@ -520,15 +526,15 @@ In batch mode, tracing now sends the trace to stdout. ** Mwheel The 'wheel-up/down/left/right' events are now bound unconditionally, and the 'mouse-wheel-up/down/left/right-event' variables are thus used -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'. +only to specify the 'mouse-4/5/6/7' events that might still +happen to be generated by some old packages (or if 'mouse-wheel-buttons' +has been set to nil). ** '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). +It uses the new variable 'mouse-wheel-buttons' to decide which button +maps to which wheel event (if any). ** Info diff --git a/lisp/mouse.el b/lisp/mouse.el index cef88dede8a..ae5a6455566 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -133,6 +133,19 @@ mouse-drag-mode-line-buffer :type 'boolean :version "29.1") +(defcustom mouse-wheel-buttons + '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right)) + "Buttons to remap to wheel events. +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel +events represented as mouse button events. It remaps mouse button event +NUMBER to the event SYMBOL. SYMBOL must be one of `wheel-up', `wheel-down', +`wheel-left', or `wheel-right'. +This is used only for events that come from sources known to generate such +events, such as X11 events when XInput2 is not used, or events coming from +a text terminal." + :type '(alist) + :version "30.1") + (defvar mouse--last-down nil) (defun mouse--down-1-maybe-follows-link (&optional _prompt) diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 66a1fa1a706..9fc922eebc9 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -56,20 +56,17 @@ mouse-wheel-change-button (bound-and-true-p mouse-wheel-mode)) (mouse-wheel-mode 1))) -(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 text-terminals as well.") +(make-obsolete-variable 'mouse-wheel-up-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-down-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-left-event 'mouse-wheel-buttons "30.1") +(make-obsolete-variable 'mouse-wheel-right-event 'mouse-wheel-buttons "30.1") -(defcustom mouse-wheel-down-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) +(defcustom mouse-wheel-down-event 'mouse-4 "Event used for scrolling down, beside `wheel-up', if any." :group 'mouse :type 'symbol :set #'mouse-wheel-change-button) - -(defcustom mouse-wheel-up-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5) +(defcustom mouse-wheel-up-event 'mouse-5 "Event used for scrolling up, beside `wheel-down', if any." :group 'mouse :type 'symbol @@ -223,12 +220,10 @@ mwheel-scroll-left-function (defvar mwheel-scroll-right-function 'scroll-right "Function that does the job of scrolling right.") -(defvar mouse-wheel-left-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-6) +(defvar mouse-wheel-left-event 'mouse-6 "Event used for scrolling left, beside `wheel-left', if any.") -(defvar mouse-wheel-right-event - (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-7) +(defvar mouse-wheel-right-event 'mouse-7 "Event used for scrolling right, beside `wheel-right', if any.") (defun mouse-wheel--get-scroll-window (event) diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 081b8f32456..c27dee7e249 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -40,8 +40,6 @@ ;;; Code: -(require 'mwheel) - (defvar xterm-mouse-debug-buffer nil) (defun xterm-mouse-translate (_event) @@ -195,12 +193,6 @@ xterm-mouse--read-number-from-terminal (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 ;; in default mode, and ;; ";" ";" <"M" or "m"> in extended mode. @@ -246,14 +238,10 @@ xterm-mouse--read-event-sequence (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)))))))) + (let ((remap (alist-get btn mouse-wheel-buttons))) + (if remap + (symbol-name remap) + (format "mouse-%d" btn)))))))) (list sym (1- x) (1- y)))) (defun xterm-mouse--set-click-count (event click-count) diff --git a/src/keyboard.c b/src/keyboard.c index 91faf4582fa..a06c9116d24 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6639,8 +6639,17 @@ make_lispy_event (struct input_event *event) if (CONSP (event->arg)) return list5 (head, position, make_fixnum (double_click_count), - XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)), - XCAR (XCDR (XCDR (event->arg))))); + XCAR (event->arg), + /* FIXME: When a mouse-click on a tab-bar is + converted into a wheel-event we get here something + of an unexpected shape... */ + (CONSP (XCDR (event->arg)) + && CONSP (XCDR (XCDR (event->arg)))) + ? Fcons (XCAR (XCDR (event->arg)), + XCAR (XCDR (XCDR (event->arg)))) + /* ... not knowing what this "unexpected shape" means, + we just use nil. */ + : Qnil); else if (NUMBERP (event->arg)) return list4 (head, position, make_fixnum (double_click_count), event->arg); diff --git a/src/xterm.c b/src/xterm.c index c0aef65ab66..5e5eb6269e4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14551,18 +14551,19 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, `x', `y', `x_root' and `y_root'. This function should not access any other fields in EVENT without also initializing the corresponding fields in `bv' under the XI_ButtonPress and - XI_ButtonRelease labels inside `handle_one_xevent'. */ + XI_ButtonRelease labels inside `handle_one_xevent'. + + XI2 indicates that this click comes from XInput2 rather than core + event. */ static Lisp_Object x_construct_mouse_click (struct input_event *result, const XButtonEvent *event, - struct frame *f) + struct frame *f, bool xi2) { int x = event->x; int y = event->y; - /* Make the event type NO_EVENT; we'll change that when we decide - otherwise. */ result->kind = MOUSE_CLICK_EVENT; result->code = event->button - Button1; result->timestamp = event->time; @@ -14572,6 +14573,29 @@ x_construct_mouse_click (struct input_event *result, ? up_modifier : down_modifier)); + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ + if (!xi2) + { + Lisp_Object base + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), + Fsymbol_value (Qmouse_wheel_buttons))); + int wheel + = (NILP (base) ? -1 + : BASE_EQ (base, Qwheel_down) ? 0 + : BASE_EQ (base, Qwheel_up) ? 1 + : BASE_EQ (base, Qwheel_left) ? 2 + : BASE_EQ (base, Qwheel_right) ? 3 + : -1); + if (wheel >= 0) + { + result->kind = (event->type != ButtonRelease ? NO_EVENT + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); + result->code = 0; /* Not used. */ + result->modifiers &= ~(up_modifier || down_modifier); + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; + } + } + /* If result->window is not the frame's edit widget (which can happen with GTK+ scroll bars, for example), translate the coordinates so they appear at the correct position. */ @@ -21881,13 +21905,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, f, false); *finish = X_EVENT_DROP; goto OTHER; @@ -21957,13 +21982,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, && event->xbutton.time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); } if (event->type == ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &event->xbutton, f); + x_construct_mouse_click (&inev.ie, &event->xbutton, + f, false); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; @@ -23740,13 +23767,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, && xev->time > ignore_next_mouse_click_timeout) { ignore_next_mouse_click_timeout = 0; - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); } if (xev->evtype == XI_ButtonRelease) ignore_next_mouse_click_timeout = 0; } else - x_construct_mouse_click (&inev.ie, &bv, f); + x_construct_mouse_click (&inev.ie, &bv, f, true); if (!NILP (tab_bar_arg)) inev.ie.arg = tab_bar_arg; @@ -32452,6 +32479,12 @@ syms_of_xterm (void) DEFSYM (Qexpose, "expose"); DEFSYM (Qdont_save, "dont-save"); + DEFSYM (Qmouse_wheel_buttons, "mouse-wheel-buttons"); + DEFSYM (Qwheel_up, "wheel-up"); + DEFSYM (Qwheel_down, "wheel-down"); + DEFSYM (Qwheel_left, "wheel-left"); + DEFSYM (Qwheel_right, "wheel-right"); + #ifdef USE_GTK xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); staticpro (&xg_default_icon_file); -- 2.43.0 --=-=-=-- From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: Stefan's wheel event change Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Apr 2024 05:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: luangruo@yahoo.com, 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.171220812218485 (code B ref 68796); Thu, 04 Apr 2024 05:23:01 +0000 Received: (at 68796) by debbugs.gnu.org; 4 Apr 2024 05:22:02 +0000 Received: from localhost ([127.0.0.1]:60150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsFY1-0004nt-Hy for submit@debbugs.gnu.org; Thu, 04 Apr 2024 01:22:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsFXw-0004ms-Oh for 68796@debbugs.gnu.org; Thu, 04 Apr 2024 01:22:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsFXl-0001UT-U0; Thu, 04 Apr 2024 01:21:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5+fgilobkUcDzMMiSm/8N+qxZe/Djun4s3GhsUNZ9aw=; b=GOabVbavnd24 hp8J44x+ohTttXNmlCOzkFZ5rHuTfn0rZHZKV+06z2m1YLsxrdNMk6QB1V0Xghc0lPzMLqeHvFxhw 5M0QZNvsU7Jq9DhmCA9es/dLdpHF/xFzBiATJBKTsRkpTjdg+y5RtDK2Wer44E3FxJ8B4ocqxayhk Dnzy6G8cPKMGXbd+3pKjgYqSStYaUcJZzaZm/4w8OQeHI/EBU5QStGWoSeqGwuGIGUIldQtBpr66e eZdtcmMX0Z8if0u3c6lagLDEeT9U/fCiIIhQ1TCH9EMnWF1HMt2uQ4IOTmCAgwcevGxRtJEWzbGY5 9WdUGVsqSuQ7I64QfowTAg==; Date: Thu, 04 Apr 2024 08:21:43 +0300 Message-Id: <86cyr58zyw.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: <877che34wk.fsf.ref@yahoo.com> <877che34wk.fsf@yahoo.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 68796@debbugs.gnu.org > Date: Wed, 03 Apr 2024 15:27:54 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > I'm now satisfied that Stefan's change to return wheel events on all > > platforms does not produce the adverse effects I feared, but I have also > > misplaced the number of the bug report where it was discussed, so, > > Stefan, please post your version of the patch again before it is > > installed. Thanks in advance. > > Here it is, with a brand new etc/NEWS, Thanks, a few minor comments below. > Change the handling of the old X11 convention to use mouse-4/5/6/7 > events to represent wheel events: instead of asking downstream > packages to use the `mouse-wheel-*-event` variables to know which events > represent wheel events, use new var `mouse-wheel-buttons` to directly > convert those events into the standard `wheel-up/down/left/right` events > used everywhere else. > > This will simplify the work of packages which can thus just bind their > commands to `wheel-up/down/left/right`. > > * lisp/mouse.el (mouse-wheel-buttons): New custom variable. > > * src/keyboard.c (make_lispy_event): Adjust for "wheel-clicks" on the tab-bar. > * src/xterm.c (x_construct_mouse_click): Add `xi2` argument and > obey `mouse-wheel-buttons` variable. > (handle_one_xevent): Adjust calls accordingly. > (syms_of_xterm): Define the `mouse-wheel-buttons` and the > `wheel-up/down/left/right`symbols. > > * lisp/xt-mouse.el: Don't require `mwheel` any more. > (xterm-mouse--same-button-p): Delete function. > (xterm-mouse--read-event-sequence): Use `mouse-wheel-buttons`. Nit-picking: can we please NOT use Markdown-style quoting `like this` in our docs and change logs? > +** Mouse wheel events should now always be 'wheel-up/down/left/right'. > +At those places where the old 'mouse-4/5/6/7' events could still occur > +(i.e. X11 input in the absence of XInput2, and `xterm-mouse-mode`), > +we remap them to the corresponding 'wheel-up/down/left/right' event, > +according to the new variable 'mouse-wheel-buttons'. Likewise here. > +(defcustom mouse-wheel-buttons > + '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right)) > + "Buttons to remap to wheel events. Suggest to rephrase: "How to remap mouse button numbers to wheel events." > +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel > +events represented as mouse button events. It remaps mouse button event > +NUMBER to the event SYMBOL. SYMBOL must be one of `wheel-up', `wheel-down', Not "mouse event NUMBER", but "mouse button NUMBER", I think. Alternatively, you could say "mouse button event 'mouse-NUMBER'". IOW, NUMBER is not a mouse event, it's a number. > + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ > + if (!xi2) > + { > + Lisp_Object base > + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), > + Fsymbol_value (Qmouse_wheel_buttons))); Should this test mouse-wheel-buttons for being bound and have a list value, before calling assq? mouse.el is preloaded relatively late in loadup, so I think we had better played it safe, no? From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: Stefan's wheel event change Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Apr 2024 21:25:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: luangruo@yahoo.com, 68796@debbugs.gnu.org Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.17123522995020 (code B ref 68796); Fri, 05 Apr 2024 21:25:03 +0000 Received: (at 68796) by debbugs.gnu.org; 5 Apr 2024 21:24:59 +0000 Received: from localhost ([127.0.0.1]:37663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsr3R-0001It-PC for submit@debbugs.gnu.org; Fri, 05 Apr 2024 17:24:59 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35359) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsr3L-0001Ia-Sy for 68796@debbugs.gnu.org; Fri, 05 Apr 2024 17:24:56 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D0AC34413B1; Fri, 5 Apr 2024 17:24:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712352278; bh=KZ9aTEQx1sJWJa43kgn2bRNzqdYTSWnyueXAPOijmNk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Q1DeafZXzHBb8zoPlMB61znQllcNk9LbQX1XxXm4smAf0ZXun8WzlcTfngkyMJ6DQ lHLeSMKzjriMRECgCeX1iNjBmURhIpEGoHvzgmUjivn9IP50CKXgiuXGthuRS2b8cS 3a36DCJ04FWfHY3BCDXH+NVvfIpF9oT1rvR8Ja3Phq44GLkvJpATSuWvdFzJ6GluCs 3Lx5yS/S7Bwk6e8JxO6D7hJP7/hurY9C1/TFcY0tKuX8aRS3rHiuLE6hofL57Ioe5z ijiKzK6ftMQtScOObOzhGpKUjysBT1Kv9o1nTbmIft58HyCzGQmz/F9x8BejpdmSyr /lh4vZaH79T5g== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4CAC0441369; Fri, 5 Apr 2024 17:24:38 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 36D6C120195; Fri, 5 Apr 2024 17:24:38 -0400 (EDT) From: Stefan Monnier In-Reply-To: <86cyr58zyw.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 04 Apr 2024 08:21:43 +0300") Message-ID: References: <877che34wk.fsf.ref@yahoo.com> <877che34wk.fsf@yahoo.com> <86cyr58zyw.fsf@gnu.org> Date: Fri, 05 Apr 2024 17:22:05 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> +** Mouse wheel events should now always be 'wheel-up/down/left/right'. >> +At those places where the old 'mouse-4/5/6/7' events could still occur >> +(i.e. X11 input in the absence of XInput2, and `xterm-mouse-mode`), >> +we remap them to the corresponding 'wheel-up/down/left/right' event, >> +according to the new variable 'mouse-wheel-buttons'. > > Likewise here. Fixed. >> +(defcustom mouse-wheel-buttons >> + '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right)) >> + "Buttons to remap to wheel events. > > Suggest to rephrase: > > "How to remap mouse button numbers to wheel events." Thanks. >> +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel >> +events represented as mouse button events. It remaps mouse button event >> +NUMBER to the event SYMBOL. SYMBOL must be one of `wheel-up', `wheel-down', > > Not "mouse event NUMBER", but "mouse button NUMBER", I think. > Alternatively, you could say "mouse button event 'mouse-NUMBER'". > IOW, NUMBER is not a mouse event, it's a number. Indeed. >> + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ >> + if (!xi2) >> + { >> + Lisp_Object base >> + = Fcdr_safe (Fassq (make_fixnum (result->code + 1), >> + Fsymbol_value (Qmouse_wheel_buttons))); > > Should this test mouse-wheel-buttons for being bound and have a list > value, before calling assq? mouse.el is preloaded relatively late in > loadup, so I think we had better played it safe, no? AFAIK we can't get such events until *much* later, after the dump, so I don't see any need for that. Especially since it only affects mouse clicks, so it wouldn't render Emacs unusable. `Fassq` can also signal an error if `mouse-wheel-buttons` contains something else than an alist, but in my tests, this simply results in error messages when you use the mouse buttons/wheel, which is about as good as it gets, IMO. Stefan From unknown Sat Jun 14 19:40:47 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Stefan Monnier Subject: bug#68796: closed (Re: bug#68796: Stefan's wheel event change) Message-ID: References: X-Gnu-PR-Message: they-closed 68796 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 68796@debbugs.gnu.org Date: Tue, 09 Apr 2024 14:32:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1712673122-30341-1" This is a multi-part message in MIME format... ------------=_1712673122-30341-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right 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 68796@debbugs.gnu.org. --=20 68796: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68796 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1712673122-30341-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 68796-done) by debbugs.gnu.org; 9 Apr 2024 14:31:22 +0000 Received: from localhost ([127.0.0.1]:51198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruCVO-0007nA-Hu for submit@debbugs.gnu.org; Tue, 09 Apr 2024 10:31:22 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruCVM-0007mw-E8 for 68796-done@debbugs.gnu.org; Tue, 09 Apr 2024 10:31:20 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BFCAE80CE1; Tue, 9 Apr 2024 10:31:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712673064; bh=7XxtjSSs12wl+XRv493sQY/Ezb9CmTE38jxnC/gZQMQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=HBLF2DvqF/QdVSdXQWt/Jri/H7hSxTs/CO2PPk+iSbATil04NNq9spaMDYMRvv+yo Gjr6eX0qrrMgPlNWMHKgUR+euhYsocfYGM/feMukDM29Inzwkwu4wcNcOpkE0ajyLN 1sr+t3YHMrJqUAfurz3PkCxnd8P0wk2glPBIXfM8mZFxa2w+xzvjGa6bYe0tnC0n0m fYFQSMf3dcSe27qZByNaDcz4MEjEzy8O0TyxeMyE0iS7nBQxAUj+VxagBql1Bgi+U+ udBwTxQ/ICN7ArZuHzApqlk7qgZCnDNeb1w2E2hbKgznFB+OaXIjLPozx1XRyIEZq8 ZY6h2u3q1nKfA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BB2F18089D; Tue, 9 Apr 2024 10:31:04 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 91EE712065C; Tue, 9 Apr 2024 10:31:04 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#68796: Stefan's wheel event change In-Reply-To: (Stefan Monnier's message of "Fri, 05 Apr 2024 17:22:05 -0400") Message-ID: References: <877che34wk.fsf.ref@yahoo.com> <877che34wk.fsf@yahoo.com> <86cyr58zyw.fsf@gnu.org> Date: Tue, 09 Apr 2024 10:31:03 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.092 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68796-done Cc: luangruo@yahoo.com, 68796-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Pushed to `master, closing, Stefan ------------=_1712673122-30341-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Jan 2024 14:45:47 +0000 Received: from localhost ([127.0.0.1]:59372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUStO-0008VB-GE for submit@debbugs.gnu.org; Mon, 29 Jan 2024 09:45:47 -0500 Received: from lists.gnu.org ([2001:470:142::17]:34822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUStM-0008Ux-4f for submit@debbugs.gnu.org; Mon, 29 Jan 2024 09:45:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUSt5-0000hZ-80 for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 09:45:30 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUSt2-0000RM-C9 for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 09:45:26 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3CCB4440976 for ; Mon, 29 Jan 2024 09:45:22 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1706539517; bh=xixryesPc0jyKV6gaBPu7LC/WGmhuV5g0W2ImPSjdek=; h=From:To:Subject:Date:From; b=g75fjC/U61TWXGsEmjtHmxt1agHNFYBwC7/6jPpA7z58DBuLDMqaS3VLXU3ycHjXh uQoyMt+3W26rmNsX/NjOiXXzvjIQgk7712K0pZyuu0i70q4wD3igmznHUQES4bpHB1 Z6aczg9Z59IZG9q/F/tz+k30KQ/9OMK98tij8/fkgAKN7+jdE5DivuCgV2mPka+mYK bZaravxRfRvClzQ4KYBljVELCbOAXFj/ob0+R6IpB994b/Kz9W2bhZXmOM2/bq4LBi GfCtP3iCGOylShyEPJHf2/t/lHFReOIjgCIYM5UbPCclXVB5tMwlzxRohaoKrzSq5N emYsgmRc2RjpQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C187C442415 for ; Mon, 29 Jan 2024 09:45:17 -0500 (EST) Received: from pastel (unknown [45.72.206.68]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A43BB120C8F for ; Mon, 29 Jan 2024 09:45:17 -0500 (EST) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Date: Mon, 29 Jan 2024 09:45:01 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.000 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Tags: patch Following up on the `xt-mouse.el` patch (bug#68698), I now propose we do the same for those `mouse-4/5/6/7` events generated by old-style X11 input. IIUC Po Lu wasn't favorable to the idea, but maybe seeing the code will make a convert? Beside that, the patch has 2 remaining issues: - Lack of corresponding updates to `etc/NEWS` and `doc/lispref/commands.texi`. - Lack of testing for the left/right remapping. This is *really* necessary because even after (re)reading the various parts of the code that handle horizontal scrolling, I'm still very much unsure if I got the direction right[left?], so if you have a mouse with a horizontal wheel, please compare the `wheel-left/right` events generated with and without building `--without-xinput2`. Stefan In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2024-01-25 built on pastel Repository revision: 5945fab9af0b52cc55f06b2c7e911d51e34a9cdf Repository branch: work Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign' --without-native-compilation PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-xterm.c-Map-old-style-wheel-buttons-to-actual-wheel-.patch >From 60e6903ae12546db93f149b1f184ffc7ccdc30c2 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 29 Jan 2024 09:35:09 -0500 Subject: [PATCH] xterm.c: Map old-style wheel buttons to actual wheel events Change the handling of the old X11 convention to use mouse-4/5/6/7 events to represent wheel events: instead of asking downstream packages to use the `mouse-wheel-*-event` variables to know which events represent wheel events, use those variables in `xterm.c` to directly convert those events into the standard `wheel-up/down/left/right` events used everywhere else. This simplifies the work of packages which can now just bind their commands to `wheel-up/down/left/right`. * src/keyboard.c (base_mouse_symbol): New function. * src/keyboard.h (base_mouse_symbol): Declare. * src/xterm.c (x_construct_mouse_click): Obey `mouse-wheel-*-event` vars. (syms_of_xterm): Define the `mouse-wheel-*-event` symbols. * lisp/completion-preview.el (completion-preview--mouse-map): Don't bind to `mouse-wheel-*-event`s any more. * lisp/edmacro.el (edmacro-fix-menu-commands): Remove special casing of `mouse-wheel-*-event`s. * lisp/mwheel.el (mouse-wheel-down-event, mouse-wheel-up-event): Remove :set. (mouse-wheel--setup-bindings): Don't bind to `mouse-wheel-*-event`s any more. * lisp/progmodes/flymake.el (flymake--mode-line-counter-map): Don't bind to `mouse-wheel-*-event`s any more if Emacs is recent enough. --- lisp/completion-preview.el | 10 +--------- lisp/edmacro.el | 8 +------- lisp/mwheel.el | 31 +++++++++++-------------------- lisp/progmodes/flymake.el | 19 +++++++++---------- src/fns.c | 1 + src/keyboard.c | 9 +++++++++ src/keyboard.h | 2 +- src/xterm.c | 31 +++++++++++++++++++++++++++++-- 8 files changed, 62 insertions(+), 49 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 6fd60f3c416..6bbf1246a9a 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -52,8 +52,6 @@ ;;; Code: -(require 'mwheel) - (defgroup completion-preview nil "In-buffer completion preview." :group 'completion) @@ -135,14 +133,8 @@ completion-preview--mouse-map "" #'completion-preview-insert "C-" #'completion-at-point "" #'completion-at-point - ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events - ;; and vice versa!! "" #'completion-preview-prev-candidate - "" #'completion-preview-next-candidate - (key-description (vector mouse-wheel-up-event)) - #'completion-preview-next-candidate - (key-description (vector mouse-wheel-down-event)) - #'completion-preview-prev-candidate) + "" #'completion-preview-next-candidate) (defvar-local completion-preview--overlay nil) diff --git a/lisp/edmacro.el b/lisp/edmacro.el index abfc380d154..a80fe973240 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -725,10 +725,6 @@ edmacro-fix-menu-commands (let (result) ;; Not preloaded in a --without-x build. (require 'mwheel) - (defvar mouse-wheel-down-event) - (defvar mouse-wheel-up-event) - (defvar mouse-wheel-right-event) - (defvar mouse-wheel-left-event) ;; Make a list of the elements. (setq macro (append macro nil)) (dolist (ev macro) @@ -744,9 +740,7 @@ edmacro-fix-menu-commands ;; info is recorded in macros to make this possible. ((or (mouse-event-p ev) (mouse-movement-p ev) (memq (event-basic-type ev) - `( ,mouse-wheel-down-event ,mouse-wheel-up-event - ,mouse-wheel-right-event ,mouse-wheel-left-event - wheel-down wheel-up wheel-left wheel-right))) + '(wheel-down wheel-up wheel-left wheel-right))) nil) (noerror nil) (t diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 66a1fa1a706..82a2c48fd5d 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -65,15 +65,13 @@ mouse-wheel-down-event (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) "Event used for scrolling down, beside `wheel-up', if any." :group 'mouse - :type 'symbol - :set #'mouse-wheel-change-button) + :type 'symbol) (defcustom mouse-wheel-up-event (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5) "Event used for scrolling up, beside `wheel-down', if any." :group 'mouse - :type 'symbol - :set #'mouse-wheel-change-button) + :type 'symbol) (defcustom mouse-wheel-click-event 'mouse-2 "Event that should be temporarily inhibited after mouse scrolling. @@ -464,25 +462,18 @@ mouse-wheel--setup-bindings (cond ;; Bindings for changing font size. ((and (consp binding) (eq (cdr binding) 'text-scale)) - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - 'wheel-down 'wheel-up)) - (when event - (mouse-wheel--add-binding `[,(append (car binding) (list event))] - 'mouse-wheel-text-scale)))) + (dolist (event '(wheel-down wheel-up)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-text-scale))) ((and (consp binding) (eq (cdr binding) 'global-text-scale)) - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - 'wheel-down 'wheel-up)) - (when event - (mouse-wheel--add-binding `[,(append (car binding) (list event))] - 'mouse-wheel-global-text-scale)))) + (dolist (event '(wheel-down wheel-up)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-global-text-scale))) ;; Bindings for scrolling. (t - (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event - mouse-wheel-left-event mouse-wheel-right-event - 'wheel-down 'wheel-up 'wheel-left 'wheel-right)) - (when event - (dolist (key (mouse-wheel--create-scroll-keys binding event)) - (mouse-wheel--add-binding key 'mwheel-scroll)))))))) + (dolist (event '(wheel-down wheel-up wheel-left wheel-right)) + (dolist (key (mouse-wheel--create-scroll-keys binding event)) + (mouse-wheel--add-binding key 'mwheel-scroll))))))) (when mouse-wheel-mode (mouse-wheel--setup-bindings)) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 5974f076556..1411a669891 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -114,10 +114,6 @@ (require 'thingatpt) ; end-of-thing (require 'warnings) ; warning-numeric-level, display-warning (require 'compile) ; for some faces -;; We need the next `require' to avoid compiler warnings and run-time -;; errors about mouse-wheel-up/down-event in builds --without-x, where -;; mwheel is not preloaded. -(require 'mwheel) ;; when-let*, if-let*, hash-table-keys, hash-table-values: (eval-when-compile (require 'subr-x)) (require 'project) @@ -1637,16 +1633,19 @@ flymake--mode-line-counter-scroll-next (defvar flymake--mode-line-counter-map (let ((map (make-sparse-keymap))) - ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events - ;; and vice versa!! - (define-key map (vector 'mode-line mouse-wheel-down-event) - #'flymake--mode-line-counter-scroll-prev) (define-key map [mode-line wheel-down] #'flymake--mode-line-counter-scroll-next) - (define-key map (vector 'mode-line mouse-wheel-up-event) - #'flymake--mode-line-counter-scroll-next) (define-key map [mode-line wheel-up] #'flymake--mode-line-counter-scroll-prev) + (when (< emacs-major-version 30) + (require 'mwheel) + (defvar mouse-wheel-down-event) (defvar mouse-wheel-up-event) + ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events + ;; and vice versa!! + (define-key map (vector 'mode-line mouse-wheel-down-event) + #'flymake--mode-line-counter-scroll-prev) + (define-key map (vector 'mode-line mouse-wheel-up-event) + #'flymake--mode-line-counter-scroll-next)) map)) (defun flymake--mode-line-counter-1 (type) diff --git a/src/fns.c b/src/fns.c index e4fa8157000..48d7b217cb6 100644 --- a/src/fns.c +++ b/src/fns.c @@ -4855,6 +4855,7 @@ check_mutable_hash_table (Lisp_Object obj, struct Lisp_Hash_Table *h) HASH is a previously computed hash code of KEY. Value is the index of the entry in H matching KEY. */ +/* FIXME: Callers shouldn't care about the return value! */ ptrdiff_t hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, hash_hash_t hash) diff --git a/src/keyboard.c b/src/keyboard.c index 1f7253a7da1..7c1822b3423 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7597,6 +7597,15 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, Lisp_Object symbol_kin /* Apply modifiers to that symbol. */ return apply_modifiers (modifiers, value); } + +Lisp_Object +base_mouse_symbol (int button) +{ + return modify_event_symbol (button, 0, + Qmouse_click, Vlispy_mouse_stem, + NULL, &mouse_syms, ASIZE (mouse_syms)); +} + /* Convert a list that represents an event type, such as (ctrl meta backspace), into the usual representation of that diff --git a/src/keyboard.h b/src/keyboard.h index 68e68bc2ae3..083b16e4896 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -456,7 +456,7 @@ #define EVENT_HEAD_KIND(event_head) \ extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, bool *, struct timespec *); extern int parse_solitary_modifier (Lisp_Object symbol); - +extern Lisp_Object base_mouse_symbol (int button); /* This is like Vthis_command, except that commands never set it. */ extern Lisp_Object real_this_command; diff --git a/src/xterm.c b/src/xterm.c index c8a43785564..fcbe7a1ec4f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14553,8 +14553,6 @@ x_construct_mouse_click (struct input_event *result, int x = event->x; int y = event->y; - /* Make the event type NO_EVENT; we'll change that when we decide - otherwise. */ result->kind = MOUSE_CLICK_EVENT; result->code = event->button - Button1; result->timestamp = event->time; @@ -14564,6 +14562,30 @@ x_construct_mouse_click (struct input_event *result, ? up_modifier : down_modifier)); + /* Convert pre-XInput2 wheel events represented as mouse-clicks. */ +#ifdef HAVE_XINPUT2 + if (!dpyinfo->supports_xi2) +#endif + { + Lisp_Object base = base_mouse_symbol (result->code); + int wheel + /* BEWARE: `mouse-wheel-UP-event' corresponds to + `wheel-DOWN' events and vice versa!! */ + = BASE_EQ (base, find_symbol_value (Qmouse_wheel_up_event)) ? 0 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_down_event)) ? 1 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_left_event)) ? 2 + : BASE_EQ (base, find_symbol_value (Qmouse_wheel_right_event)) ? 3 + : -1; + if (wheel >= 0) + { + result->kind = (event->type != ButtonRelease ? NO_EVENT + : wheel & 2 ? HORIZ_WHEEL_EVENT : WHEEL_EVENT); + result->code = 0; /* Not used. */ + result->modifiers &= ~(up_modifier || down_modifier); + result->modifiers |= wheel & 1 ? up_modifier : down_modifier; + } + } + /* If result->window is not the frame's edit widget (which can happen with GTK+ scroll bars, for example), translate the coordinates so they appear at the correct position. */ @@ -32444,6 +32466,11 @@ syms_of_xterm (void) DEFSYM (Qexpose, "expose"); DEFSYM (Qdont_save, "dont-save"); + DEFSYM (Qmouse_wheel_down_event, "mouse-wheel-down-event"); + DEFSYM (Qmouse_wheel_up_event, "mouse-wheel-up-event"); + DEFSYM (Qmouse_wheel_left_event, "mouse-wheel-left-event"); + DEFSYM (Qmouse_wheel_right_event, "mouse-wheel-right-event"); + #ifdef USE_GTK xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); staticpro (&xg_default_icon_file); -- 2.43.0 --=-=-=-- ------------=_1712673122-30341-1-- From unknown Sat Jun 14 19:40:47 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68796: Stefan's wheel event change Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Apr 2024 01:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 68796-done@debbugs.gnu.org, Eli Zaretskii Received: via spool by 68796-done@debbugs.gnu.org id=D68796.171271178013887 (code D ref 68796); Wed, 10 Apr 2024 01:17:02 +0000 Received: (at 68796-done) by debbugs.gnu.org; 10 Apr 2024 01:16:20 +0000 Received: from localhost ([127.0.0.1]:51816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruMZW-0003bV-Q3 for submit@debbugs.gnu.org; Tue, 09 Apr 2024 21:16:20 -0400 Received: from sonic312-25.consmr.mail.ne1.yahoo.com ([66.163.191.206]:45322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruMZV-0003bJ-4Z for 68796-done@debbugs.gnu.org; Tue, 09 Apr 2024 21:16:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1712711762; bh=VG1KrGCDHsz/L19+BRlmrk7hQaHy6o0cN988rr2FJPQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=TiJSYD+tF1RWfwwUV1F4JraXciOaWfAQrCdKsXIO3ekqPczEUcupn8kalQrwF6Fe0ldrMrmALYSj+S57tNNIk5Gp89BmjtuTHETc8zfQDqQKzMvcaXY9Z8B0DZLX+5thQiFyGqeGX5bBsogAK9iKceX5xnNIZgspZ1qe5bopGUOh2KCfRchc1V9wM9De/Gf0Mv6O20dhtoSMdvIB6MS1AjGphGHOnMbfzWe+k4x3h9ClkhjecEw79JGkbIvr0ZuctOsgbS2AA4j9/xV19JerDOr5KGdSPycmh5CJPn1gAa1G2h3rOoy+RVnwDpoggrmbJPwR9wr5ZJif0Q2vDDO71w== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1712711762; bh=+2O4+bdhMDkkJjtLnVQnMuFTA9xZX+MaS9TL1XcXMwZ=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=SlZpejv+JRo81RutDlF5HBRol0wChBjMxPDdS5aBhAoO/vg6a3ioTiTJPwPR2Iy/wjz0ECpH3CTEmRIg6A2ZK+5t2YnmIfJEWEMM5ZzhvodKpKZX69l12z0wt6GKojiUFkGDhNbDWuxUgzVUmXpXFLRgjeESksd2y5qBuPnWNqxZmX56AI1XHTdGg+tKdzjAW5gcQyJ73aFkurCEleSCPrSXLcjUE+yaosNXPS3c7q5bhCyXZMV+v+1DO2fThYXyrYxApn2seIby2/nBrQw8o8TxRZrnnxEoM5y0qaAA/Vo9daWHBf1TGW9L8SNYimLU7SGmTfdFKWk1YoRIvbWK2g== X-YMail-OSG: RiQPKwkVM1knAtDK63Vhxg.ga2yXhM.W1DaE4cqDPOTmkd0O_L_eLQrrlMCtBpy oCVnK_HmzBWW0r_ONC4cI_Wb3.WhgDZp2WJA77yy26.ZikPmFXlcW7aLM_ywwogS07tUUzL820vK ejNRHmavtNiXWYy0Au13bnYZB9sUn0YdSLt_U_h9aIQtju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Lz3w-- X-Sonic-MF: X-Sonic-ID: 8d414075-c944-4963-ab0d-1603cfa206e3 Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Wed, 10 Apr 2024 01:16:02 +0000 Received: by hermes--production-sg3-6dc75bc8fb-wtvcs (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 86dbf3fcf21fe6334335c6f04f88d989; Wed, 10 Apr 2024 01:15:58 +0000 (UTC) From: Po Lu In-Reply-To: (Stefan Monnier's message of "Tue, 09 Apr 2024 10:31:03 -0400") References: <877che34wk.fsf.ref@yahoo.com> <877che34wk.fsf@yahoo.com> <86cyr58zyw.fsf@gnu.org> Date: Wed, 10 Apr 2024 09:15:53 +0800 Message-ID: <87o7ai3tme.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22205 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 90 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > Pushed to `master, closing, Thanks.