Bug 454428 - Touchpad based kinetic scrolling in gtk applications does not work
Summary: Touchpad based kinetic scrolling in gtk applications does not work
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: 5.24.5
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
: 469965 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-05-26 09:04 UTC by Marcus Gursch
Modified: 2023-07-26 20:36 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Gursch 2022-05-26 09:04:28 UTC
SUMMARY

Touchpad based kinetic scrolling in gtk applications does not work when using kwin (wayland). After doing some digging and testing I found that the reason is the way wl_pointer.axis_stop events are sent to application windows. kwin (actually kwayland-server before it was merged in kwin) currently sends the stop event for each axis in its own frame:

```
[13:      wl_pointer] frame
[13:      wl_pointer] axis_source: 1 (finger)
[13:      wl_pointer] axis_stop: time: 1054759; axis: 0 (vertical)
[13:      wl_pointer] frame
[13:      wl_pointer] axis_source: 1 (finger)
[13:      wl_pointer] axis_stop: time: 1054759; axis: 1 (horizontal)
[13:      wl_pointer] frame
```

In other compositors (weston, wlroots based like sway, mutter) the stop events for both axes are bundled in a single frame:

```
[13:      wl_pointer] frame
[13:      wl_pointer] axis_source: 1 (finger)
[13:      wl_pointer] axis_stop: time: 1054759; axis: 0 (vertical)
[13:      wl_pointer] axis_stop: time: 1054759; axis: 1 (horizontal)
[13:      wl_pointer] frame
```

After patching kwayland-server to behave like sway etc kinetic scrolling works. The patch needs more work obviously and is only intended to show the bare minimum of changes to "make it work":

```
diff --git a/src/server/pointer_interface.cpp b/src/server/pointer_interface.cpp
index b552ac4..128c6d9 100644
--- a/src/server/pointer_interface.cpp
+++ b/src/server/pointer_interface.cpp
@@ -236,7 +236,11 @@ void PointerInterface::sendAxis(Qt::Orientation orientation, qreal delta, qint32
             }
             d->send_axis(resource->handle, d->seat->timestamp(), wlOrientation, wl_fixed_from_double(delta));
         } else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
-            d->send_axis_stop(resource->handle, d->seat->timestamp(), wlOrientation);
+            if (wlOrientation == 0)
+            {
+                d->send_axis_stop(resource->handle, d->seat->timestamp(), 0);
+                d->send_axis_stop(resource->handle, d->seat->timestamp(), 1);
+            }
         }
     }
 }
```

STEPS TO REPRODUCE
1. Open some gtk application, e.g. use gedit to display a large text file. 
2. Scroll using touchpad and lift fingers while they are moving.

OBSERVED RESULT

The scrolling stops immediately after lifting the fingers.

EXPECTED RESULT

The scrolling goes on after lifting the fingers up.

SOFTWARE/OS VERSIONS
OS: Manjaro 21.2.6
uname -a: Linux marcus-surface 5.17.9-arch1-2-surface #1 SMP PREEMPT Wed, 25 May 2022 15:31:19 +0000 x86_64 GNU/Linux
KDE Plasma Version: KDE Plasma 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Comment 1 Bug Janitor Service 2023-05-04 14:18:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4057
Comment 2 Vlad Zahorodnii 2023-05-05 11:09:34 UTC
Git commit e6b5cf283e619c712fe5f5f99e1c00bce06a7846 by Vlad Zahorodnii.
Committed on 05/05/2023 at 10:27.
Pushed by vladz into branch 'master'.

core: Batch pointer input device events

This change introduces InputDevice::pointerFrame(). The main motivation
behind it is to allow batching multiple pointer events within a single
event frame.

M  +6    -0    autotests/integration/test_helpers.cpp
M  +5    -0    src/backends/fakeinput/fakeinputdevice.cpp
M  +6    -0    src/backends/libinput/connection.cpp
M  +4    -0    src/backends/wayland/wayland_backend.cpp
M  +3    -0    src/backends/x11/windowed/x11_windowed_backend.cpp
M  +1    -0    src/core/inputdevice.h
M  +38   -10   src/input.cpp
M  +1    -0    src/input.h
M  +9    -0    src/pointer_input.cpp
M  +4    -0    src/pointer_input.h

https://invent.kde.org/plasma/kwin/commit/e6b5cf283e619c712fe5f5f99e1c00bce06a7846
Comment 3 Zamundaaa 2023-07-26 20:36:03 UTC
*** Bug 469965 has been marked as a duplicate of this bug. ***