[vlc-commits] qt: allow changing csd setting at runtime

Prince Gupta git at videolan.org
Mon Mar 1 10:40:10 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Tue Feb 23 15:53:55 2021 +0530| [1d773e996840b04e4cd348ffe22edea0fc9516ae] | committer: Pierre Lamot

qt: allow changing csd setting at runtime

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d773e996840b04e4cd348ffe22edea0fc9516ae
---

 modules/gui/qt/maininterface/main_interface.cpp       | 16 ++++++++++++++++
 modules/gui/qt/maininterface/main_interface.hpp       |  1 +
 modules/gui/qt/maininterface/main_interface_win32.cpp |  9 +++++++++
 modules/gui/qt/maininterface/main_interface_win32.hpp |  2 ++
 4 files changed, 28 insertions(+)

diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 66cea66e04..8a45c785af 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -299,6 +299,15 @@ void MainInterface::reloadPrefs()
         m_hasToolbarMenu = !m_hasToolbarMenu;
         emit hasToolbarMenuChanged();
     }
+
+#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
+    if (m_clientSideDecoration != (! var_InheritBool( p_intf, "qt-titlebar" )))
+    {
+        m_clientSideDecoration = !m_clientSideDecoration;
+        emit useClientSideDecorationChanged();
+        updateClientSideDecorations();
+    }
+#endif
 }
 
 
@@ -692,6 +701,13 @@ void MainInterface::closeEvent( QCloseEvent *e )
     }
 }
 
+void MainInterface::updateClientSideDecorations()
+{
+    hide(); // some window managers don't like to change frame window hint on visible window
+    setWindowFlag(Qt::FramelessWindowHint, useClientSideDecoration());
+    show();
+}
+
 void MainInterface::setInterfaceFullScreen( bool fs )
 {
     b_interfaceFullScreen = fs;
diff --git a/modules/gui/qt/maininterface/main_interface.hpp b/modules/gui/qt/maininterface/main_interface.hpp
index 289753b769..5b480c7944 100644
--- a/modules/gui/qt/maininterface/main_interface.hpp
+++ b/modules/gui/qt/maininterface/main_interface.hpp
@@ -215,6 +215,7 @@ protected:
     void dragMoveEvent( QDragMoveEvent * ) Q_DECL_OVERRIDE;
     void dragLeaveEvent( QDragLeaveEvent * ) Q_DECL_OVERRIDE;
     void closeEvent( QCloseEvent *) Q_DECL_OVERRIDE;
+    virtual void updateClientSideDecorations();
 
 protected:
     /* Systray */
diff --git a/modules/gui/qt/maininterface/main_interface_win32.cpp b/modules/gui/qt/maininterface/main_interface_win32.cpp
index edfe98243d..b88bf03e4d 100644
--- a/modules/gui/qt/maininterface/main_interface_win32.cpp
+++ b/modules/gui/qt/maininterface/main_interface_win32.cpp
@@ -434,6 +434,15 @@ void MainInterfaceWin32::reloadPrefs()
     MainInterface::reloadPrefs();
 }
 
+void MainInterfaceWin32::updateClientSideDecorations()
+{
+    HWND winId = WinId(windowHandle());
+    SetWindowPos(winId, NULL, 0, 0, 0, 0,
+        SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS |
+        SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREPOSITION |
+        SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER);
+}
+
 
 void InterfaceWindowHandlerWin32::toggleWindowVisiblity()
 {
diff --git a/modules/gui/qt/maininterface/main_interface_win32.hpp b/modules/gui/qt/maininterface/main_interface_win32.hpp
index 422905ca52..3a5b4e4798 100644
--- a/modules/gui/qt/maininterface/main_interface_win32.hpp
+++ b/modules/gui/qt/maininterface/main_interface_win32.hpp
@@ -68,6 +68,8 @@ private:
 public slots:
     virtual void reloadPrefs() override;
 
+protected:
+    void updateClientSideDecorations() Q_DECL_OVERRIDE;
 };
 
 class InterfaceWindowHandlerWin32 : public InterfaceWindowHandler



More information about the vlc-commits mailing list