Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maplespe committed Feb 7, 2024
1 parent 4a4d519 commit 9af2186
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 60 deletions.
4 changes: 2 additions & 2 deletions DWMBlurGlass/Extend/ColorPickerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace MDWMBlurGlass
ui->Mgr()->AddGeometryStyle(L"colorpickerbtn", geometry);

std::wstring_view xml = LR"(
<PropGroup id="colorpicker_edit" limitText="3" number="true" inset="3,1,1,1" />
<PropGroup id="colorpicker_edit" limitText="3" number="true" inset="3,1,1,1" wordAutoSel="true" />
<UIControl name="colorpicker" bgColor="80,80,80,60" size="100%,100%" autoSize="false" align="Center" visible="false">
<UIControl bgColor="255,255,255,255" frameWidth="1" frameColor="222,222,222,255" frameRound="10" name="content"
Expand Down Expand Up @@ -209,7 +209,7 @@ namespace MDWMBlurGlass
ret = false;
}
break;
case Event_Edit_TextChanged:
case Event_Focus_False:
{
//防止文本越界
auto textFormat = [](UIEditBox* edit, int max)
Expand Down
2 changes: 1 addition & 1 deletion DWMBlurGlass/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace MDWMBlurGlass
return false;
}
else if(GetSystemLocalName() != L"en-US")
LoadLanguageString(ui, L"en-US", true);
LoadLanguageString(ui, L"en-US", true, false);

const HWND hWnd = (HWND)ctx->Base()->GetWindowHandle();
//SetWindowLongW(hWnd, GWL_STYLE, GetWindowLongW(hWnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX | WS_SIZEBOX));
Expand Down
2 changes: 1 addition & 1 deletion DWMBlurGlass/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace MDWMBlurGlass
{
inline const std::wstring g_vernum = L"2.0.0";
inline const std::wstring g_vernum = L"2.0.1";

Mui::_m_result MainWindow_SrcEventProc(Mui::MWindowCtx*, const Mui::MWndDefEventSource&, Mui::MEventCodeEnum, Mui::_m_param);

Expand Down
4 changes: 2 additions & 2 deletions DWMBlurGlass/Page/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace MDWMBlurGlass

xml += LR"(
<UIControl frame="0,50,485,100%" name="page1" visible="false" align="LinearV">
<UIControl frame="15,5,15f,115" align="LinearV" prop="group" autoSize="true" maxSize="455,150" minSize="455,90">
<UIControl frame="15,5,15f,115" align="LinearV" prop="group" autoSize="true" maxSize="455,180" minSize="455,90">
<UIControl frame="0,0,10f,30">
<UIImgBox frame="0,0,18,18" autoSize="false" img="icon_code" />
<UILabel pos="10,2" text="#blurmethod" />
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace MDWMBlurGlass
</UIControl>
</UIControl>
<UIControl frame="0,50,485,100%" name="page4" visible="false" align="LinearV">
<UIControl pos="15,5" align="LinearV" prop="group" autoSize="true" maxSize="455,150" minSize="455,90">
<UIControl pos="15,5" align="LinearV" prop="group" autoSize="true" maxSize="455,180" minSize="455,90">
<UIControl autoSize="true">
<UIImgBox frame="0,0,18,20" autoSize="false" img="icon_about" />
<UILabel pos="10,3" text="#about" />
Expand Down
Binary file modified DWMBlurGlass/Resource.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions DWMBlurGlass/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace MDWMBlurGlass
g_baselangList.clear();
}

bool LoadLanguageString(XML::MuiXML* ui, std::wstring_view local, bool init)
bool LoadLanguageString(XML::MuiXML* ui, std::wstring_view local, bool init, bool replaceCur)
{
const auto iter = g_langfileList.find(local.data());
if (iter == g_langfileList.end() || !ui)
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace MDWMBlurGlass
g_baselangList.insert({ name, value });
}

if ((_m_ptrv)ui != 1)
if ((_m_ptrv)ui != 1 && replaceCur)
{
g_curlangInfo.local = local;
g_curlangInfo.author = root.attribute(L"author").value();
Expand Down
2 changes: 1 addition & 1 deletion DWMBlurGlass/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace MDWMBlurGlass

void ClearBaseLanguage();

bool LoadLanguageString(Mui::XML::MuiXML* ui, std::wstring_view local, bool init);
bool LoadLanguageString(Mui::XML::MuiXML* ui, std::wstring_view local, bool init, bool replaceCur = true);

bool LoadDefualtUIStyle(Mui::XML::MuiXML* ui);

Expand Down
31 changes: 29 additions & 2 deletions DWMBlurGlassExt/Common/DWMStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ namespace MDWMBlurGlassExt::DWM
return accentpolicy;
}

HRESULT CMatrixTransformProxy::Update(const MilMatrix3x2D* matrix)
{
return DEFCALL_MHOST_METHOD(CMatrixTransformProxy::Update, matrix);
}

