[vlc-devel] [PATCH 05/16] qt: allow changing csd setting at runtime
Prince Gupta
guptaprince8832 at gmail.com
Tue Feb 23 10:05:55 UTC 2021
---
modules/gui/qt/maininterface/main_interface.cpp | 16 ++++++++++++++++
modules/gui/qt/maininterface/main_interface.hpp | 1 +
.../qt/maininterface/main_interface_win32.cpp | 9 +++++++++
.../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 28e8c9ade2..1475282486 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -303,6 +303,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
}
@@ -696,6 +705,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
--
2.25.1
More information about the vlc-devel
mailing list