[vlc-devel] [3.0 PATCH 2/2] qt: reparent video window to root whence UI closes

remi at remlab.net remi at remlab.net
Fri Feb 5 17:58:15 UTC 2021


From: RĂ©mi Denis-Courmont <remi at remlab.net>

The video window has to exist until it is closed by its owner, i.e.
WindowClose() is called. If it stayed as a child of the main UI window,
it would be destroyed with the main UI window.

This reparents it (back) to the root window before the main UI window
gets destroyed. This works around #21875.
---
 modules/gui/qt/components/interface_widgets.cpp |  2 ++
 modules/gui/qt/main_interface.cpp               |  2 ++
 modules/gui/qt/qt.cpp                           | 13 +++++++++++++
 3 files changed, 17 insertions(+)

diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index 74e82eab58..ff44bf2e44 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -229,6 +229,7 @@ QSize VideoWidget::physicalSize() const
 }
 
 void WindowResized(vout_window_t *, const QSize&);
+void WindowReleased(vout_window_t *);
 
 void VideoWidget::reportSize()
 {
@@ -378,6 +379,7 @@ void VideoWidget::release( void )
 
     if( stable )
     {
+        WindowReleased(p_window);
         layout->removeWidget( stable );
         stable->deleteLater();
         stable = NULL;
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 259dcf7109..a57506533d 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -1664,6 +1664,8 @@ void MainInterface::closeEvent( QCloseEvent *e )
 //  hide();
     if ( b_minimalView )
         setMinimalView( false );
+    if( videoWidget )
+        releaseVideoSlot();
     emit askToQuit(); /* ask THEDP to quit, so we have a unique method */
     /* Accept session quit. Otherwise we break the desktop mamager. */
     e->accept();
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 6e7056b10b..06888da05d 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -813,6 +813,19 @@ static int WindowControl( vout_window_t *p_wnd, int i_query, va_list args )
     return p_mi->controlVideo( i_query, args );
 }
 
+void WindowReleased(vout_window_t *wnd)
+{
+#if defined (QT5_HAS_X11)
+    if (QX11Info::isPlatformX11())
+    {
+        msg_Warn(wnd, "orphaned video window");
+        XReparentWindow(dpy, wnd->handle.xid,
+                        RootWindow(dpy, DefaultScreen(dpy)), 0, 0);
+        XSync(dpy, True);
+    }
+#endif
+}
+
 static void WindowClose( vout_window_t *p_wnd )
 {
     MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-- 
2.30.0



More information about the vlc-devel mailing list