From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#51891: 29.0.50; [PATCH] Pixel delta support for wheel events on X Date: Tue, 16 Nov 2021 14:39:56 +0100 Message-ID: <871r3gnrrn.fsf@gmail.com> References: <87zgq4uvh0.fsf.ref@yahoo.com> <87zgq4uvh0.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27934"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu To: 51891@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 16 14:44:24 2021 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 1mmyl6-00079V-Lk for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 14:44:24 +0100 Original-Received: from localhost ([::1]:44890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmyl5-0002Dz-P7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 08:44:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmyhz-0008AI-BX for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 08:41:11 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmyhq-0004LY-1F for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 08:41:11 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mmyhp-0006a9-TK for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 08:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Nov 2021 13:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51891 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51891-submit@debbugs.gnu.org id=B51891.163707000625146 (code B ref 51891); Tue, 16 Nov 2021 13:41:01 +0000 Original-Received: (at 51891) by debbugs.gnu.org; 16 Nov 2021 13:40:06 +0000 Original-Received: from localhost ([127.0.0.1]:57537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmygv-0006XW-NC for submit@debbugs.gnu.org; Tue, 16 Nov 2021 08:40:06 -0500 Original-Received: from mail-wm1-f41.google.com ([209.85.128.41]:38625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmygt-0006Wh-Ko for 51891@debbugs.gnu.org; Tue, 16 Nov 2021 08:40:04 -0500 Original-Received: by mail-wm1-f41.google.com with SMTP id p3-20020a05600c1d8300b003334fab53afso1998340wms.3 for <51891@debbugs.gnu.org>; Tue, 16 Nov 2021 05:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=dhaTAwb/9fC7kbT6EnbrX/9PiwPvlEJDHDaig9aQe0c=; b=gT9fGxyMcrjdcpr86wAAwXdiW/kEtVkBrlnOs7uqk977+9dmUvBBCtz3VawoEAZDv6 RmcxC9QxSH2MKXzcb0azLFRY/v/aleVf4d1B3BX+i0OjYFfgO2T/qDl9Jkq0+R7zYDXT 5zd1ZaWjv4ve0rH0ax6cCLmv3wN/Do+/yPpMJPuR7vi0er1h9B9r/vMePQj+vg1wPXA7 ZHNyAPqBU/S/pu4RgokM2+6bDASSVwBVamN35xWpfR8SgKnGTiI3ukw1E2gUYB/SeaEc VYaFvVTF1hPfKFvhYByZ79xII3VfMci4XQ9MIQ77t2Be87rrgFdKOM2fzVDRGtDUKBKI G7Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=dhaTAwb/9fC7kbT6EnbrX/9PiwPvlEJDHDaig9aQe0c=; b=vRJiQqyvr1ZXmNr9C65L/c4Cs3KGs/EJRHfTtj0vO2sVNaWq/uXzgrvUKQDiF53Zrx Rf08lJWq0R2AOCvZTwaYlq9Bmqn7FlkN8tk39KHiYegxYo/vu5XMWfP/zECjA1JoFqcM xr49DdEU+qi5Lc55vG4VAPCKaCw1CemnpzM3SqpRHKaVEphZiKMkEBqdUiMokBSbxfYq Wy2B/u1SuFm77lafmz1Er88CoJ4GV5IakKjeJNtWFANA5PPG6f4MEuiahRaGL/v10t7r XPBC1qpfYP/XxpNhNh8wGBDOHDTzy3GFNi2oP5Q92MKbKXj2cdwC8viDEbQKysfC2X2U 9oqg== X-Gm-Message-State: AOAM533iwTRIkYCrPg4pL4vEqsrz1Bm/i56sMH1exxfuTKTTfHEIjkRL pfUCEf+UcIZNvRjf2w34KWo= X-Google-Smtp-Source: ABdhPJwW6qBaVblOEboT95hM2Bwh5wjBRsEsbDDaBKf/hbqEDwgv80U0eiV8t8gYUDd1HnCizxKPXA== X-Received: by 2002:a7b:c388:: with SMTP id s8mr68706741wmj.170.1637069997501; Tue, 16 Nov 2021 05:39:57 -0800 (PST) Original-Received: from rltb ([2a01:e0a:3f3:fb50:96da:7a41:4cc2:4c20]) by smtp.gmail.com with ESMTPSA id n13sm17751101wrt.44.2021.11.16.05.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 05:39:57 -0800 (PST) In-Reply-To: <87zgq4uvh0.fsf@yahoo.com> (Po Lu via's message of "Tue, 16 Nov 2021 20:38:03 +0800") 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" Xref: news.gmane.io gmane.emacs.bugs:220119 Archived-At: >>>>> On Tue, 16 Nov 2021 20:38:03 +0800, Po Lu via "Bug reports for GNU Em= acs, the Swiss army knife of text editors" said: Po> +occurred. The event may have additional arguments after Po> +@var{position}. The third argument after @var{position}, if prese= nt, Po> +is a property list of the form @w{@code{(:delta-x @var{x} :delta-y Po> +@var{y})}}, where @var{x} and @var{y} are the number of pixels to Po> +scroll by in each axis. Is there really a need for this to be a plist with :delta-x and :delta-y in it? Just a cons of x and y would work. Po> @vindex mouse-wheel-up-event Po> @vindex mouse-wheel-down-event Po> diff --git a/src/keyboard.c b/src/keyboard.c Po> index de9805df32..276fd8c5aa 100644 Po> --- a/src/keyboard.c Po> +++ b/src/keyboard.c Po> @@ -5980,7 +5980,10 @@ make_lispy_event (struct input_event *event) Po> ASIZE (wheel_syms)); Po> } =20 Po> - if (NUMBERP (event->arg)) Po> + if (CONSP (event->arg)) Po> + return list5 (head, position, make_fixnum (double_click_count), Po> + XCAR (event->arg), XCDR (event->arg)); Po> + else if (NUMBERP (event->arg)) Po> return list4 (head, position, make_fixnum (double_click_= count), event-> arg); Po> else if (event->modifiers & (double_modifier | triple_modifier)) Po> diff --git a/src/termhooks.h b/src/termhooks.h Po> index e7539bbce2..43a9fc2f22 100644 Po> --- a/src/termhooks.h Po> +++ b/src/termhooks.h Po> @@ -119,7 +119,12 @@ #define EMACS_TERMHOOKS_H Po> .timestamp gives a timestamp (in Po> milliseconds) for the event. Po> .arg may contain the number of Po> - lines to scroll. */ Po> + lines to scroll, or a list of Po> + the form (NUMBER-OF-LINES . Po> + (:DELTA-X :DELTA-Y Y)) where Po> + DELTA-X and DELTA-Y are the number Po> + of pixels on each axis to scroll Po> + by. */ I don=CA=BCt think this is quite right. The 'X' is missing, and it=CA=BCs '= X' and 'Y' that give the number of pixels. And :delta-x and :delta-y (lowercase). Po> HORIZ_WHEEL_EVENT, /* A wheel event generated by a se= cond Po> horizontal wheel that is presen= t on some Po> mice. See WHEEL_EVENT. */ Po> diff --git a/src/xfns.c b/src/xfns.c Po> index b33b40b330..9d70ba479b 100644 Po> --- a/src/xfns.c Po> +++ b/src/xfns.c Po> @@ -8085,6 +8085,9 @@ syms_of_xfns (void) =20 Po> #ifdef HAVE_XINPUT2 Po> DEFSYM (Qxinput2, "xinput2"); Po> + DEFSYM (QCdelta_x, ":delta-x"); Po> + DEFSYM (QCdelta_y, ":delta-y"); Po> + Po> Fprovide (Qxinput2, Qnil); Po> #endif =20 Po> diff --git a/src/xterm.c b/src/xterm.c Po> index 63754a2cb6..6eb361efca 100644 Po> --- a/src/xterm.c Po> +++ b/src/xterm.c Po> @@ -9935,7 +9935,7 @@ handle_one_xevent (struct x_display_info *dpy= info, Po> block_input (); =20 Po> struct xi_scroll_valuator_t *val; Po> - double delta; Po> + double delta, scroll_unit; =20 Po> delta =3D x_get_scroll_valuator_delta (dpyinfo, xev->devicei= d, Po> i, *values, &val); Po> @@ -9943,6 +9943,7 @@ handle_one_xevent (struct x_display_info *dpy= info, Po> if (delta !=3D DBL_MAX) Po> { Po> f =3D mouse_or_wdesc_frame (dpyinfo, xev->event); Po> + scroll_unit =3D pow (FRAME_PIXEL_HEIGHT (f), 2.0 / 3.0); Po> found_valuator =3D true; =20 Po> if (signbit (delta) !=3D signbit (val->emacs_value)) Po> @@ -9975,7 +9976,15 @@ handle_one_xevent (struct x_display_info *dp= yinfo, Po> inev.ie.modifiers Po> |=3D x_x_to_emacs_modifiers (dpyinfo, xev-> mods.effective); Po> - inev.ie.arg =3D Qnil; Po> + Po> + if (val->horizontal) Po> + inev.ie.arg =3D list5 (Qnil, QCdelta_x, Po> + make_float (delta * scroll_unit), Po> + QCdelta_y, make_float (0)); Po> + else Po> + inev.ie.arg =3D list5 (Qnil, QCdelta_x, make_float (0), Po> + QCdelta_y, Po> + make_float (delta * scroll_unit)); So the :delta-y value is always 0 when :delta-x is non-zero and vice versa? Why bother to return both then? (and why floats and not ints?). Robert --=20