summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-04-19 16:03:56 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-04-20 19:37:41 +0200
commitdc886bc6de2c0061a840bea2426663c3be2ecd26 (patch)
tree7ca849b5a24c3e62f2968f0efed5c499a2777231 /vcl/qt5
parente44f71dd3439cd1c473b2e32516e33986de042f3 (diff)
tdf#140463 Qt handle mouse enter+leave events
Currently just implemented for the QtWidget, but still as a static function, so it may be used for QtObject at some point too. But there is no (mouse) enter or leave event function in QWindow, so no way to handle these there. And since we can't modify the returned QWidget from QWidget::createWindowContainer, the only way would be to expand the static QtWidget::handleEvent used by QtObjectWindow::event ... if it's actually needed at some point. Change-Id: If9009e5dfca508acd1e702df1a17eb8ad7c29690 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133190 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtWidget.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 33320c577f94..2ac27548ac6a 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -207,6 +207,34 @@ void QtWidget::mouseMoveEvent(QMouseEvent* pEvent)
pEvent->accept();
}
+void QtWidget::handleMouseEnterLeaveEvents(const QtFrame& rFrame, QEvent* pQEvent)
+{
+ const qreal fRatio = rFrame.devicePixelRatioF();
+ const QWidget* pWidget = rFrame.GetQWidget();
+ const Point aPos = toPoint(pWidget->mapFromGlobal(QCursor::pos()) * fRatio);
+
+ SalMouseEvent aEvent;
+ aEvent.mnX
+ = QGuiApplication::isLeftToRight() ? aPos.X() : round(pWidget->width() * fRatio) - aPos.X();
+ aEvent.mnY = aPos.Y();
+ aEvent.mnTime = 0;
+ aEvent.mnButton = 0;
+ aEvent.mnCode = GetKeyModCode(QGuiApplication::keyboardModifiers())
+ | GetMouseModCode(QGuiApplication::mouseButtons());
+
+ SalEvent nEventType;
+ if (pQEvent->type() == QEvent::Enter)
+ nEventType = SalEvent::MouseMove;
+ else
+ nEventType = SalEvent::MouseLeave;
+ rFrame.CallCallback(nEventType, &aEvent);
+ pQEvent->accept();
+}
+
+void QtWidget::leaveEvent(QEvent* pEvent) { handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
+
+void QtWidget::enterEvent(QEvent* pEvent) { handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
+
void QtWidget::wheelEvent(QWheelEvent* pEvent)
{
SalWheelMouseEvent aEvent;