HRESULT CVisualProxy::SetClip(CBaseGeometryProxy* geometry)
{
return DEFCALL_MHOST_METHOD(CVisualProxy::SetClip, geometry);
Expand Down Expand Up @@ -206,11 +211,21 @@ namespace MDWMBlurGlassExt::DWM
DEFCALL_MHOST_METHOD(CVisual::SetInsetFromParent, margins);
}

void CVisual::SetInsetFromParentTop(int top)
{
DEFCALL_MHOST_METHOD(CVisual::SetInsetFromParentTop, top);
}

HRESULT CVisual::SetSize(const SIZE& size)
{
return DEFCALL_MHOST_METHOD(CVisual::SetSize, size);
}

void CVisual::SetOffset(const POINT& pt)
{
DEFCALL_MHOST_METHOD(CVisual::SetOffset, pt);
}

HRESULT CVisual::InitializeVisualTreeClone(CBaseObject* baseObject, UINT cloneOptions)
{
return DEFCALL_MHOST_METHOD(CVisual::InitializeVisualTreeClone, baseObject, cloneOptions);
Expand Down Expand Up @@ -839,9 +854,14 @@ namespace MDWMBlurGlassExt::DWM
DEFCALL_MHOST_METHOD(CText::SetColor, color);
}

void CText::SetText(LPCWSTR text)
HRESULT CText::SetText(LPCWSTR text)
{
return DEFCALL_MHOST_METHOD(CText::SetText, text);
}

HRESULT CText::SetSize(SIZE* size)
{
DEFCALL_MHOST_METHOD(CText::SetText, text);
return DEFCALL_MHOST_METHOD(CText::SetSize, size);
}

LPCWSTR CText::GetText()
Expand All @@ -858,6 +878,13 @@ namespace MDWMBlurGlassExt::DWM
return text;
}

CMatrixTransformProxy* CText::GetMatrixProxy()
{
if(os::buildNumber >= 22000)
return (CMatrixTransformProxy*)*((DWORD64*)this + 50);
return (CMatrixTransformProxy*)*((DWORD64*)this + 49);
}

HRESULT CWindowList::GetExtendedFrameBounds(HWND hWnd, RECT* rect)
{
return DEFCALL_MHOST_METHOD(CWindowList::GetExtendedFrameBounds, hWnd, rect);
Expand Down
27 changes: 24 additions & 3 deletions DWMBlurGlassExt/Common/DWMStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ namespace MDWMBlurGlassExt::DWM
struct CBaseGeometryProxy : CBaseObject {};
struct CRgnGeometryProxy : CBaseGeometryProxy {};

struct MilMatrix3x2D
{
DOUBLE S_11;
DOUBLE S_12;
DOUBLE S_21;
DOUBLE S_22;
DOUBLE DX;
DOUBLE DY;
};

struct CMatrixTransformProxy
{
HRESULT Update(const MilMatrix3x2D* matrix);
};

struct CVisualProxy : CBaseObject
{
HRESULT SetClip(CBaseGeometryProxy* geometry);
Expand All @@ -112,8 +127,12 @@ namespace MDWMBlurGlassExt::DWM

void SetInsetFromParent(MARGINS* margins);

void SetInsetFromParentTop(int top);

HRESULT SetSize(const SIZE& size);

void SetOffset(const POINT& pt);

HRESULT InitializeVisualTreeClone(CBaseObject* baseObject, UINT cloneOptions);

void Unhide();
Expand Down Expand Up @@ -155,12 +174,14 @@ namespace MDWMBlurGlassExt::DWM
HRESULT InsertRelative(CVisual* visual, CVisual* reference, bool insterAfter, bool updateNow);
};

struct CText
struct CText : CVisual
{
void SetColor(COLORREF color);
void SetText(LPCWSTR text);

HRESULT SetText(LPCWSTR text);
HRESULT SetSize(SIZE* size);
LPCWSTR GetText();

CMatrixTransformProxy* GetMatrixProxy();
};

struct CDWriteText {};
Expand Down
7 changes: 6 additions & 1 deletion DWMBlurGlassExt/Common/DefFunctionList.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace MDWMBlurGlassExt
{ udwm, "CText::SetColor" },
{ udwm, "CText::SetText" },
{ udwm, "CText::SetSize" },
{ udwm, "CText::UpdateAlignmentTransform" },

{ udwm, "CWindowList::BlurBehindChange" },
{ udwm, "CWindowList::GetSyncedWindowData" },
Expand All @@ -77,7 +78,9 @@ namespace MDWMBlurGlassExt

{ udwm, "CVisual::Create" },
{ udwm, "CVisual::SetInsetFromParent" },
{ udwm, "CVisual::SetInsetFromParentTop" },
{ udwm, "CVisual::SetSize" },
{ udwm, "CVisual::SetOffset" },
{ udwm, "CVisual::InitializeVisualTreeClone" },
{ udwm, "CVisual::Unhide" },
{ udwm, "CVisual::Hide" },
Expand All @@ -95,6 +98,8 @@ namespace MDWMBlurGlassExt
{ udwm, "CContainerVisual" },
{ udwm, "CContainerVisual::Create" },

{ udwm, "CWindowData::IsImmersiveWindow" }
{ udwm, "CWindowData::IsImmersiveWindow" },

{ udwm, "CMatrixTransformProxy::Update" }
});
}
1 change: 0 additions & 1 deletion DWMBlurGlassExt/Common/HookDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace MDWMBlurGlassExt
std::array
{
detour_info(AccentBlur::CTopLevelWindow_ValidateVisual, call_type::before),
detour_info(TitleTextTweaker::CTopLevelWindow_ValidateVisual, call_type::before),
detour_info(CustomButton::CTopLevelWindow_ValidateVisual, call_type::before),
detour_info(CustomBackdrop::CTopLevelWindow_ValidateVisual, call_type::after),
detour_info(DwmAPIEffect::CTopLevelWindow_ValidateVisual, call_type::after),
Expand Down
4 changes: 2 additions & 2 deletions DWMBlurGlassExt/DWMBlurGlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace MDWMBlurGlassExt
g_funCWindowList_BlurBehindChange.Attach();
}*/

