[vlc-commits] [Git][videolan/vlc][master] qml: filter rapid events on position change in seekbar

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon May 6 21:24:37 UTC 2024



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


Commits:
80968175 by Fatih Uzunoglu at 2024-05-06T20:21:42+00:00
qml: filter rapid events on position change in seekbar

Qt has built-in event compression for certain events, such
as window resize. However, this is not the case with mouse
move event. In such cases, filtering needs to be handled
manually.

This approach is already followed in the volume slider.
It is not a good idea to request backend to do an operation
just to override it within the same event loop processing
cycle. Without filtering, CPU utilization increases a lot
and stuttering may be observed.

Volume or player position update must be asked to the
backend at most once per Qt event loop cycle. With
`Qt.callLater()` this can be satisfied.

- - - - -


1 changed file:

- modules/gui/qt/player/qml/SliderBar.qml


Changes:

=====================================
modules/gui/qt/player/qml/SliderBar.qml
=====================================
@@ -243,6 +243,11 @@ T.ProgressBar {
             target: null
             dragThreshold: 0
 
+            function moveControl() {
+                fsm.moveControl(dragHandler.centroid.position.x / control.width,
+                                dragHandler.centroid.modifiers === Qt.ShiftModifier)
+            }
+
             onActiveChanged: {
                 if (active) {
                     fsm.pressControl(centroid.position.x / control.width, centroid.modifiers === Qt.ShiftModifier)
@@ -250,14 +255,10 @@ T.ProgressBar {
                     fsm.releaseControl( centroid.position.x / control.width, centroid.modifiers === Qt.ShiftModifier)
                 }
             }
-        }
-
-        Connections {
-            //FIXME Qt6.5 use xAxis.onActiveValueChanged in the DragHandler
-            target: dragHandler
 
-            function onCentroidChanged() {
-                fsm.moveControl(dragHandler.centroid.position.x / control.width, dragHandler.centroid.modifiers === Qt.ShiftModifier)
+            onCentroidChanged: {
+                // FIXME: Qt 6.5 use xAxis.onActiveValueChanged in the DragHandler
+                Qt.callLater(dragHandler.moveControl)
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/80968175195887d6b0591adb02d47e2e35e1a407

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/80968175195887d6b0591adb02d47e2e35e1a407
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