diff --git a/OpenGlass/GlassFramework.cpp b/OpenGlass/GlassFramework.cpp index d217582..77554a2 100644 --- a/OpenGlass/GlassFramework.cpp +++ b/OpenGlass/GlassFramework.cpp @@ -67,7 +67,8 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCDrawGeometryInstruction_Create(uDwm ); auto color{ g_capturedWindow->GetTitlebarColorizationParameters()->getArgbcolor() }; color.a *= 0.99f; - color.r = g_capturedWindow->TreatAsActiveWindow(); + if (GlassSharedData::g_type == Type::Aero) + color.r = g_capturedWindow->TreatAsActiveWindow(); RETURN_IF_FAILED(solidBrush->Update(1.0, color)); return g_CDrawGeometryInstruction_Create_Org(solidBrush.get(), rgnGeometry.get(), instruction); } @@ -82,13 +83,11 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou { if (!GlassSharedData::IsBackdropAllowed()) { - GlassSharedData::g_LastTopLevelWindow = 0; return g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); } auto data{ This->GetData() }; if (!data) { - GlassSharedData::g_LastTopLevelWindow = 0; return g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); } @@ -126,7 +125,6 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou HRGN borderRegion{ GeometryRecorder::GetRegionFromGeometry(borderGeometry) }; hr = legacyVisualOverride->UpdateNCBackground(captionRegion, borderRegion); - GlassSharedData::g_LastTopLevelWindow = This; } } @@ -134,7 +132,6 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou } else { - GlassSharedData::g_LastTopLevelWindow = 0; VisualManager::RemoveLegacyVisualOverrider(This); hr = g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); } @@ -157,7 +154,6 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateClientBlur(uDw g_capturedWindow = This; GeometryRecorder::BeginCapture(); - GlassSharedData::g_LastTopLevelWindow = 0; HRESULT hr{ g_CTopLevelWindow_UpdateClientBlur_Org(This) }; GeometryRecorder::EndCapture(); g_capturedWindow = nullptr; @@ -252,7 +248,8 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCRenderDataVisual_AddInstruction(uDw } color.a = 0.99f; - color.r = 1.0f; + if (GlassSharedData::g_type == Type::Aero) + color.r = 1.0f; winrt::com_ptr rgnGeometry{ nullptr }; uDwm::ResourceHelper::CreateGeometryFromHRGN(wil::unique_hrgn{ CreateRectRgn(static_cast(rectangle.left), static_cast(rectangle.top), static_cast(rectangle.right), static_cast(rectangle.bottom)) }.get(), rgnGeometry.put()); winrt::com_ptr solidBrush{ nullptr }; @@ -339,10 +336,13 @@ void GlassFramework::UpdateConfiguration(ConfigurationFramework::UpdateType type g_roundRectRadius = static_cast(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"RoundRectRadius")); } + //Seperate keys for now until a way to readd the code that handles setting the actual values in registry is found GlassSharedData::g_ColorizationAfterglowBalance = ((float)ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"OG_ColorizationAfterglowBalance",43) / 100); GlassSharedData::g_ColorizationBlurBalance = ((float)ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"OG_ColorizationBlurBalance",49) / 100); GlassSharedData::g_ColorizationColorBalance = ((float)ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"OG_ColorizationColorBalance",8) / 100); + //Get the colorizationColor from registry directly for aero glass type, a dwm function could be used, however mods or programs such as AWM hook into this and can + //cause issues, so the colour is taken directly from registry, which is fine for aero glass (actually better) since inactive and active have the same colour DWORD hexColour = ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"ColorizationColor", 0xfffcb874); GlassSharedData::g_ColorizationColor = Utils::FromArgb(hexColour); diff --git a/OpenGlass/GlassRenderer.cpp b/OpenGlass/GlassRenderer.cpp index 45683f7..23cbbf7 100644 --- a/OpenGlass/GlassRenderer.cpp +++ b/OpenGlass/GlassRenderer.cpp @@ -71,7 +71,6 @@ namespace OpenGlass::GlassRenderer dwmcore::IDrawingContext* g_drawingContextNoRef{ nullptr }; ID2D1Device* g_deviceNoRef{ nullptr }; - Type g_type{ Type::Blur }; float g_blurAmount{ 9.f }; float g_glassOpacity{ 0.63f }; // exclusively used by aero backdrop @@ -155,8 +154,6 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawSolidRectangle( return g_CDrawingContext_DrawSolidRectangle_Org(This, rectangle, convertedColor); } -bool active = false; - HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawGeometry( dwmcore::IDrawingContext* This, dwmcore::CLegacyMilBrush* brush, @@ -186,9 +183,10 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawGeometry( //g_drawColor.value() = D2D1_COLOR_F{ 116.0f / 255.0f, 184.0f / 255.0f, 252.0f / 255.0f, g_drawColor.value().a}; //g_drawColor.value() = D2D1_COLOR_F{ GlassSharedData::g_ColorizationColor.r, GlassSharedData::g_ColorizationColor.g, GlassSharedData::g_ColorizationColor.b, g_drawColor.value().a}; auto cleanUp{ wil::scope_exit([]{ g_drawColor = std::nullopt; })}; - //D2D1_COLOR_F color{ dwmcore::Convert_D2D1_COLOR_F_scRGB_To_D2D1_COLOR_F_sRGB(g_drawColor.value()) }; - //D2D1_COLOR_F color{ g_drawColor.value()}; + D2D1_COLOR_F color{ GlassSharedData::g_ColorizationColor.r, GlassSharedData::g_ColorizationColor.g, GlassSharedData::g_ColorizationColor.b, g_drawColor.value().a }; + if (GlassSharedData::g_type == Type::Blur) + color = dwmcore::Convert_D2D1_COLOR_F_scRGB_To_D2D1_COLOR_F_sRGB(g_drawColor.value()); dwmcore::CShapePtr geometryShape{}; if ( FAILED(geometry->GetShapeData(nullptr, &geometryShape)) || @@ -272,7 +270,7 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawGeometry( GlassSharedData::g_ColorizationAfterglowBalance, // stays the same bactive ? GlassSharedData::g_ColorizationBlurBalance : 0.4f * GlassSharedData::g_ColorizationBlurBalance + 0.6f, // y = 0.4x + 60 bactive ? GlassSharedData::g_ColorizationColorBalance : 0.4f * GlassSharedData::g_ColorizationColorBalance, //y = 0.4x - g_type + GlassSharedData::g_type ); glassEffect->SetSize( D2D1::SizeF( @@ -338,7 +336,7 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDirtyRegion__Add( lprc.right + extendAmount, lprc.bottom + extendAmount }; - active = unknown; + return g_CDirtyRegion__Add_Org( This, visual, @@ -373,7 +371,7 @@ void GlassRenderer::UpdateConfiguration(ConfigurationFramework::UpdateType type) } g_afterglowBalance = std::clamp(static_cast(afterglowBalance.value()) / 100.f, 0.f, 1.f); - g_type = static_cast(std::clamp(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"GlassType", 0), 0ul, 4ul)); + GlassSharedData::g_type = static_cast(std::clamp(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"GlassType", 0), 0ul, 4ul)); } } diff --git a/OpenGlass/GlassSharedData.hpp b/OpenGlass/GlassSharedData.hpp index 73fde04..e446ce0 100644 --- a/OpenGlass/GlassSharedData.hpp +++ b/OpenGlass/GlassSharedData.hpp @@ -1,10 +1,10 @@ #pragma once #include "framework.hpp" #include "cpprt.hpp" +#include "GlassSharedStructures.hpp" namespace OpenGlass::GlassSharedData { - inline void* g_LastTopLevelWindow = nullptr; inline bool g_disableOnBattery{ true }; inline bool g_overrideAccent{ false }; inline bool g_batteryMode{ false }; @@ -13,6 +13,7 @@ namespace OpenGlass::GlassSharedData inline float g_ColorizationBlurBalance = 0.49f; inline float g_ColorizationColorBalance = 0.08f; inline D2D_COLOR_F g_ColorizationColor{ 116.0f / 255.0f, 184.0f / 255.0f, 252.0f / 255.0f,1.0f }; + inline Type g_type{ Type::Blur }; FORCEINLINE bool IsBackdropAllowed() { diff --git a/OpenGlass/VisualManager.cpp b/OpenGlass/VisualManager.cpp index efb726e..48b491c 100644 --- a/OpenGlass/VisualManager.cpp +++ b/OpenGlass/VisualManager.cpp @@ -2,6 +2,7 @@ #include "GlassFramework.hpp" #include "uDwmProjection.hpp" #include "VisualManager.hpp" +#include "GlassSharedData.hpp" #include "Utils.hpp" using namespace OpenGlass; @@ -175,7 +176,8 @@ HRESULT STDMETHODCALLTYPE VisualManager::CLegacyVisualOverrider::UpdateNCBackgro auto color{ m_window->GetTitlebarColorizationParameters()->getArgbcolor() }; color.a *= 0.99f; - color.r = m_window->TreatAsActiveWindow(); //HACK!!: Send active or inactive window data through the red channel + if (GlassSharedData::g_type == Type::Aero) + color.r = m_window->TreatAsActiveWindow(); //HACK!!: Send active or inactive window data through the red channel RETURN_IF_FAILED(m_brush->Update(1.0, color)); wil::unique_hrgn emptyRegion{ CreateRectRgn(0, 0, 0, 0) };