From dc2b7a26a8266a58d6130b5c5b270d8de9cbfc40 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo <giulio.camuffo@jollamobile.com> Date: Tue, 17 Feb 2015 11:14:46 +0200 Subject: [PATCH] Check the surface input mask for hover events We also remove the hoverLeaveEvent() reimplementation, as it serves no real purpose. Change-Id: Ic218be864564032c38f91d3946ccfdf2ccfc0d25 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> --- .../compositor_api/qwaylandsurfaceitem.cpp | 16 ++++++++-------- .../compositor_api/qwaylandsurfaceitem.h | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp index 06ea3ad48..c3951909f 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -174,6 +174,10 @@ void QWaylandSurfaceItem::mouseReleaseEvent(QMouseEvent *event) void QWaylandSurfaceItem::hoverEnterEvent(QHoverEvent *event) { if (surface()) { + if (!surface()->inputRegionContains(event->pos())) { + event->ignore(); + return; + } QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); inputDevice->sendMouseMoveEvent(this, event->pos()); } @@ -182,14 +186,10 @@ void QWaylandSurfaceItem::hoverEnterEvent(QHoverEvent *event) void QWaylandSurfaceItem::hoverMoveEvent(QHoverEvent *event) { if (surface()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseMoveEvent(this, event->pos()); - } -} - -void QWaylandSurfaceItem::hoverLeaveEvent(QHoverEvent *event) -{ - if (surface()) { + if (!surface()->inputRegionContains(event->pos())) { + event->ignore(); + return; + } QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); inputDevice->sendMouseMoveEvent(this, event->pos()); } diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h index 7a4054227..7af8c8821 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.h +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h @@ -94,7 +94,6 @@ protected: void mouseReleaseEvent(QMouseEvent *event); void hoverEnterEvent(QHoverEvent *event); void hoverMoveEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); -- GitLab