[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: check for frameless window hint when probing Win11 22H2 window backdrop effect

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Nov 19 06:52:25 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6e136d23 by Fatih Uzunoglu at 2024-11-19T06:04:24+00:00
qt: check for frameless window hint when probing Win11 22H2 window backdrop effect

Backdrop effect needs the interface window to be translucent, as we want the DWM
composited backdrop effect to pass through.

It is additionally required to use `Qt::FramelessWindowHint` for transparent
windows on Windows, otherwise artifacts may occur. Since this flag is explicitly
not used on Windows unlike other platforms, this change effectively means that
the native effect is not going to be used.

It is not clear why `Qt::FramelessWindowHint` is not used on Windows when CSD
is in use, because it is the canonical way of making a QWindow frameless.

- - - - -
db55a149 by Fatih Uzunoglu at 2024-11-19T06:04:24+00:00
qt: restore interface window geometry before it is shown

... so that the interface window does not change its size
from the default size the platform window determines to
use.

Currently, the interface window gets resized immediately
after it is shown. This does not make any sense, the
target size should be set before for the window so that
the window is shown appropriately when it becomes visible.

- - - - -


5 changed files:

- modules/gui/qt/maininterface/compositor.cpp
- modules/gui/qt/maininterface/interface_window_handler.cpp
- modules/gui/qt/maininterface/kwindowsystem_module.cpp
- modules/gui/qt/maininterface/win32windoweffects_module.cpp
- modules/gui/qt/maininterface/windoweffects_module.hpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor.cpp
=====================================
@@ -381,7 +381,7 @@ bool CompositorVideo::setBlurBehind(QWindow *window, const bool enable)
         }
     }
 
-    if (!m_windowEffectsModule->isEffectAvailable(WindowEffectsModule::BlurBehind))
+    if (!m_windowEffectsModule->isEffectAvailable(window, WindowEffectsModule::BlurBehind))
         return false;
 
     m_windowEffectsModule->setBlurBehind(window, enable);


=====================================
modules/gui/qt/maininterface/interface_window_handler.cpp
=====================================
@@ -58,12 +58,12 @@ InterfaceWindowHandler::InterfaceWindowHandler(qt_intf_t *_p_intf, MainCtx* main
     m_window->setIcon( QApplication::windowIcon() );
     m_window->setOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
 
+    QVLCTools::restoreWindowPosition( getSettings(), m_window, QSize(600, 420) );
+
     // this needs to be called asynchronously
     // otherwise QQuickWidget won't initialize properly
     QMetaObject::invokeMethod(this, [this]()
     {
-        QVLCTools::restoreWindowPosition( getSettings(), m_window, QSize(600, 420) );
-
         WindowStateHolder::holdOnTop( m_window,  WindowStateHolder::INTERFACE, m_mainCtx->isInterfaceAlwaysOnTop() );
         WindowStateHolder::holdFullscreen( m_window,  WindowStateHolder::INTERFACE, m_window->visibility() == QWindow::FullScreen );
 


=====================================
modules/gui/qt/maininterface/kwindowsystem_module.cpp
=====================================
@@ -23,7 +23,7 @@
 
 #include <KWindowEffects>
 
-static bool isEffectAvailable(const WindowEffectsModule::Effect effect)
+static bool isEffectAvailable(const QWindow*, const WindowEffectsModule::Effect effect)
 {
     KWindowEffects::Effect kWindowEffect;
 
@@ -54,7 +54,7 @@ static int Open(vlc_object_t* const p_this)
     // In that case, simply fail here,
     // so that another potentially compatible
     // module can be loaded instead:
-    if (!isEffectAvailable(WindowEffectsModule::BlurBehind))
+    if (!isEffectAvailable(nullptr, WindowEffectsModule::BlurBehind))
         return VLC_EGENERIC;
 
     const auto obj = reinterpret_cast<WindowEffectsModule*>(p_this);


=====================================
modules/gui/qt/maininterface/win32windoweffects_module.cpp
=====================================
@@ -25,12 +25,34 @@
 
 #include <dwmapi.h>
 
-static bool isEffectAvailable(const WindowEffectsModule::Effect effect)
+static bool isEffectAvailable(const QWindow* window, const WindowEffectsModule::Effect effect)
 {
     // Version check is done on module open, no need to re-do it here.
     switch (effect)
     {
     case WindowEffectsModule::BlurBehind:
+        // NOTE: Qt does not officially support translucent window with frame.
+        //       The documentation states that `Qt::FramelessWindowHint` is
+        //       required on certain platforms, such as Windows. Otherwise,
+        //       The window starts with a white background, which is a widely
+        //       known Windows issue regardless of translucency, but the white
+        //       background is never cleared if the window clear color is
+        //       translucent. In this case, minimizing and restoring the window
+        //       makes the background cleared, but this still does not make
+        //       it a portable solution.
+        // NOTE: See QTBUG-56201, QTBUG-120691. From the reports, it appears
+        //       that Nvidia graphics is "fine" with translucent framed window
+        //       while Intel graphics is not. However, the said issue above
+        //       is still a concern with Nvidia graphics according to my own
+        //       experience.
+        // TODO: Ideally, we should at least use the frameless window hint
+        //       when CSD is in use and use native backdrop effect since
+        //       the custom solution has more chance to cause issues.
+        if (!window->flags().testFlag(Qt::FramelessWindowHint))
+        {
+            qDebug("Target window is not frameless, window can not be translucent for the Windows 11 22H2 native acrylic backdrop effect.");
+            return false;
+        }
         return true;
     default:
         return false;


=====================================
modules/gui/qt/maininterface/windoweffects_module.hpp
=====================================
@@ -33,7 +33,7 @@ struct WindowEffectsModule
     module_t *p_module = nullptr;
     void *p_sys = nullptr;
 
-    bool (*isEffectAvailable)(Effect effect);
+    bool (*isEffectAvailable)(const QWindow* window, Effect effect);
     void (*setBlurBehind)(QWindow* window, bool enable);
 };
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/96b74dc60449c5766c05ebb573cae4df61b545ca...db55a1497b606078fa7d160ad1a4f16d14199a9b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/96b74dc60449c5766c05ebb573cae4df61b545ca...db55a1497b606078fa7d160ad1a4f16d14199a9b
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