bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51891: 29.0.50; [PATCH] Pixel delta support for wheel events on X


From: Robert Pluim
Subject: bug#51891: 29.0.50; [PATCH] Pixel delta support for wheel events on X
Date: Tue, 16 Nov 2021 14:39:56 +0100

>>>>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]