[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: make sure to preserve window state
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Oct 29 13:38:20 UTC 2023
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
687a2b44 by Prince Gupta at 2023-10-29T13:19:52+00:00
qt: make sure to preserve window state
fixes #28071
- - - - -
16c952f0 by Prince Gupta at 2023-10-29T13:19:52+00:00
qt: remove unused member variable
- - - - -
9 changed files:
- modules/gui/qt/maininterface/compositor.cpp
- modules/gui/qt/maininterface/compositor.hpp
- modules/gui/qt/maininterface/compositor_dcomp.cpp
- modules/gui/qt/maininterface/compositor_win7.cpp
- modules/gui/qt/maininterface/compositor_x11.cpp
- modules/gui/qt/maininterface/interface_window_handler.cpp
- modules/gui/qt/maininterface/interface_window_handler.hpp
- modules/gui/qt/maininterface/mainctx_win32.cpp
- modules/gui/qt/maininterface/mainctx_win32.hpp
Changes:
=====================================
modules/gui/qt/maininterface/compositor.cpp
=====================================
@@ -237,7 +237,7 @@ void CompositorVideo::commonWindowDisable()
}
-bool CompositorVideo::commonGUICreateImpl(QWindow* window, QWidget* rootWidget, CompositorVideo::Flags flags)
+bool CompositorVideo::commonGUICreateImpl(QWindow* window, CompositorVideo::Flags flags)
{
assert(m_mainCtx);
@@ -255,9 +255,9 @@ bool CompositorVideo::commonGUICreateImpl(QWindow* window, QWidget* rootWidget,
m_videoWindowHandler->setWindow( window );
#ifdef _WIN32
- m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandlerWin32>(m_intf, m_mainCtx, window, rootWidget);
+ m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandlerWin32>(m_intf, m_mainCtx, window);
#else
- m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandler>(m_intf, m_mainCtx, window, rootWidget);
+ m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandler>(m_intf, m_mainCtx, window);
#endif
m_mainCtx->setHasAcrylicSurface(flags & CompositorVideo::HAS_ACRYLIC);
m_mainCtx->setWindowSuportExtendedFrame(flags & CompositorVideo::HAS_EXTENDED_FRAME);
@@ -270,9 +270,9 @@ bool CompositorVideo::commonGUICreateImpl(QWindow* window, QWidget* rootWidget,
return true;
}
-bool CompositorVideo::commonGUICreate(QWindow* window, QWidget* rootWidget, QmlUISurface* qmlSurface, CompositorVideo::Flags flags)
+bool CompositorVideo::commonGUICreate(QWindow* window, QmlUISurface* qmlSurface, CompositorVideo::Flags flags)
{
- bool ret = commonGUICreateImpl(window, rootWidget, flags);
+ bool ret = commonGUICreateImpl(window, flags);
if (!ret)
return false;
ret = m_ui->setup(qmlSurface->engine());
@@ -282,9 +282,9 @@ bool CompositorVideo::commonGUICreate(QWindow* window, QWidget* rootWidget, QmlU
return true;
}
-bool CompositorVideo::commonGUICreate(QWindow* window, QWidget* rootWidget, QQuickView* qmlView, CompositorVideo::Flags flags)
+bool CompositorVideo::commonGUICreate(QWindow* window, QQuickView* qmlView, CompositorVideo::Flags flags)
{
- bool ret = commonGUICreateImpl(window, rootWidget, flags);
+ bool ret = commonGUICreateImpl(window, flags);
if (!ret)
return false;
ret = m_ui->setup(qmlView->engine());
=====================================
modules/gui/qt/maininterface/compositor.hpp
=====================================
@@ -126,13 +126,13 @@ protected:
void commonWindowDisable();
protected:
- bool commonGUICreate(QWindow* window, QWidget* rootWidget, QmlUISurface* , CompositorVideo::Flags flags);
- bool commonGUICreate(QWindow* window, QWidget* rootWidget, QQuickView* , CompositorVideo::Flags flags);
+ bool commonGUICreate(QWindow* window, QmlUISurface* , CompositorVideo::Flags flags);
+ bool commonGUICreate(QWindow* window, QQuickView* , CompositorVideo::Flags flags);
void commonGUIDestroy();
void commonIntfDestroy();
private:
- bool commonGUICreateImpl(QWindow* window, QWidget* rootWidget, CompositorVideo::Flags flags);
+ bool commonGUICreateImpl(QWindow* window, CompositorVideo::Flags flags);
protected slots:
virtual void onSurfacePositionChanged(const QPointF&) {}
=====================================
modules/gui/qt/maininterface/compositor_dcomp.cpp
=====================================
@@ -271,7 +271,7 @@ bool CompositorDirectComposition::makeMainInterface(MainCtx* mainCtx)
if (!ret)
return false;
- ret = commonGUICreate(m_rootWindow, nullptr, m_uiSurface.get(), CompositorVideo::CAN_SHOW_PIP);
+ ret = commonGUICreate(m_rootWindow, m_uiSurface.get(), CompositorVideo::CAN_SHOW_PIP);
if (!ret)
return false;
=====================================
modules/gui/qt/maininterface/compositor_win7.cpp
=====================================
@@ -145,7 +145,7 @@ bool CompositorWin7::makeMainInterface(MainCtx* mainCtx)
m_qmlWindowHWND = (HWND)m_qmlView->winId();
- commonGUICreate(m_qmlView.get(), nullptr, m_qmlView.get(), CompositorVideo::CAN_SHOW_PIP);
+ commonGUICreate(m_qmlView.get(), m_qmlView.get(), CompositorVideo::CAN_SHOW_PIP);
return true;
}
=====================================
modules/gui/qt/maininterface/compositor_x11.cpp
=====================================
@@ -196,7 +196,7 @@ bool CompositorX11::makeMainInterface(MainCtx* mainCtx)
flags |= CompositorVideo::HAS_ACRYLIC;
if (m_renderWindow->supportExtendedFrame())
flags |= CompositorVideo::HAS_EXTENDED_FRAME;
- commonGUICreate(m_renderWindow.get(), nullptr, m_qmlView.get(), flags);
+ commonGUICreate(m_renderWindow.get(), m_qmlView.get(), flags);
m_renderWindow->setInterfaceWindow(m_qmlView.get());
m_renderWindow->setVideoWindow(m_videoWidget->windowHandle());
=====================================
modules/gui/qt/maininterface/interface_window_handler.cpp
=====================================
@@ -25,12 +25,26 @@
#include <QQmlProperty>
#include <cmath>
+namespace
+{
+
+void setWindowState(QWindow *window, Qt::WindowState state)
+{
+ // make sure to preserve original state, Qt saves this info
+ // in underlying platform window but we need this in top level
+ // so that our window handling code works.
+ // see issue #28071
+ const auto original = window->windowStates();
+ window->setWindowStates(original | state);
+}
+
+}
+
-InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QWidget* widget, QObject *parent)
+InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QObject *parent)
: QObject(parent)
, p_intf(_p_intf)
, m_window(window)
- , m_widget(widget)
, m_mainCtx(mainCtx)
{
assert(m_window);
@@ -133,18 +147,9 @@ InterfaceWindowHandler::~InterfaceWindowHandler()
#if QT_CLIENT_SIDE_DECORATION_AVAILABLE
void InterfaceWindowHandler::updateCSDWindowSettings()
{
- if (m_widget)
- {
- m_widget->hide(); // some window managers don't like to change frame window hint on visible window
- m_widget->setWindowFlag(Qt::FramelessWindowHint, m_mainCtx->useClientSideDecoration());
- m_widget->show();
- }
- else
- {
- m_window->hide(); // some window managers don't like to change frame window hint on visible window
- m_window->setFlag(Qt::FramelessWindowHint, m_mainCtx->useClientSideDecoration());
- m_window->show();
- }
+ m_window->hide(); // some window managers don't like to change frame window hint on visible window
+ m_window->setFlag(Qt::FramelessWindowHint, m_mainCtx->useClientSideDecoration());
+ m_window->show();
}
#endif
@@ -324,10 +329,7 @@ void InterfaceWindowHandler::setInterfaceFullScreen( bool fs )
void InterfaceWindowHandler::setRaise()
{
requestActivate();
- if (m_widget)
- m_widget->raise();
- else
- m_window->raise();
+ m_window->raise();
}
void InterfaceWindowHandler::setBoss()
@@ -345,51 +347,33 @@ void InterfaceWindowHandler::setBoss()
void InterfaceWindowHandler::setInterfaceHiden()
{
- if (m_widget)
- m_widget->hide();
- else
- m_window->hide();
+ m_window->hide();
}
void InterfaceWindowHandler::setInterfaceShown()
{
- if (m_widget)
- m_widget->show();
- else
- m_window->show();
+ m_window->show();
}
void InterfaceWindowHandler::setInterfaceMinimized()
{
- if (m_widget)
- m_widget->showMinimized();
- else
- m_window->showMinimized();
+ setWindowState(m_window, Qt::WindowMinimized);
}
void InterfaceWindowHandler::setInterfaceMaximized()
{
- if (m_widget)
- m_widget->showMaximized();
- else
- m_window->showMaximized();
+ setWindowState(m_window, Qt::WindowMaximized);
}
void InterfaceWindowHandler::setInterfaceNormal()
{
- if (m_widget)
- m_widget->showNormal();
- else
- m_window->showNormal();
+ m_window->showNormal();
}
void InterfaceWindowHandler::requestActivate()
{
- if (m_widget)
- m_widget->activateWindow();
- else
- m_window->requestActivate();
+ m_window->requestActivate();
}
void InterfaceWindowHandler::setInterfaceAlwaysOnTop( bool on_top )
=====================================
modules/gui/qt/maininterface/interface_window_handler.hpp
=====================================
@@ -28,7 +28,7 @@ class InterfaceWindowHandler : public QObject
{
Q_OBJECT
public:
- explicit InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QWidget* widget, QObject *parent = nullptr);
+ explicit InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QObject *parent = nullptr);
virtual ~InterfaceWindowHandler();
public slots:
@@ -69,10 +69,7 @@ private:
protected:
qt_intf_t* p_intf = nullptr;
- //some compositor uses a Window as the base interface, some uses a widget
- //when a widget is used, perform window operation on it
QWindow* m_window = nullptr;
- QWidget* m_widget = nullptr;
MainCtx* m_mainCtx = nullptr;
=====================================
modules/gui/qt/maininterface/mainctx_win32.cpp
=====================================
@@ -792,8 +792,8 @@ void MainCtxWin32::reloadPrefs()
// InterfaceWindowHandlerWin32
-InterfaceWindowHandlerWin32::InterfaceWindowHandlerWin32(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QWidget* widget, QObject *parent)
- : InterfaceWindowHandler(_p_intf, mainCtx, window, widget, parent)
+InterfaceWindowHandlerWin32::InterfaceWindowHandlerWin32(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QObject *parent)
+ : InterfaceWindowHandler(_p_intf, mainCtx, window, parent)
#if QT_CLIENT_SIDE_DECORATION_AVAILABLE
, m_CSDWindowEventHandler(new CSDWin32EventHandler(mainCtx, window, window))
=====================================
modules/gui/qt/maininterface/mainctx_win32.hpp
=====================================
@@ -70,7 +70,7 @@ class InterfaceWindowHandlerWin32 : public InterfaceWindowHandler, public QAbstr
{
Q_OBJECT
public:
- explicit InterfaceWindowHandlerWin32(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QWidget* widget, QObject *parent = nullptr);
+ explicit InterfaceWindowHandlerWin32(qt_intf_t *_p_intf, MainCtx* mainCtx, QWindow* window, QObject *parent = nullptr);
virtual ~InterfaceWindowHandlerWin32();
virtual void toggleWindowVisibility() override;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8403c838aab4a0f90c2f2fcd9072af84e0d6194b...16c952f0df0b52e827ae9d8c94e934430859e0c0
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8403c838aab4a0f90c2f2fcd9072af84e0d6194b...16c952f0df0b52e827ae9d8c94e934430859e0c0
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