Skip to content

Commit 506815a

Browse files
committed
merge
1 parent f297388 commit 506815a

11 files changed

Lines changed: 25 additions & 236 deletions

File tree

Common/Common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,9 @@ namespace MDWMBlurGlass
5959

6060
bool disableFramerateLimit = false;
6161

62-
bool occlusionCulling = false;
63-
6462
//Options without GUI
6563
int extendRound = 10;
6664
int titlebtnOffsetX = -1;
67-
int cullingLevel = 0;
6865
//
6966

7067
float blurAmount = 20.f;

DWMBlurGlass/Helper/Helper.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,14 @@ namespace MDWMBlurGlass
8787
return str;
8888
}
8989

90-
std::pair<std::wstring, std::wstring> GetSystemLocaleAndParent()
90+
std::wstring GetSystemLocalName()
9191
{
9292
WCHAR langName[LOCALE_NAME_MAX_LENGTH];
93-
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, langName, LOCALE_NAME_MAX_LENGTH))
93+
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, langName, LOCALE_NAME_MAX_LENGTH))
9494
{
95-
std::wstring locale = langName;
96-
auto pos = locale.find(L'-');
97-
if (pos != std::wstring::npos)
98-
{
99-
return { locale, std::wstring(locale.substr(0, pos)) };
100-
}
101-
return { locale, locale };
95+
return langName;
10296
}
103-
return { L"en-US", L"en" };
97+
return L"en-US";
10498
}
10599

106100
std::wstring hrToStr(HRESULT hr)

DWMBlurGlass/Helper/Helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace MDWMBlurGlass
2626

2727
extern std::wstring ReadFileSting(std::wstring_view filePath);
2828

29-
std::pair<std::wstring, std::wstring> GetSystemLocaleAndParent();
29+
extern std::wstring GetSystemLocalName();
3030

3131
extern bool InstallScheduledTasks(std::wstring& errinfo);
3232

DWMBlurGlass/MainWindow.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ namespace MDWMBlurGlass
3838
if (!LoadDefualtUIStyle(ui))
3939
return false;
4040

41-
auto [locale, parentLocale] = GetSystemLocaleAndParent();
42-
if (!LoadLanguageString(ui, locale, true))
41+
if (!LoadLanguageString(ui, GetSystemLocalName(), true))
4342
{
44-
if (!LoadLanguageString(ui, parentLocale, true))
45-
{
46-
if (!LoadLanguageString(ui, L"en-US", true))
47-
return false;
48-
}
43+
if (!LoadLanguageString(ui, L"en-US", true))
44+
return false;
4945
}
50-
else if (locale != L"en-US")
51-
{
46+
else if(GetSystemLocalName() != L"en-US")
5247
LoadLanguageString(ui, L"en-US", true, false);
53-
}
5448

5549
const HWND hWnd = (HWND)ctx->Base()->GetWindowHandle();
5650
//SetWindowLongW(hWnd, GWL_STYLE, GetWindowLongW(hWnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX | WS_SIZEBOX));

DWMBlurGlass/winmain.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
4040
return 0;
4141
#endif
4242

43-
auto [locale, parentLocale] = MDWMBlurGlass::GetSystemLocaleAndParent();
44-
4543
if (!MDWMBlurGlass::LoadLanguageFileList()
46-
|| (!MDWMBlurGlass::LoadBaseLanguageString(locale) && !MDWMBlurGlass::LoadBaseLanguageString(parentLocale)
44+
|| (!MDWMBlurGlass::LoadBaseLanguageString(MDWMBlurGlass::GetSystemLocalName())
4745
&& !MDWMBlurGlass::LoadBaseLanguageString(L"en-US")))
4846
{
4947
MessageBoxW(nullptr, L"初始化失败: 没有有效的语言文件 (Initialization failed: No valid language file).", L"error", MB_ICONERROR);
@@ -60,7 +58,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
6058
{
6159
MessageBoxW(nullptr,
6260
Helper::M_ReplaceString(MDWMBlurGlass::GetBaseLanguageString(L"initfail0"), L"{path}", curpath).c_str(),
63-
L"Warning", MB_ICONWARNING | MB_TOPMOST);
61+
L"waring", MB_ICONWARNING | MB_TOPMOST);
6462
return false;
6563
}
6664
}
@@ -131,4 +129,4 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
131129
engine.UnInitEngine();
132130

