From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right Date: Tue, 30 Jan 2024 10:00:17 +0800 Message-ID: <871q9zh972.fsf@yahoo.com> References: Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11336"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68796@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 30 03:01:32 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rUdRM-0002lZ-Md for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Jan 2024 03:01:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUdQn-0000mP-AR; Mon, 29 Jan 2024 21:00:57 -0500 Original-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 1rUdQk-0000lM-QH for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 21:00:55 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUdQk-0007Gv-HB for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 21:00:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rUdQt-0005FV-2A for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 21:01:03 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 68796-submit@debbugs.gnu.org id=B68796.170658005720151 (code B ref 68796); Tue, 30 Jan 2024 02:01:03 +0000 Original-Received: (at 68796) by debbugs.gnu.org; 30 Jan 2024 02:00:57 +0000 Original-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 Original-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_tI1eqVoCIpUokLdmhWs U3tTkYX1XmMr.V6ks0q3nj41h3RkZHZbMZPJaK7w.KZlYKeJz19EOQe.9JLWIPeKoUUhGZlq9P2B 7SIgiRxWEbvOAkpOe0G5NGcqrFYYo6pD7lv7F2v4YUooufVFBafgCTCmWusGnVgPda3LaaY7hSgk HWk1g90nHmsfCvO_iojRkrrwTstpYfko7s1.GG87GwRFZRXTbrzWQC9jeORPX_tT5QBYITSotHOj pW4MVzxQPJb_PWmP._jxWNV4oWpcIJfz.dHCfajE2HUow9Iw4EHOQHVgECyk2VoYIjMSB_u8pkq5 vDwgmLhASQyUO64b9B2b.2ovhg4MVXYRUeX.xHxD.J8BG8ot2aCFVqZHjaIIG0RlRKPiASi6t5lO O9CrbVHCUQiV5YQEcUzv5jnpo9IfKlO.nylhOd0wqYeBYyetU4oBC5WGDpK87HeR7E.2WJQ31AUm QJo_j0WyEIYMJYY7F07luJRyXzHyKSuTQU2Y_Ej9vFLYZ7hrL50RtO1HtxchBAgWBHVjaVnL5D8H 9CHt5fc12QhfmjpKnKyRppanC7oz9VUFEzFNxFeapXwoLgB1qgvUqkxVJ_Axc9BaHC1_e0JKOYTQ YYJLjcKgfwLTCXP6Ysz5545Ia2kUzY5HNHwFDQeWAeCkd7DugZGcJRLP7IrMWU5Oe7GEv0ycLHvm XxBE8y5qM6zsQaFLCYyeJnxpXmKBxJ9OhFVKBi8wKmPJwDVYBEJRwJyqkciSw9.vBF3ADcejcEYm l0_Xo5Ey7RDuOm4uj0lioOcuIis64en2ugFZdOaX5v X-Sonic-MF: X-Sonic-ID: 1e8b4973-028e-4ca0-91f7-501408d63369 Original-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 Original-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) In-Reply-To: (Stefan Monnier's message of "Mon, 29 Jan 2024 09:45:01 -0500") X-Mailer: WebService/1.1.22046 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279154 Archived-At: 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.