Fix wheel events when the decorations are enabled

We must offset the wheel events' position, as we do with the other
types of mouse events.

Change-Id: If85e93ffe95304c7dee4c2a3ff195a73243a8182
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
Giulio Camuffo 2015-05-09 10:29:15 +03:00
parent 58f3c602f0
commit 7d54e5527e
3 changed files with 29 additions and 5 deletions

View File

@ -494,6 +494,15 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time
}
}
class WheelEvent : public QWaylandPointerEvent
{
public:
WheelEvent(ulong t, const QPointF &l, const QPointF &g, const QPoint &pd, const QPoint &ad)
: QWaylandPointerEvent(QWaylandPointerEvent::Wheel, t, l, g, pd, ad)
{
}
};
void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, int32_t value)
{
QWaylandWindow *window = mFocus;
@ -517,10 +526,8 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in
angleDelta.setY(valueDelta);
}
QWindowSystemInterface::handleWheelEvent(window->window(),
time, mSurfacePos,
mGlobalPos, pixelDelta,
angleDelta);
WheelEvent e(time, mSurfacePos, mGlobalPos, pixelDelta, angleDelta);
window->handleMouse(mParent, e);
}
#ifndef QT_NO_WAYLAND_XKB

View File

@ -259,7 +259,8 @@ class QWaylandPointerEvent
public:
enum Type {
Enter,
Motion
Motion,
Wheel
};
inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, Qt::MouseButtons b, Qt::KeyboardModifiers m)
: type(t)
@ -269,6 +270,14 @@ public:
, buttons(b)
, modifiers(m)
{}
inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, const QPoint &pd, const QPoint &ad)
: type(t)
, timestamp(ts)
, local(l)
, global(g)
, pixelDelta(pd)
, angleDelta(ad)
{}
Type type;
ulong timestamp;
@ -276,6 +285,8 @@ public:
QPointF global;
Qt::MouseButtons buttons;
Qt::KeyboardModifiers modifiers;
QPoint pixelDelta;
QPoint angleDelta;
};
}

View File

@ -625,6 +625,9 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan
case QWaylandPointerEvent::Motion:
QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.modifiers);
break;
case QWaylandPointerEvent::Wheel:
QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta);
break;
}
}
@ -684,6 +687,9 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
case QWaylandPointerEvent::Motion:
QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers);
break;
case QWaylandPointerEvent::Wheel:
QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta);
break;
}
mMouseEventsInContentArea = true;