mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
79 lines
3.5 KiB
Diff
79 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: maxjivi05 <maxjividen@gmail.com>
|
|
Date: Wed, 28 Oct 2026 07:28:45 -0400
|
|
Subject: [PATCH] Forward nested scroll source
|
|
|
|
---
|
|
src/backends/wayland/wayland_backend.cpp | 42 +++++++++++++++++++++---
|
|
1 file changed, 38 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/backends/wayland/wayland_backend.cpp b/src/backends/wayland/wayland_backend.cpp
|
|
index 54f5a70..25bd0d0 100644
|
|
--- a/src/backends/wayland/wayland_backend.cpp
|
|
+++ b/src/backends/wayland/wayland_backend.cpp
|
|
@@ -29,6 +29,9 @@
|
|
|
|
#include <QAbstractEventDispatcher>
|
|
|
|
+#include <array>
|
|
+#include <memory>
|
|
+
|
|
#include <drm_fourcc.h>
|
|
#include <fcntl.h>
|
|
#include <gbm.h>
|
|
@@ -123,8 +126,31 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Pointer *pointer, Wayla
|
|
}
|
|
Q_EMIT pointerButtonChanged(button, state, std::chrono::milliseconds(time), this);
|
|
});
|
|
- // TODO: Send discreteDelta and source as well.
|
|
- connect(pointer, &Pointer::axisChanged, this, [this](quint32 time, Pointer::Axis nativeAxis, qreal delta) {
|
|
+ auto axisSource = std::make_shared<PointerAxisSource>(PointerAxisSource::Unknown);
|
|
+ auto axisDiscrete = std::make_shared<std::array<qint32, 2>>();
|
|
+ connect(pointer, &Pointer::axisSourceChanged, this, [axisSource](Pointer::AxisSource source) {
|
|
+ switch (source) {
|
|
+ case Pointer::AxisSource::Wheel:
|
|
+ *axisSource = PointerAxisSource::Wheel;
|
|
+ break;
|
|
+ case Pointer::AxisSource::Finger:
|
|
+ *axisSource = PointerAxisSource::Finger;
|
|
+ break;
|
|
+ case Pointer::AxisSource::Continuous:
|
|
+ *axisSource = PointerAxisSource::Continuous;
|
|
+ break;
|
|
+ case Pointer::AxisSource::WheelTilt:
|
|
+ *axisSource = PointerAxisSource::WheelTilt;
|
|
+ break;
|
|
+ default:
|
|
+ *axisSource = PointerAxisSource::Unknown;
|
|
+ break;
|
|
+ }
|
|
+ });
|
|
+ connect(pointer, &Pointer::axisDiscreteChanged, this, [axisDiscrete](Pointer::Axis nativeAxis, qint32 discreteDelta) {
|
|
+ (*axisDiscrete)[nativeAxis == Pointer::Axis::Vertical ? 0 : 1] = discreteDelta * 120;
|
|
+ });
|
|
+ connect(pointer, &Pointer::axisChanged, this, [this, axisSource, axisDiscrete](quint32 time, Pointer::Axis nativeAxis, qreal delta) {
|
|
PointerAxis axis;
|
|
switch (nativeAxis) {
|
|
case Pointer::Axis::Horizontal:
|
|
@@ -136,10 +162,18 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Pointer *pointer, Wayla
|
|
default:
|
|
Q_UNREACHABLE();
|
|
}
|
|
- Q_EMIT pointerAxisChanged(axis, delta, 0, PointerAxisSource::Unknown, false, std::chrono::milliseconds(time), this);
|
|
+ qint32 &discrete = (*axisDiscrete)[nativeAxis == Pointer::Axis::Vertical ? 0 : 1];
|
|
+ Q_EMIT pointerAxisChanged(axis, delta, discrete, *axisSource, false, std::chrono::milliseconds(time), this);
|
|
+ discrete = 0;
|
|
+ });
|
|
+ connect(pointer, &Pointer::axisStopped, this, [this, axisSource](quint32 time, Pointer::Axis nativeAxis) {
|
|
+ const PointerAxis axis = nativeAxis == Pointer::Axis::Vertical ? PointerAxis::Vertical : PointerAxis::Horizontal;
|
|
+ Q_EMIT pointerAxisChanged(axis, 0, 0, *axisSource, false, std::chrono::milliseconds(time), this);
|
|
});
|
|
|
|
- connect(pointer, &Pointer::frame, this, [this]() {
|
|
+ connect(pointer, &Pointer::frame, this, [this, axisSource, axisDiscrete]() {
|
|
+ *axisSource = PointerAxisSource::Unknown;
|
|
+ axisDiscrete->fill(0);
|
|
Q_EMIT pointerFrame(this);
|
|
});
|
|
|