[vlc-commits] [Git][videolan/vlc][master] qt: follow system settings for acrylic effect (windows)

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Sep 17 17:04:29 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
ed47ae16 by Prince Gupta at 2021-09-17T16:51:42+00:00
qt: follow system settings for acrylic effect (windows)

- - - - -


2 changed files:

- modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.cpp
- modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.hpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.cpp
=====================================
@@ -30,6 +30,15 @@
 namespace
 {
 
+bool isTransparencyEnabled()
+{
+    static const char *TRANSPARENCY_SETTING_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
+    static const char *TRANSPARENCY_SETTING_KEY = "EnableTransparency";
+
+    QSettings settings(QLatin1String {TRANSPARENCY_SETTING_PATH}, QSettings::NativeFormat);
+    return settings.value(TRANSPARENCY_SETTING_KEY).toBool();
+}
+
 template <typename F>
 F loadFunction(QLibrary &library, const char *symbol)
 {
@@ -80,7 +89,7 @@ CompositorDCompositionAcrylicSurface::CompositorDCompositionAcrylicSurface(qt_in
     }
 
     if (auto w = window())
-        setActive(w->isActive());
+        setActive(m_transparencyEnabled && w->isActive());
 
     qApp->installNativeEventFilter(this);
 }
@@ -104,6 +113,9 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e
     {
     case WM_WINDOWPOSCHANGED:
     {
+        if (!m_active)
+            break;
+
         sync();
         commitChanges();
 
@@ -112,12 +124,28 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e
     }
     case WM_ACTIVATE:
     {
+        if (!m_transparencyEnabled)
+            break;
+
         const int activeType = LOWORD(msg->wParam);
         if ((activeType == WA_ACTIVE) || (activeType == WA_CLICKACTIVE))
             setActive(true);
         else if (activeType == WA_INACTIVE)
             setActive(false);
-
+        break;
+    }
+    case WM_SETTINGCHANGE:
+    {
+        if (!lstrcmpW(LPCWSTR(msg->lParam), L"ImmersiveColorSet"))
+        {
+            const auto transparencyEnabled = isTransparencyEnabled();
+            if (m_transparencyEnabled == transparencyEnabled)
+                break;
+
+            m_transparencyEnabled = transparencyEnabled;
+            if (const auto w = window())
+                setActive(m_transparencyEnabled && w->isActive());
+        }
         break;
     }
     }
@@ -140,6 +168,8 @@ bool CompositorDCompositionAcrylicSurface::init(ID3D11Device *device)
     if (!createBackHostVisual())
         return false;
 
+    m_transparencyEnabled = isTransparencyEnabled();
+
     m_leftMostScreenX = 0;
     m_topMostScreenY = 0;
     for (const auto screen : qGuiApp->screens())


=====================================
modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.hpp
=====================================
@@ -224,6 +224,7 @@ private:
     QBasicTimer m_resetTimer;
     bool m_resetPending = false;
     bool m_active = false;
+    bool m_transparencyEnabled = false;
     int m_leftMostScreenX = 0;
     int m_topMostScreenY = 0;
 };



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ed47ae165c5813ad59bb77e09d7782296f4b9ff3

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ed47ae165c5813ad59bb77e09d7782296f4b9ff3
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list