[vlc-commits] [Git][videolan/vlc][master] qt: wayland: respect subsurface position when re-mapping

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Oct 6 09:00:31 UTC 2026



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


Commits:
9bae6f79 by Fatih Uzunoglu at 2026-10-06T10:44:25+02:00
qt: wayland: respect subsurface position when re-mapping

I realized that when the video window is disabled and then
enabled, the old position is no longer respected. This is
not aligned with how the other compositors behave, and also
against our expectation.

Sadly Wayland does not have visual trees the same way Direct
Composition does, so we can not simply unmap a surface by
removing the surface from the visual tree as we are doing
with Direct Composition, and the only way of unmapping seems
to be one of these:

- Attach a null buffer, but this is not applicable since the
buffer is in the jurisdiction of the display module.
- Destroy the subsurface role.

Currently we are destroying the subsurface here, but that
also means that the position is lost. Not only that, we are
also not respecting move requests if the video window is not
enabled, which is also not the behavior of other compositors.

In this patch, it is proposed to store the position so that
when the window is mapped (window enable is called), the
stored position can be respected.

This also helps preventing calling `wl_subsurface_set_position()`
again if the new position is the same, as well as not requesting
surface commit.

This fixes the video window getting misplaced in the interface
when the video window is disabled and (re)-enabled.

- - - - -


1 changed file:

- modules/gui/qt/maininterface/compositor_wayland_module.c


Changes:

=====================================
modules/gui/qt/maininterface/compositor_wayland_module.c
=====================================
@@ -59,6 +59,17 @@ typedef struct
     int width;
     int height;
 
+    // Store the position, because we need
+    // to respect the old position when the
+    // video window gets re-enabled. We do
+    // not need to store the scale or size
+    // for this purpose, because the surface
+    // itself remains when the window gets
+    // disabled, only the subsurface role
+    // is destroyed.
+    int x;
+    int y;
+
     uint32_t compositor_interface_version;
 } qtwayland_priv_t;
 
@@ -297,6 +308,10 @@ static void Enable(qtwayland_t* obj, const vlc_window_cfg_t * conf)
     sys->video_subsurface = wl_subcompositor_get_subsurface(sys->subcompositor, sys->video_surface, sys->interface_surface);
     wl_subsurface_place_below(sys->video_subsurface, sys->interface_surface);
     wl_subsurface_set_desync(sys->video_subsurface);
+
+    if ((sys->x >= 0) && (sys->y >= 0))
+        wl_subsurface_set_position(sys->video_subsurface, sys->x, sys->y);
+
     CommitSurface(obj);
 }
 
@@ -314,10 +329,22 @@ static void Move(struct qtwayland_t* obj, int x, int y, bool commitSurface)
 {
     qtwayland_priv_t* sys = (qtwayland_priv_t*)obj->p_sys;
     if(sys->video_subsurface == NULL)
+    {
+        // `Enable()` is going to respect this:
+        sys->x = x;
+        sys->y = y;
         return;
-    wl_subsurface_set_position(sys->video_subsurface, x, y);
-    if (commitSurface)
-        CommitSurface(obj);
+    }
+
+    if ((sys->x != x) || (sys->y != y))
+    {
+        wl_subsurface_set_position(sys->video_subsurface, x, y);
+        sys->x = x;
+        sys->y = y;
+
+        if (commitSurface)
+            CommitSurface(obj);
+    }
 }
 
 static void Resize(struct qtwayland_t* obj, size_t width, size_t height, bool commitSurface)
@@ -463,6 +490,8 @@ int OpenCompositor(vlc_object_t* p_this)
     if (!sys)
         return VLC_ENOMEM;
 
+    sys->x = -1;
+    sys->y = -1;
 
     //module functions
     obj->init = Init;



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9bae6f79c8662b389e446ff695acf48bd49dd7c9
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list