[vlc-commits] [Git][videolan/vlc][master] qt: fix video mouse position report when the device pixel ratio is not 1.0

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Dec 28 17:39:50 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
9f41c71b by Pierre Lamot at 2022-12-28T17:16:35+00:00
qt: fix video mouse position report when the device pixel ratio is not 1.0

Mouse events are reported in Qt's coordinates and needs to be scaled. This is
analogous to the way we are scaling the video size report event.

fix: #27674

- - - - -


1 changed file:

- modules/gui/qt/maininterface/videosurface.cpp


Changes:

=====================================
modules/gui/qt/maininterface/videosurface.cpp
=====================================
@@ -267,7 +267,11 @@ void VideoSurface::mouseReleaseEvent(QMouseEvent* event)
 void VideoSurface::mouseMoveEvent(QMouseEvent* event)
 {
     QPointF current_pos = event->localPos();
-    emit mouseMoved(current_pos.x() , current_pos.y());
+    QQuickWindow* window = this->window();
+    if (!window)
+        return;
+    qreal dpr = window->effectiveDevicePixelRatio();
+    emit mouseMoved(current_pos.x() * dpr, current_pos.y() * dpr);
     event->accept();
 }
 
@@ -276,7 +280,11 @@ void VideoSurface::hoverMoveEvent(QHoverEvent* event)
     QPointF current_pos = event->posF();
     if (current_pos != m_oldHoverPos)
     {
-        emit mouseMoved(current_pos.x(), current_pos.y());
+        QQuickWindow* window = this->window();
+        if (!window)
+            return;
+        qreal dpr = window->effectiveDevicePixelRatio();
+        emit mouseMoved(current_pos.x() * dpr, current_pos.y()  * dpr);
         m_oldHoverPos = current_pos;
     }
     event->accept();
@@ -379,7 +387,7 @@ void VideoSurface::onSurfacePositionChanged()
     QQuickWindow* window = this->window();
     if (!window)
         return;
-    qreal dpr = this->window()->effectiveDevicePixelRatio();
+    qreal dpr = window->effectiveDevicePixelRatio();
     emit surfacePositionChanged(scenePosition * dpr);
 }
 
@@ -391,7 +399,7 @@ void VideoSurface::updatePositionAndSize()
     QQuickWindow* window = this->window();
     if (!window)
         return;
-    qreal dpr = this->window()->effectiveDevicePixelRatio();
+    qreal dpr = window->effectiveDevicePixelRatio();
     emit surfaceSizeChanged(size() * dpr);
     QPointF scenePosition = this->mapToScene(QPointF(0, 0));
     emit surfacePositionChanged(scenePosition * dpr);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9f41c71b5054263134632786bb88e1cb1199c232

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9f41c71b5054263134632786bb88e1cb1199c232
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list