Skip to content
Snippets Groups Projects
Commit ed47ae16 authored by Prince Gupta's avatar Prince Gupta :speech_balloon: Committed by Hugo Beauzée-Luyssen
Browse files

qt: follow system settings for acrylic effect (windows)

parent 0d48be63
No related branches found
No related tags found
1 merge request!623qt: follow system settings for acrylic effect (windows)
Pipeline #139156 passed with stages
in 29 minutes and 10 seconds
...@@ -30,6 +30,15 @@ ...@@ -30,6 +30,15 @@
namespace 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> template <typename F>
F loadFunction(QLibrary &library, const char *symbol) F loadFunction(QLibrary &library, const char *symbol)
{ {
...@@ -80,7 +89,7 @@ CompositorDCompositionAcrylicSurface::CompositorDCompositionAcrylicSurface(qt_in ...@@ -80,7 +89,7 @@ CompositorDCompositionAcrylicSurface::CompositorDCompositionAcrylicSurface(qt_in
} }
if (auto w = window()) if (auto w = window())
setActive(w->isActive()); setActive(m_transparencyEnabled && w->isActive());
qApp->installNativeEventFilter(this); qApp->installNativeEventFilter(this);
} }
...@@ -104,6 +113,9 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e ...@@ -104,6 +113,9 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e
{ {
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
{ {
if (!m_active)
break;
sync(); sync();
commitChanges(); commitChanges();
...@@ -112,12 +124,28 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e ...@@ -112,12 +124,28 @@ bool CompositorDCompositionAcrylicSurface::nativeEventFilter(const QByteArray &e
} }
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
if (!m_transparencyEnabled)
break;
const int activeType = LOWORD(msg->wParam); const int activeType = LOWORD(msg->wParam);
if ((activeType == WA_ACTIVE) || (activeType == WA_CLICKACTIVE)) if ((activeType == WA_ACTIVE) || (activeType == WA_CLICKACTIVE))
setActive(true); setActive(true);
else if (activeType == WA_INACTIVE) else if (activeType == WA_INACTIVE)
setActive(false); 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; break;
} }
} }
...@@ -140,6 +168,8 @@ bool CompositorDCompositionAcrylicSurface::init(ID3D11Device *device) ...@@ -140,6 +168,8 @@ bool CompositorDCompositionAcrylicSurface::init(ID3D11Device *device)
if (!createBackHostVisual()) if (!createBackHostVisual())
return false; return false;
m_transparencyEnabled = isTransparencyEnabled();
m_leftMostScreenX = 0; m_leftMostScreenX = 0;
m_topMostScreenY = 0; m_topMostScreenY = 0;
for (const auto screen : qGuiApp->screens()) for (const auto screen : qGuiApp->screens())
......
...@@ -224,6 +224,7 @@ private: ...@@ -224,6 +224,7 @@ private:
QBasicTimer m_resetTimer; QBasicTimer m_resetTimer;
bool m_resetPending = false; bool m_resetPending = false;
bool m_active = false; bool m_active = false;
bool m_transparencyEnabled = false;
int m_leftMostScreenX = 0; int m_leftMostScreenX = 0;
int m_topMostScreenY = 0; int m_topMostScreenY = 0;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment