summaryrefslogtreecommitdiff
path: root/vcl/qt5/Qt5Widget.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/qt5/Qt5Widget.cxx')
-rw-r--r--vcl/qt5/Qt5Widget.cxx46
1 files changed, 21 insertions, 25 deletions
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 0ef305f42949..2d3951ad8203 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -127,10 +127,28 @@ void Qt5Widget::resizeEvent(QResizeEvent* pEvent)
m_rFrame.CallCallback(SalEvent::Resize, nullptr);
}
+void Qt5Widget::fillSalAbstractMouseEvent(const Qt5Frame& rFrame, const QInputEvent* pQEvent,
+ const QPoint& rPos, Qt::MouseButtons eButtons, int nWidth,
+ SalAbstractMouseEvent& aSalEvent)
+{
+ const qreal fRatio = rFrame.devicePixelRatioF();
+ const Point aPos = toPoint(rPos * fRatio);
+
+ aSalEvent.mnX = QGuiApplication::isLeftToRight() ? aPos.X() : round(nWidth * fRatio) - aPos.X();
+ aSalEvent.mnY = aPos.Y();
+ aSalEvent.mnTime = pQEvent->timestamp();
+ aSalEvent.mnCode = GetKeyModCode(pQEvent->modifiers()) | GetMouseModCode(eButtons);
+}
+
+#define FILL_SAME(rFrame, nWidth) \
+ fillSalAbstractMouseEvent(rFrame, pEvent, pEvent->pos(), pEvent->buttons(), nWidth, aEvent)
+
void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent,
const ButtonKeyState eState)
{
SalMouseEvent aEvent;
+ FILL_SAME(rFrame, rFrame.GetQWidget()->width());
+
switch (pEvent->button())
{
case Qt::LeftButton:
@@ -146,16 +164,6 @@ void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& rFrame, const QMouseEvent
return;
}
- const qreal fRatio = rFrame.devicePixelRatioF();
- const Point aPos = toPoint(pEvent->pos() * fRatio);
-
- aEvent.mnX = QGuiApplication::isLeftToRight()
- ? aPos.X()
- : round(rFrame.GetQWidget()->width() * fRatio) - aPos.X();
- aEvent.mnY = aPos.Y();
- aEvent.mnTime = pEvent->timestamp();
- aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons());
-
SalEvent nEventType;
if (eState == ButtonKeyState::Pressed)
nEventType = SalEvent::MouseButtonDown;
@@ -173,14 +181,9 @@ void Qt5Widget::mouseReleaseEvent(QMouseEvent* pEvent)
void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent)
{
- const qreal fRatio = m_rFrame.devicePixelRatioF();
- const Point aPos = toPoint(pEvent->pos() * fRatio);
-
SalMouseEvent aEvent;
- aEvent.mnX = QGuiApplication::isLeftToRight() ? aPos.X() : round(width() * fRatio) - aPos.X();
- aEvent.mnY = aPos.Y();
- aEvent.mnTime = pEvent->timestamp();
- aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons());
+ FILL_SAME(m_rFrame, width());
+
aEvent.mnButton = 0;
m_rFrame.CallCallback(SalEvent::MouseMove, &aEvent);
@@ -189,15 +192,8 @@ void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent)
void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
{
- const Point aPos = toPoint(pEvent->pos() * m_rFrame.devicePixelRatioF());
-
SalWheelMouseEvent aEvent;
- aEvent.mnX = QGuiApplication::isLeftToRight()
- ? aPos.X()
- : round(width() * m_rFrame.devicePixelRatioF()) - aPos.X();
- aEvent.mnY = aPos.Y();
- aEvent.mnTime = pEvent->timestamp();
- aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons());
+ FILL_SAME(m_rFrame, width());
// mouse wheel ticks are 120, which we map to 3 lines.
// we have to accumulate for touch scroll to keep track of the absolute delta.