g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<5, true>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<4, true>();

Refresh();
TitleTextTweaker::Attach();
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace MDWMBlurGlassExt
CustomBackdrop::Detach();
DwmAPIEffect::Detach();

g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<5, false>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<4, false>();

HMODULE udwmModule = GetModuleHandleW(L"udwm.dll");
if(os::buildNumber < 22000)
Expand Down
Binary file modified DWMBlurGlassExt/DWMBlurGlassExt.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions DWMBlurGlassExt/Section/CustomBackdropEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ namespace MDWMBlurGlassExt::CustomBackdrop
g_funCTopLevelWindow_InitializeVisualTreeClone.Attach();
g_funCTopLevelWindow_UpdateNCAreaBackground.Attach();
g_funResourceHelper_CreateGeometryFromHRGN.Attach();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<3, true>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<2, true>();

}

void Detach()
{
if (!g_startup) return;

g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<3, false>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<2, false>();
g_funResourceHelper_CreateGeometryFromHRGN.Detach();
g_funCTopLevelWindow_UpdateNCAreaBackground.Detach();
g_funCTopLevelWindow_InitializeVisualTreeClone.Detach();
Expand Down
18 changes: 11 additions & 7 deletions DWMBlurGlassExt/Section/CustomButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ namespace MDWMBlurGlassExt::CustomButton
g_startup = true;

g_funCButton_UpdateLayout.Attach();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<2, true>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<1, true>();

}

void Detach()
{
if (!g_startup) return;

g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<2, false>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<1, false>();
g_funCButton_UpdateLayout.Detach();
g_cbuttonList.clear();

Expand Down Expand Up @@ -128,15 +128,19 @@ namespace MDWMBlurGlassExt::CustomButton

const float scale = (float)dpi / 96.f;

if (borderW != 0)
borderW += (int)round(1.f * scale);
else if(!IsZoomed(g_window))
{
borderW = GetSystemMetrics(SM_CXPADDEDBORDER) + GetSystemMetrics(SM_CXFRAME);
if (os::buildNumber >= 22000)
borderW = -borderW;
}

const int width = int(28.f * scale);
const int normalW = int(48.f * scale);
const int height = int((float)frameY * scale);

//if (os::buildNumber >= 22000)
//{
borderW += (int)round(1.f * scale);
//}

int offset = rect.right - borderW;
//关闭按钮
if (PushButtonPtr(3, rect.right - normalW - borderW, normalW, height))
Expand Down
11 changes: 5 additions & 6 deletions DWMBlurGlassExt/Section/DwmAPIEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
#include "DwmAPIEffect.h"
#include "CommonDef.h"
#include "AccentBlurEffect.h"

namespace MDWMBlurGlassExt::DwmAPIEffect
{
Expand All @@ -29,23 +28,23 @@ namespace MDWMBlurGlassExt::DwmAPIEffect

void Attach()
{
if (os::buildNumber < 22000)
if (os::buildNumber < 22621)
return;
if (g_startup) return;
g_startup = true;
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<4, true>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<3, true>();
}

void Detach()
{
if (!g_startup) return;
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<4, false>();
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<3, false>();
g_startup = false;
}

void Refresh()
{
if (os::buildNumber < 22000)
if (os::buildNumber < 22621)
return;
if (g_configData.blurmethod == blurMethod::DWMAPIBlur && !g_startup)
Attach();
Expand All @@ -59,7 +58,7 @@ namespace MDWMBlurGlassExt::DwmAPIEffect
{
const HWND hWnd = windowData->GetHWND();

if (os::buildNumber >= 22000 && This->HasNonClientBackground())
if (os::buildNumber >= 22621 && This->HasNonClientBackground())
{
DWM_SYSTEMBACKDROP_TYPE type = DWMSBT_NONE;
switch ((int)g_configData.effectType)
Expand Down
Loading

0 comments on commit 9af2186

Please sign in to comment.