133131
return 0;
134-
}
132+
}

DWMBlurGlassExt/Backdrops/AcrylicBackdrop.hpp

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -188,91 +188,4 @@ namespace MDWMBlurGlassExt::AcrylicBackdrop
188188

189189
return effectBrush;
190190
}
191-
static winrt::Windows::UI::Composition::CompositionSurfaceBrush CreateNoiceSurfaceBrush(
192-
const winrt::Windows::UI::Composition::Compositor& compositor,
193-
ID2D1Device* d2dDevice
194-
) try
195-
{
196-
winrt::Windows::UI::Composition::CompositionGraphicsDevice graphicsDevice{ nullptr };
197-
THROW_IF_FAILED(
198-
compositor.as<ABI::Windows::UI::Composition::ICompositorInterop>()->CreateGraphicsDevice(
199-
d2dDevice,
200-
reinterpret_cast<ABI::Windows::UI::Composition::ICompositionGraphicsDevice**>(winrt::put_abi(graphicsDevice))
201-
)
202-
);
203-
auto compositionSurface
204-
{
205-
graphicsDevice.CreateDrawingSurface(
206-
{ 256.f, 256.f },
207-
winrt::Windows::Graphics::DirectX::DirectXPixelFormat::R16G16B16A16Float,
208-
winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied
209-
)
210-
};
211-
auto noiceBrush{ compositor.CreateSurfaceBrush(compositionSurface) };
212-
213-
wil::unique_hmodule wuxcModule{ LoadLibraryExW(L"Windows.UI.Xaml.Controls.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE) };
214-
THROW_LAST_ERROR_IF_NULL(wuxcModule);
215-
auto resourceHandle{ FindResourceW(wuxcModule.get(), MAKEINTRESOURCE(2000), RT_RCDATA) };
216-
THROW_LAST_ERROR_IF_NULL(resourceHandle);
217-
auto globalHandle{ LoadResource(wuxcModule.get(), resourceHandle) };
218-
THROW_LAST_ERROR_IF_NULL(globalHandle);
219-
auto cleanUp = wil::scope_exit([&]
220-
{
221-
if (globalHandle)
222-
{
223-
UnlockResource(globalHandle);
224-
FreeResource(globalHandle);
225-
}
226-
});
227-
DWORD resourceSize{ SizeofResource(wuxcModule.get(), resourceHandle) };
228-
THROW_LAST_ERROR_IF(resourceSize == 0);
229-
auto resourceAddress{ reinterpret_cast<PBYTE>(LockResource(globalHandle)) };
230-
winrt::com_ptr<IStream> stream{ SHCreateMemStream(resourceAddress, resourceSize), winrt::take_ownership_from_abi };
231-
THROW_LAST_ERROR_IF_NULL(stream);
232-
233-
winrt::com_ptr<IWICImagingFactory2> wicFactory{ nullptr };
234-
wicFactory.copy_from(DWM::CDesktopManager::s_pDesktopManagerInstance->GetWICFactory());
235-
winrt::com_ptr<IWICBitmapDecoder> wicDecoder{ nullptr };
236-
THROW_IF_FAILED(wicFactory->CreateDecoderFromStream(stream.get(), &GUID_VendorMicrosoft, WICDecodeMetadataCacheOnDemand, wicDecoder.put()));
237-
winrt::com_ptr<IWICBitmapFrameDecode> wicFrame{ nullptr };
238-
THROW_IF_FAILED(wicDecoder->GetFrame(0, wicFrame.put()));
239-
winrt::com_ptr<IWICFormatConverter> wicConverter{ nullptr };
240-
THROW_IF_FAILED(wicFactory->CreateFormatConverter(wicConverter.put()));
241-
winrt::com_ptr<IWICPalette> wicPalette{ nullptr };
242-
THROW_IF_FAILED(
243-
wicConverter->Initialize(
244-
wicFrame.get(),
245-
GUID_WICPixelFormat32bppPBGRA,
246-
WICBitmapDitherTypeNone,
247-
wicPalette.get(),
248-
0, WICBitmapPaletteTypeCustom
249-
)
250-
);
251-
winrt::com_ptr<IWICBitmap> wicBitmap{ nullptr };
252-
THROW_IF_FAILED(wicFactory->CreateBitmapFromSource(wicConverter.get(), WICBitmapCreateCacheOption::WICBitmapNoCache, wicBitmap.put()));
253-
254-
auto drawingSurfaceInterop{ compositionSurface.as<ABI::Windows::UI::Composition::ICompositionDrawingSurfaceInterop>() };
255-
POINT offset = { 0, 0 };
256-
winrt::com_ptr<ID2D1DeviceContext> d2dContext{ nullptr };
257-
THROW_IF_FAILED(
258-
drawingSurfaceInterop->BeginDraw(nullptr, IID_PPV_ARGS(d2dContext.put()), &offset)
259-
);
260-
d2dContext->Clear();
261-
winrt::com_ptr<ID2D1Bitmap1> d2dBitmap{ nullptr };
262-
d2dContext->CreateBitmapFromWicBitmap(
263-
wicBitmap.get(),
264-
D2D1::BitmapProperties1(
265-
D2D1_BITMAP_OPTIONS_NONE,
266-
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)
267-
),
268-
d2dBitmap.put()
269-
);
270-
d2dContext->DrawBitmap(d2dBitmap.get());
271-
THROW_IF_FAILED(
272-
drawingSurfaceInterop->EndDraw()
273-
);
274-
275-
return noiceBrush;
276-
}
277-
catch (...) { return nullptr; }
278191
}

