Bug 577875 - [GTK3] MouseWheel event sent with event.count == 0 causing jumpy scrolling
Summary: [GTK3] MouseWheel event sent with event.count == 0 causing jumpy scrolling
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.22   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-17 11:39 EST by Thomas Singer CLA
Modified: 2022-02-10 00:21 EST (History)
4 users (show)

See Also:


Attachments
Snippet (1.28 KB, text/plain)
2021-12-30 03:46 EST, Thomas Singer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2021-12-17 11:39:28 EST
On Linux adding a MouseWheel event to a Composite and using a Notebook's touchpad might result in events with event.count == 0.
Comment 1 Thomas Singer CLA 2021-12-30 03:46:41 EST
Created attachment 287747 [details]
Snippet
Comment 2 Eclipse Genie CLA 2022-01-03 04:45:31 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/189229
Comment 3 Eclipse Genie CLA 2022-01-04 03:50:12 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/189241
Comment 4 Thomas Singer CLA 2022-01-04 10:50:38 EST
Explanation: until now a scrollevent only happend if the double value reported by GTK was > 0.333. I reckon, that way slow scroll events from some mousepads simply were ignored. Now the double values are accumulated and if the sum gets large (absolute) enough, an event is sent. The user who reported this problem is happy now.
Comment 5 Andrey Loskutov CLA 2022-01-10 07:51:04 EST
(In reply to Thomas Singer from comment #4)
> Explanation: until now a scrollevent only happend if the double value
> reported by GTK was > 0.333. I reckon, that way slow scroll events from some
> mousepads simply were ignored. Now the double values are accumulated and if
> the sum gets large (absolute) enough, an event is sent. The user who
> reported this problem is happy now.

Two things: 
1) why was user unhappy with events count == 0? Any errors? Wrong UI behavior?
2) Please add a better commit message explaining the change (like you did it above), amend & rebase & push the commit
Comment 6 Thomas Singer CLA 2022-01-11 01:29:50 EST
Problem: the scrolling did not work smooth enough. I then noticed that sending scroll events without a scroll amount is useless. I'll update the patch later.
Comment 7 Thomas Singer CLA 2022-01-11 06:09:45 EST
Answering your comment: some mouse pads seem to deliver only small amounts of scrolling. In other controls, e.g. Table, Tree, this causes smooth slow scrolling. If you try to implement an own component (see snippet), however, such slow scrolling was simply ignored and became "jumpy".

If you don't want to have the 2 double variables in all Controls, do you think it might be useful to move the whole method to Composite? But then incorrect code would remain in Control.
Comment 8 Thomas Singer CLA 2022-01-26 05:52:53 EST
Is the last patch acceptable now?
Comment 9 Alexandr Miloslavskiy CLA 2022-02-09 17:54:23 EST
I did an analysis of how native GTK applications handle scrolling, and my findings are:
1) Contrary to my expectations, using a non-smooth mouse wheel still
   produces smooth scrolling events in 'Control.gtk_scroll_event()':
   false = gdk_event_get_scroll_direction()
   true  = gdk_event_get_scroll_deltas()
   +1/-1 = delta_y
2) Synaptics touchpad produces smooth scrolling events on my Ubuntu 21.04
   It sends events with 'delta_y' containing all kinds of values.
3) GTK scrolls the following number of pixels per each unit of 'delta_y' :
   pixels = pow(control_height, 2.0/3.0)
   See 'get_scroll_unit()' called from 'gtk_scrolled_window_scroll_event()'

Now what does SWT's 'event.count' even mean?
4) SWT-GTK implementation sends 'SWT.SCROLL_LINE' with value (3*delta_y)
5) 3x multiplier is first seen in Bug 7101 for directional scrolling
   Bug 7101 adds support for both Windows and GTK.
   On Windows, 'SPI_GETWHEELSCROLLLINES' is used to query the
   multiplier. It equals 3 by default. I understand that same
   multiplier was used in GTK to have similar behavior.
6) Bug 393793 adds smooth scrolling, also with 3x multiplier
   I understand that 3x is used to match existing code for directional
   scrolling.
7) Summary: value of 'event.count' matches that on Windows
   However, on Windows, every unit of 'event.count' scrolls one row
   (line of text, row of Table, etc), and on GTK, it scrolls pixels
   and distance depends on Control's height. It's up to SWT application
   to decide whether to have same behavior cross-platform or to follow
   platform's rules for scrolling.

If Windows style behavior is desirable, scroll one row per 'event.count'.
If GTK style behavior is desirable, use formula from (3).
Comment 10 Alexander Kurtakov CLA 2022-02-10 00:21:30 EST
(In reply to Alexandr Miloslavskiy from comment #9)
> I did an analysis of how native GTK applications handle scrolling, and my
> findings are:
> 1) Contrary to my expectations, using a non-smooth mouse wheel still
>    produces smooth scrolling events in 'Control.gtk_scroll_event()':
>    false = gdk_event_get_scroll_direction()
>    true  = gdk_event_get_scroll_deltas()
>    +1/-1 = delta_y
> 2) Synaptics touchpad produces smooth scrolling events on my Ubuntu 21.04
>    It sends events with 'delta_y' containing all kinds of values.
> 3) GTK scrolls the following number of pixels per each unit of 'delta_y' :
>    pixels = pow(control_height, 2.0/3.0)
>    See 'get_scroll_unit()' called from 'gtk_scrolled_window_scroll_event()'
> 
> Now what does SWT's 'event.count' even mean?
> 4) SWT-GTK implementation sends 'SWT.SCROLL_LINE' with value (3*delta_y)
> 5) 3x multiplier is first seen in Bug 7101 for directional scrolling
>    Bug 7101 adds support for both Windows and GTK.
>    On Windows, 'SPI_GETWHEELSCROLLLINES' is used to query the
>    multiplier. It equals 3 by default. I understand that same
>    multiplier was used in GTK to have similar behavior.
> 6) Bug 393793 adds smooth scrolling, also with 3x multiplier
>    I understand that 3x is used to match existing code for directional
>    scrolling.
> 7) Summary: value of 'event.count' matches that on Windows
>    However, on Windows, every unit of 'event.count' scrolls one row
>    (line of text, row of Table, etc), and on GTK, it scrolls pixels
>    and distance depends on Control's height. It's up to SWT application
>    to decide whether to have same behavior cross-platform or to follow
>    platform's rules for scrolling.
> 
> If Windows style behavior is desirable, scroll one row per 'event.count'.
> If GTK style behavior is desirable, use formula from (3).

System default scrolling should be the preferred one IMHO. Having two apps scroll direrently on same machine is terrible user experience. By the numbe of the bugs you refer to - this must have been gtk 1.x time so it's behavior has been quite different or even not yet well defined.