unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: 51891@debbugs.gnu.org
Cc: Po Lu <luangruo@yahoo.com>
Subject: bug#51891: 29.0.50; [PATCH] Pixel delta support for wheel events on X
Date: Tue, 16 Nov 2021 14:39:56 +0100	[thread overview]
Message-ID: <871r3gnrrn.fsf@gmail.com> (raw)
In-Reply-To: <87zgq4uvh0.fsf@yahoo.com> (Po Lu via's message of "Tue, 16 Nov 2021 20:38:03 +0800")

>>>>> On Tue, 16 Nov 2021 20:38:03 +0800, Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:
    Po> +occurred.  The event may have additional arguments after
    Po> +@var{position}.  The third argument after @var{position}, if present,
    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>  	}
 
    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ʼt think this is quite right. The 'X' is missing, and itʼs '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 second
    Po>                                     horizontal wheel that is present 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)
 
    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
 
    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 *dpyinfo,
    Po>  		    block_input ();
 
    Po>  		    struct xi_scroll_valuator_t *val;
    Po> -		    double delta;
    Po> +		    double delta, scroll_unit;
 
    Po>  		    delta = x_get_scroll_valuator_delta (dpyinfo, xev->deviceid,
    Po>  							 i, *values, &val);
    Po> @@ -9943,6 +9943,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
    Po>  		    if (delta != DBL_MAX)
    Po>  		      {
    Po>  			f = mouse_or_wdesc_frame (dpyinfo, xev->event);
    Po> +			scroll_unit = pow (FRAME_PIXEL_HEIGHT (f), 2.0 / 3.0);
    Po>  			found_valuator = true;
 
    Po>  			if (signbit (delta) != signbit (val->emacs_value))
    Po> @@ -9975,7 +9976,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
    Po>  			inev.ie.modifiers
    Po>  			  |= x_x_to_emacs_modifiers (dpyinfo,
    xev-> mods.effective);
    Po> -			inev.ie.arg = Qnil;
    Po> +
    Po> +			if (val->horizontal)
    Po> +			  inev.ie.arg = list5 (Qnil, QCdelta_x,
    Po> +					       make_float (delta * scroll_unit),
    Po> +					       QCdelta_y, make_float (0));
    Po> +			else
    Po> +			  inev.ie.arg = 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
-- 





  reply	other threads:[~2021-11-16 13:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87zgq4uvh0.fsf.ref@yahoo.com>
2021-11-16 12:38 ` bug#51891: 29.0.50; [PATCH] Pixel delta support for wheel events on X Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-16 13:39   ` Robert Pluim [this message]
2021-11-17  0:34     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-17  2:38       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-17 13:33         ` Eli Zaretskii
2021-11-18  0:15           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-18  7:33             ` Eli Zaretskii
2021-11-18  9:17               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-18 10:27                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19 13:05                   ` Eli Zaretskii
2021-11-19 13:10                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19 13:23                       ` Eli Zaretskii
2021-11-20  0:30                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-20  7:06                           ` Eli Zaretskii
2021-11-19 13:09                 ` Eli Zaretskii
2021-11-19 13:24                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19 13:55                     ` Eli Zaretskii
2021-11-20 10:28                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r3gnrrn.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=51891@debbugs.gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).