Subject: Re: bug#52685: 29.0.50; Horizontal scrolling doesn't work when compiled with pgtk

From: Po Lu <[email-masked]>
Date: Wed, 22 Dec 2021 14:11:01 +0800

Andrey Listopadov <[email-masked]> writes:

> On Wed, Dec 22, 2021 at 4:09 AM Po Lu <[email-masked]> wrote:
>>
>> Po Lu <[email-masked]> writes:
>>
>> > Andrey Listopadov <[email-masked]> writes:
>> >
>> >> When `pixel-scroll-precision-mode' is disabled everything works fine.
>> >> When compiled without `--with-pgtk' but with `--with-xinput2'
>> >> `pixel-scroll-precision-mode' works as expected.
>> >
>> > Thanks, I will look into this now.
>>
>> Please try the following patch to see if it resolves your problem.
>> Thanks.
>>
>> diff --git a/src/pgtkterm.c b/src/pgtkterm.c
>> index bd61c65edd..bea2650584 100644
>> --- a/src/pgtkterm.c
>> +++ b/src/pgtkterm.c
>> @@ -6133,78 +6133,64 @@ scroll_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data)
>>      }
>>    else if (gdk_event_get_scroll_deltas (event, &delta_x, &delta_y))
>>      {
>> -      dpyinfo->scroll.acc_x += delta_x;
>> -      dpyinfo->scroll.acc_y += delta_y;
>> -      if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line
>> -         || !mwheel_coalesce_scroll_events)
>> +      if (!mwheel_coalesce_scroll_events)
>>         {
>> -         int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
>> -         inev.ie.kind = WHEEL_EVENT;
>> -         inev.ie.modifiers |= down_modifier;
>> -         inev.ie.arg = list3 (make_fixnum (nlines),
>> -                              make_float (-dpyinfo->scroll.acc_x * 100),
>> -                              make_float (-dpyinfo->scroll.acc_y * 100));
>> -         if (!mwheel_coalesce_scroll_events)
>> -           {
>> -             dpyinfo->scroll.acc_y = 0;
>> -             dpyinfo->scroll.acc_x = 0;
>> -           }
>> -         else
>> +         inev.ie.kind = ((fabs (delta_x) > fabs (delta_y))
>> +                         ? HORIZ_WHEEL_EVENT
>> +                         : WHEEL_EVENT);
>> +         inev.ie.modifiers = (inev.ie.kind == HORIZ_WHEEL_EVENT
>> +                              ? (delta_x >= 0 ? down_modifier : up_modifier)
>> +                              : (delta_y >= 0 ? down_modifier : up_modifier));
>> +         inev.ie.arg = list3 (Qnil, make_float (delta_x),
>> +                              make_float (delta_y));
>> +       }
>> +      else
>> +       {
>> +         dpyinfo->scroll.acc_x += delta_x;
>> +         dpyinfo->scroll.acc_y += delta_y;
>> +         if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line)
>>             {
>> +             int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
>> +             inev.ie.kind = WHEEL_EVENT;
>> +             inev.ie.modifiers |= down_modifier;
>> +             inev.ie.arg = list3 (make_fixnum (nlines),
>> +                                  make_float (-dpyinfo->scroll.acc_x * 100),
>> +                                  make_float (-dpyinfo->scroll.acc_y * 100));
>>               dpyinfo->scroll.acc_y -= dpyinfo->scroll.y_per_line * nlines;
>>             }
>> -       }
>> -      else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line
>> -              || !mwheel_coalesce_scroll_events)
>> -       {
>> -         int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
>> -         inev.ie.kind = WHEEL_EVENT;
>> -         inev.ie.modifiers |= up_modifier;
>> -         inev.ie.arg = list3 (make_fixnum (nlines),
>> -                              make_float (-dpyinfo->scroll.acc_x * 100),
>> -                              make_float (-dpyinfo->scroll.acc_y * 100));
>> -
>> -         if (!mwheel_coalesce_scroll_events)
>> +         else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line)
>>             {
>> -             dpyinfo->scroll.acc_y = 0;
>> -             dpyinfo->scroll.acc_x = 0;
>> +             int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
>> +             inev.ie.kind = WHEEL_EVENT;
>> +             inev.ie.modifiers |= up_modifier;
>> +             inev.ie.arg = list3 (make_fixnum (nlines),
>> +                                  make_float (-dpyinfo->scroll.acc_x * 100),
>> +                                  make_float (-dpyinfo->scroll.acc_y * 100));
>> +
>> +             dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines;
>>             }
>> -         else
>> -           dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines;
>> -       }
>> -      else if (dpyinfo->scroll.acc_x >= dpyinfo->scroll.x_per_char
>> -              || !mwheel_coalesce_scroll_events)
>> -       {
>> -         int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
>> -         inev.ie.kind = HORIZ_WHEEL_EVENT;
>> -         inev.ie.modifiers |= up_modifier;
>> -         inev.ie.arg = list3 (make_fixnum (nchars),
>> -                              make_float (-dpyinfo->scroll.acc_x * 100),
>> -                              make_float (-dpyinfo->scroll.acc_y * 100));
>> -
>> -         if (mwheel_coalesce_scroll_events)
>> -           dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars;
>> -         else
>> +         else if (dpyinfo->scroll.acc_x >= dpyinfo->scroll.x_per_char
>> +                  || !mwheel_coalesce_scroll_events)
>>             {
>> -             dpyinfo->scroll.acc_x = 0;
>> -             dpyinfo->scroll.acc_y = 0;
>> +             int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
>> +             inev.ie.kind = HORIZ_WHEEL_EVENT;
>> +             inev.ie.modifiers |= up_modifier;
>> +             inev.ie.arg = list3 (make_fixnum (nchars),
>> +                                  make_float (-dpyinfo->scroll.acc_x * 100),
>> +                                  make_float (-dpyinfo->scroll.acc_y * 100));
>> +
>> +             dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars;
>>             }
>> -       }
>> -      else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char)
>> -       {
>> -         int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
>> -         inev.ie.kind = HORIZ_WHEEL_EVENT;
>> -         inev.ie.modifiers |= down_modifier;
>> -         inev.ie.arg = list3 (make_fixnum (nchars),
>> -                              make_float (-dpyinfo->scroll.acc_x * 100),
>> -                              make_float (-dpyinfo->scroll.acc_y * 100));
>> -
>> -         if (mwheel_coalesce_scroll_events)
>> -           dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars;
>> -         else
>> +         else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char)
>>             {
>> -             dpyinfo->scroll.acc_x = 0;
>> -             dpyinfo->scroll.acc_y = 0;
>> +             int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
>> +             inev.ie.kind = HORIZ_WHEEL_EVENT;
>> +             inev.ie.modifiers |= down_modifier;
>> +             inev.ie.arg = list3 (make_fixnum (nchars),
>> +                                  make_float (-dpyinfo->scroll.acc_x * 100),
>> +                                  make_float (-dpyinfo->scroll.acc_y * 100));
>> +
>> +             dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars;
>>             }
>>         }
>>      }

> The patch doesn't apply.

That's odd.  Could you try updating your checkout, or failing that,
applying it manually?

Thanks.