summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2013-01-28 17:12:46 +0100
committerAndy Nichols <andy.nichols@digia.com>2013-01-31 12:02:06 +0100
commit5d188139d3f9d8aeaca10a941c7fb177c709a0c0 (patch)
tree9b0656062613be010bce0f90821229f16654fe92
parent744f8ce55c04d8cac73c8283ab7552456a8ee15d (diff)
Fix scroll wheel behavior for Wayland clients
There are inconsistencies between how we represent mouse wheel deltas and how the Weston compositor does. For better compatibility with Weston we need to change our mouse axis events too look like Up: positive Y (+10) Down: negative Y (-10) Left: positive X (+10) Right: negative X (-10) Our synthesised mouse wheel deltas are (+ or -)120 with both axes inversed. With this change Qt Clients should behave the same way on both Weston and QtCompositors. Change-Id: I37b4fd8cbb93e5a1a135a60ae8c3547c823aeba2 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.cpp2
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp20
2 files changed, 17 insertions, 5 deletions
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp
index c951ecf05..6b8f36409 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp
@@ -361,7 +361,7 @@ void InputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
uint32_t time = m_compositor->currentTimeMsecs();
uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL
: WL_POINTER_AXIS_VERTICAL_SCROLL;
- wl_pointer_send_axis(resource, time, axis, wl_fixed_from_double(delta / 120.0));
+ wl_pointer_send_axis(resource, time, axis, wl_fixed_from_int(-delta / 12));
}
void InputDevice::updateModifierState(uint code, int state)
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index a3a31e3d7..aaef268e5 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -358,14 +358,26 @@ void QWaylandInputDevice::pointer_axis(void *data,
Q_UNUSED(pointer);
QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
QWaylandWindow *window = inputDevice->mPointerFocus;
- Qt::Orientation orientation = axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ? Qt::Horizontal
- : Qt::Vertical;
+ QPoint pixelDelta;
+ QPoint angleDelta;
+
+ //normalize value and inverse axis
+ int valueDelta = wl_fixed_to_int(value) * -12;
+
+ if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
+ pixelDelta = QPoint();
+ angleDelta.setX(valueDelta);
+ } else {
+ pixelDelta = QPoint();
+ angleDelta.setY(valueDelta);
+ }
+
QWindowSystemInterface::handleWheelEvent(window->window(),
time,
inputDevice->mSurfacePos,
inputDevice->mGlobalPos,
- int(wl_fixed_to_double(value) * 120.0),
- orientation);
+ pixelDelta,
+ angleDelta);
}
#ifndef QT_NO_WAYLAND_XKB