[vlc-commits] [Git][videolan/vlc][master] 4 commits: Revert "qt: do not adjust size in `VideoWindowHandler` with Wayland"

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Aug 17 09:22:29 UTC 2025



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
0fa42cd9 by Fatih Uzunoglu at 2025-08-17T09:09:11+00:00
Revert "qt: do not adjust size in `VideoWindowHandler` with Wayland"

This reverts commit dae15e996aee610d97e35f836f1d6b0f98c1b3d3.

After checking this again, I realized that we need to revert it as
it does the opposite of what we want. Even if DPR is already considered
in `CompositorWayland`, without this revert, the final size end up
being the scaled one (where we want to use the natural size of the
video). It seems that there was something wrong with how I tested it
back then.

- - - - -
2c8838b3 by Fatih Uzunoglu at 2025-08-17T09:09:11+00:00
qml: set object name for `playerSpecializationLoader` in `Player.qml`

- - - - -
59527955 by Fatih Uzunoglu at 2025-08-17T09:09:11+00:00
qt: set root item's parent in `CompositorX11UISurface::setContent()`

We are already setting the visual parent, we might as well set the
object parent. It should be acceptable to take ownership here,
unless I'm missing something. Besides, QQuickView also does this.

I did not remove the manual deletion in the destructor, as I was
worried about the ordering there. With the weak pointer, we should
not have double free here (if somehow the window content item is
destroyed before hence it destroyed its object child root item).

This makes it useful to make use of `QObject` utilities such as
`findChild()`.

- - - - -
a4132ae6 by Fatih Uzunoglu at 2025-08-17T09:09:11+00:00
qt: compensate for non-video area with auto resize when resizing the interface window

When controls are not overlayed (pinned control bar), the embedded video window has
a non-matching, less size than the interface window. With auto resize, although it
is advertised as "interface resizes to video size" and it is working as expected,
the expectation is actually the embedded video area resizing and the control bar
taking additional space. This practically means that when the interface window is
resized, it needs to compensate for the non-video area.

This should make the behavior consistent with VLC 3.0.

- - - - -


4 changed files:

- modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
- modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
- modules/gui/qt/maininterface/video_window_handler.cpp
- modules/gui/qt/player/qml/Player.qml


Changes:

=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
=====================================
@@ -154,6 +154,7 @@ void CompositorX11UISurface::setContent(QQmlComponent*,  QQuickItem* rootItem)
     assert(rootItem);
     m_rootItem = rootItem;
 
+    m_rootItem->setParent(m_uiWindow->contentItem()); // QQuickView also does this
     m_rootItem->setParentItem(m_uiWindow->contentItem());
 
     m_rootItem->setSize(size());


=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
=====================================
@@ -99,7 +99,7 @@ protected:
 private:
     static void applyNvidiaWorkaround(QSurfaceFormat& format);
 
-    QQuickItem* m_rootItem = nullptr;
+    QPointer<QQuickItem> m_rootItem;
     QOpenGLContext *m_context = nullptr;
     QBackingStore *m_backingStore = nullptr;
     QPainter *m_backingStorePainter = nullptr;


=====================================
modules/gui/qt/maininterface/video_window_handler.cpp
=====================================
@@ -22,6 +22,7 @@
 #include <QScreen>
 
 #include <vlc_window.h>
+#include "compositor.hpp"
 
 VideoWindowHandler::VideoWindowHandler(qt_intf_t* intf, QObject *parent)
     : QObject(parent)
@@ -118,13 +119,66 @@ void VideoWindowHandler::setVideoSize(unsigned int w, unsigned int h, Qt::Window
                 w = screen.width();
                 h = screen.height();
             }
-            else if (!m_hasWayland)
+            else
             {
-                // Convert the size in logical pixels
-                w = qRound( (float)w / factor );
-                h = qRound( (float)h / factor );
-                msg_Dbg( m_intf, "Logical video size: %ux%u", w, h );
+                {
+                    // Convert the size in logical pixels
+                    w = qRound( (float)w / factor );
+                    h = qRound( (float)h / factor );
+                    msg_Dbg( m_intf, "Logical video size: %ux%u", w, h );
+                }
+
+                {
+                    // Video window is anchored to the interface window, this is
+                    // expected because video window is "embedded". It is not the
+                    // other way around, where the window would adjust its size
+                    // depending on the size of the video window. However here,
+                    // with auto resize, the size is solely for the video window.
+                    // So, with the current approach, we need to compensate non-
+                    // video area for setting the window size to make the video
+                    // window have the expected size. If in the future we change
+                    // the approach, we can get rid of this workaround and rather
+                    // set the size of video surface item in the Qt Quick scene.
+                    // Currently this is mostly a case with pinned controls in
+                    // the player page, where the controls do not overlay the
+                    // video window/surface.
+
+                    assert(m_intf);
+                    assert(m_intf->p_compositor); // this slot should not be executed otherwise
+                    const auto quickWindow = m_intf->p_compositor->quickWindow();
+                    assert(quickWindow);
+                    const auto contentItem = quickWindow->contentItem();
+                    assert(contentItem);
+
+                    // I initially wanted to probe the QML video surface item, but
+                    // we can not do that because it is not available when this slot
+                    // is executed. In fact, due to late `MainCtx.hasEmbededVideo`
+                    // adjustment, it still remains "false" with a video input and
+                    // player state is in playing state. Worse, `hasVideoOutput`
+                    // is also "false" in the same situation (player reports playing
+                    // state). Relying on a delay there would be fragile, but we can
+                    // simply probe the loader instead, where the video surface item
+                    // is expected to fill it (so has the same size).
+                    if (const auto playerSpecializationLoader = contentItem->findChild<QQuickItem*>(QStringLiteral("playerSpecializationLoader")))
+                    {
+                        // Capture the current sizes to calculate the compensation, we
+                        // can do this because the compensation is not expected to change
+                        // with the change in the window size:
+                        const auto pslSize = playerSpecializationLoader->size().toSize(); // QML items have logical size too
+                        const auto windowSize = m_window->size();
+
+                        const auto dW = (windowSize.width() - pslSize.width());
+                        const auto dH = (windowSize.height() - pslSize.height());
+                        assert(dW >= 0 && dH >= 0); // psl can not be bigger than the window
+
+                        msg_Dbg( m_intf, "Autoresize interface window size compensation: %ix%i", dW, dH );
+
+                        w += dW;
+                        h += dH;
+                    }
+                }
             }
+
             m_window->resize(std::clamp<int>(w, m_window->minimumWidth(), m_window->maximumWidth()),
                              std::clamp<int>(h, m_window->minimumHeight(), m_window->maximumHeight()));
         }


=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -165,6 +165,8 @@ FocusScope {
     Loader {
         id: playerSpecializationLoader
 
+        objectName: "playerSpecializationLoader"
+
         anchors {
             left: parent.left
             right: parent.right



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b7773578b65cdf7665632d180afa01a8c7d4b167...a4132ae65091abe6c9690f5e7e4771a44bc9bcba

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b7773578b65cdf7665632d180afa01a8c7d4b167...a4132ae65091abe6c9690f5e7e4771a44bc9bcba
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