DWMBlurGlassExt/Backdrops/BlurBackdrop.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ namespace MDWMBlurGlassExt::BlurBackdrop
4949
compositeStepEffect->SetDestination(*gaussianBlurEffect);
5050
compositeStepEffect->SetSource(*tintOpacityEffect);
5151

52-
blurAmount = g_configData.customBlurAmount;
52+
auto effectBrush{ compositor.CreateEffectFactory(*compositeStepEffect).CreateBrush() };
53+
effectBrush.SetSourceParameter(L"Backdrop", compositor.CreateBackdropBrush());
54+
return effectBrush;
5355
}
5456
}

DWMBlurGlassExt/Common/DWMStruct.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,10 +1514,5 @@ namespace MDWMBlurGlassExt::DWM
15141514
return DEFCALL_MHOST_METHOD(CChannel::MatrixTransformUpdate, handleIndex, matrix);
15151515
}
15161516
}
1517-
1518-
PRLIST_ENTRY CWindowList::GetWindowListForDesktop(ULONG_PTR desktopID)
1519-
{
1520-
return DEFCALL_MHOST_METHOD(CWindowList::GetWindowListForDesktop, desktopID);
1521-
}
15221517
}
15231518
#pragma pop_macro("DEFCALL_MHOST_METHOD")

DWMBlurGlassExt/DWMBlurGlass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ namespace MDWMBlurGlassExt
186186
}
187187
DwmAPIEffect::Refresh();
188188
CustomBackdrop::Refresh();
189-
OcclusionCulling::Refresh();
190189
AccentBlur::Refresh();
191190
BlurRadiusTweaker::Refresh();
192191
CustomButton::Refresh();

DWMBlurGlassExt/Section/CompositedBackdrop.hpp

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -215,85 +215,4 @@ namespace MDWMBlurGlassExt
215215
return false;
216216
}
217217
};
218-
219-
template <bool insertAtBack>
220-
class CSpriteVisualBase : public winrt::implements<CSpriteVisualBase<insertAtBack>, IUnknown>
221-
{
222-
protected:
223-
DWM::CVisual* m_parentVisual{ nullptr };
224-
winrt::com_ptr<DWM::CVisual> m_udwmVisual{ nullptr };
225-
winrt::com_ptr<IDCompositionVisual2> m_dcompVisual{ nullptr };
226-
winrt::com_ptr<DCompPrivate::InteropCompositionTarget> m_dcompTarget{ nullptr };
227-
winrt::com_ptr<DCompPrivate::IDCompositionDesktopDevicePartner> m_dcompDevice{ nullptr };
228-
winrt::Windows::UI::Composition::VisualCollection m_visualCollection{ nullptr };
229-
230-
virtual HRESULT InitializeVisual()
231-
{
232-
m_dcompDevice.copy_from(DWM::CDesktopManager::s_pDesktopManagerInstance->GetDCompositionInteropDevice());
233-
RETURN_IF_FAILED(
234-
m_dcompDevice->CreateSharedResource(
235-
IID_PPV_ARGS(m_dcompTarget.put())
236-
)
237-
);
238-
RETURN_IF_FAILED(m_dcompDevice->CreateVisual(m_dcompVisual.put()));
239-
RETURN_IF_FAILED(m_dcompVisual->SetBorderMode(DCOMPOSITION_BORDER_MODE_SOFT));
240-
#ifdef _DEBUG
241-
//m_dcompVisual.as<IDCompositionVisualDebug>()->EnableRedrawRegions();
242-
#endif
243-
RETURN_IF_FAILED(m_dcompTarget->SetRoot(m_dcompVisual.get()));
244-
RETURN_IF_FAILED(m_dcompDevice->Commit());
245-
m_visualCollection = m_dcompVisual.as<DCompPrivate::IDCompositionVisualPartnerWinRTInterop>()->GetVisualCollection();
246-
247-
wil::unique_handle resourceHandle{ nullptr };
248-
RETURN_IF_FAILED(
249-
m_dcompDevice->OpenSharedResourceHandle(m_dcompTarget.get(), resourceHandle.put())
250-
);
251-
RETURN_IF_FAILED(DWM::CVisual::CreateFromSharedHandle(resourceHandle.get(), m_udwmVisual.put()));
252-
m_udwmVisual->AllowVisualTreeClone(false);
253-
if (m_parentVisual)
254-
{
255-
RETURN_IF_FAILED(
256-
m_parentVisual->GetVisualCollection()->InsertRelative(
257-
m_udwmVisual.get(),
258-
nullptr,
259-
insertAtBack,
260-
true
261-
)
262-
);
263-
}
264-
265-
return S_OK;
266-
}
267-
268-
virtual void UninitializeVisual()
269-
{
270-
if (m_udwmVisual)
271-
{
272-
if (m_parentVisual)
273-
{
274-
m_parentVisual->GetVisualCollection()->Remove(
275-
m_udwmVisual.get()
276-
);
277-
}
278-
m_udwmVisual = nullptr;
279-
}
280-
if (m_dcompVisual)
281-
{
282-
#ifdef _DEBUG
283-
//m_dcompVisual.as<IDCompositionVisualDebug>()->DisableRedrawRegions();
284-
#endif
285-
m_visualCollection.RemoveAll();
286-
m_dcompVisual = nullptr;
287-
}
288-
if (m_dcompTarget)
289-
{
290-
m_dcompTarget->SetRoot(nullptr);
291-
m_dcompTarget = nullptr;
292-
}
293-
}
294-
295-
CSpriteVisualBase(DWM::CVisual* parentVisual) : m_parentVisual{ parentVisual } {}
296-
virtual ~CSpriteVisualBase() { CSpriteVisualBase::UninitializeVisual(); }
297-
};
298-
299218
}

0 commit comments

Comments
 (0)