Skip to content

Commit

Permalink
Merge branch 'dev' into dev-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Nov 10, 2023
2 parents 7cd7956 + b10a3a3 commit b3b3539
Showing 17 changed files with 165 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Magpie.sln
Original file line number Diff line number Diff line change
@@ -23,7 +23,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
src\Common.Pre.props = src\Common.Pre.props
src\Common.Post.props = src\Common.Post.props
src\extract_winui_runtime.py = src\extract_winui_runtime.py
src\fix_resfiles.py = src\fix_resfiles.py
HybridCRT.props = HybridCRT.props
src\WinUI.props = src\WinUI.props
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shared", "src\Shared\Shared.vcxitems", "{4EB33017-68C1-40FE-877A-BCFAB2832F18}"
4 changes: 2 additions & 2 deletions docs/Compilation guide.md
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ In order to compile Magpie, you need to first install:
2. [CMake](https://cmake.org/)

You can also use the built-in CMake of Visual Studio, which is located at `%ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin`.
3. [Python](https://www.python.org/) 3.6+
4. [Conan](https://conan.io/) v1
3. [Python](https://www.python.org/) 3.11+
4. [Conan](https://conan.io/)

```bash
pip install conan
4 changes: 2 additions & 2 deletions docs/编译指南.md
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
2. [CMake](https://cmake.org/)

你也可以使用 Visual Studio 内置的 CMake,它位于 `%ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin`
3. [Python](https://www.python.org/) 3.6+
4. [Conan](https://conan.io/) v1
3. [Python](https://www.python.org/) 3.11+
4. [Conan](https://conan.io/)

```bash
pip install conan
21 changes: 6 additions & 15 deletions publish.py
Original file line number Diff line number Diff line change
@@ -131,16 +131,9 @@ def remove_file(file):
pass


# 删除文件夹,忽略错误
def remove_folder(folder):
try:
shutil.rmtree(folder)
except:
pass


remove_file("Microsoft.Web.WebView2.Core.dll")

for folder in ["Microsoft.UI.Xaml", "Magpie.App"]:
shutil.rmtree(folder, ignore_errors=True)

for pattern in ["*.pdb", "*.lib", "*.exp", "*.winmd", "*.xml", "*.xbf", "dummy.*"]:
for file in glob.glob(pattern):
remove_file(file)
@@ -149,8 +142,7 @@ def remove_folder(folder):
if file != "resources.pri":
remove_file(file)

for folder in ["Microsoft.UI.Xaml", "Magpie.App"]:
remove_folder(folder)
remove_file("Microsoft.Web.WebView2.Core.dll")

print("清理完毕", flush=True)

@@ -162,9 +154,7 @@ def remove_folder(folder):
#####################################################################

# 取最新的 Windows SDK
windowsSdkDir = sorted(
glob.glob(programFilesX86Path + "\\Windows Kits\\10\\bin\\10.*")
)[-1]
windowsSdkDir = max(glob.glob(programFilesX86Path + "\\Windows Kits\\10\\bin\\10.*"))
makepriPath = windowsSdkDir + "\\x64\\makepri.exe"
if not os.access(makepriPath, os.X_OK):
raise Exception("未找到 makepri")
@@ -186,6 +176,7 @@ def remove_folder(folder):
continue

# 我们仅需 19h1 和 21h1 的资源,分别用于 Win10 和 Win11
# 小写 compact 仅存在于预发行版 WinUI 的资源中
for key in ["compact", "Compact", "v1", "rs2", "rs3", "rs4", "rs5"]:
if key in name:
# 将文件内容替换为一个空格(Base64 为 "IA==")
2 changes: 1 addition & 1 deletion src/Common.Post.props
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTVerbosity>low</CppWinRTVerbosity>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
<GeneratedFilesDir>$(IntDir)Generated Files\</GeneratedFilesDir>
</PropertyGroup>

2 changes: 1 addition & 1 deletion src/HybridCRT.props
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<!-- HybridCRT: https://github.com/microsoft/WindowsAppSDK/blob/main/docs/Coding-Guidelines/HybridCRT.md -->
<!-- 取自 https://github.com/microsoft/WindowsAppSDK/blob/b708422eb1da22a10b56a06c54d7c0759f1683d1/HybridCRT.props -->
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<!-- 使用 MultiThreadedDebug 而不是 MultiThreadedDebugDLL 以避免对 VCRUNTIME140d.dll 和 MSVCP140d.dll 的依赖 -->
15 changes: 8 additions & 7 deletions src/Magpie.App/Magpie.App.vcxproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" />
<PropertyGroup Label="Globals">
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
@@ -45,6 +45,7 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformExtensionSDKLocation(`WindowsDesktop, Version=10.0.22621.0`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), $(SDKReferenceDirectoryRoot), $(SDKExtensionDirectoryRoot), $(SDKReferenceRegistryRoot)))\DesignTime\CommonConfiguration\Neutral\WindowsDesktop.props" Condition="exists('$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformExtensionSDKLocation(`WindowsDesktop, Version=10.0.22621.0`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), $(SDKReferenceDirectoryRoot), $(SDKExtensionDirectoryRoot), $(SDKReferenceRegistryRoot)))\DesignTime\CommonConfiguration\Neutral\WindowsDesktop.props')" />
<Import Project="..\Common.Post.props" />
<Import Project="..\WinUI.props" />
<Import Project="$(SolutionDir)\.conan\$(MSBuildProjectName)\conandeps.props" Condition="Exists('$(SolutionDir)\.conan\$(MSBuildProjectName)\conandeps.props')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
@@ -554,18 +555,18 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets'))" />
</Target>
</Project>
6 changes: 0 additions & 6 deletions src/Magpie.App/ProfilePage.xaml
Original file line number Diff line number Diff line change
@@ -272,12 +272,6 @@
Style="{StaticResource ExpanderContentSettingStyle}">
<CheckBox x:Uid="Profile_Performance_VSync_TripleBuffering"
IsChecked="{x:Bind ViewModel.IsTripleBuffering, Mode=TwoWay}" />
<local:SettingsCard.ActionContent>
<!-- 使用魔法修复动画错误 -->
<ComboBox Width="0"
Height="0"
IsTabStop="False" />
</local:SettingsCard.ActionContent>
</local:SettingsCard>
</muxc:Expander.Content>
</muxc:Expander>
4 changes: 2 additions & 2 deletions src/Magpie.App/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.UI.Xaml" version="2.8.2-prerelease.220830001" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2045.28" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.8.6" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2151.40" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
</packages>
13 changes: 7 additions & 6 deletions src/Magpie/Magpie.vcxproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" />
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
@@ -29,6 +29,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Common.Post.props" />
<Import Project="..\WinUI.props" />
<Import Project="$(SolutionDir)\.conan\$(MSBuildProjectName)\conandeps.props" Condition="Exists('$(SolutionDir)\.conan\$(MSBuildProjectName)\conandeps.props')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
@@ -83,18 +84,18 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="XamlIslands.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.2045.28\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.8.6\build\native\Microsoft.UI.Xaml.targets'))" />
</Target>
</Project>
33 changes: 32 additions & 1 deletion src/Magpie/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -123,6 +123,20 @@ bool MainWindow::Create(HINSTANCE hInstance, const RECT& windowRect, bool isMaxi
);
SetLayeredWindowAttributes(_hwndTitleBar, 0, 255, LWA_ALPHA);

if (Win32Utils::GetOSVersion().IsWin11()) {
// 如果鼠标正位于一个按钮上,贴靠布局弹窗会出现在按钮下方。我们利用这个特性来修正贴靠布局弹窗的位置
_hwndMaximizeButton = CreateWindow(
L"BUTTON",
L"",
WS_VISIBLE | WS_CHILD | WS_DISABLED | BS_OWNERDRAW,
0, 0, 0, 0,
_hwndTitleBar,
NULL,
hInstance,
NULL
);
}

_content.TitleBar().SizeChanged([this](winrt::IInspectable const&, winrt::SizeChangedEventArgs const&) {
_ResizeTitleBarWindow();
});
@@ -233,6 +247,11 @@ LRESULT MainWindow::_TitleBarWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM

LRESULT MainWindow::_TitleBarMessageHandler(UINT msg, WPARAM wParam, LPARAM lParam) noexcept {
switch (msg) {
case WM_CTLCOLORBTN:
{
// 使原生按钮控件透明,虽然整个标题栏窗口都是不可见的
return NULL;
}
case WM_NCHITTEST:
{
POINT cursorPos{ GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam) };
@@ -427,16 +446,28 @@ void MainWindow::_ResizeTitleBarWindow() noexcept {
const float dpiScale = _currentDpi / float(USER_DEFAULT_SCREEN_DPI);

// 将标题栏窗口置于 XAML Islands 窗口上方
const int titleBarWidth = (int)std::ceilf(rect.Width * dpiScale);
SetWindowPos(
_hwndTitleBar,
HWND_TOP,
(int)std::floorf(rect.X * dpiScale),
(int)std::floorf(rect.Y * dpiScale) + _GetTopBorderHeight(),
(int)std::ceilf(rect.Width * dpiScale),
titleBarWidth,
(int)std::floorf(rect.Height * dpiScale + 1), // 不知为何,直接向上取整有时无法遮盖 TitleBarControl
SWP_SHOWWINDOW
);

if (_hwndMaximizeButton) {
static const float captionButtonHeightInDips = [&]() {
return titleBar.CaptionButtons().CaptionButtonSize().Height;
}();

const int captionButtonHeightInPixels = (int)std::ceilf(captionButtonHeightInDips * dpiScale);

// 确保原生按钮和标题栏按钮高度相同
MoveWindow(_hwndMaximizeButton, 0, 0, titleBarWidth, captionButtonHeightInPixels, FALSE);
}

// 设置标题栏窗口的最大化样式,这样才能展示正确的文字提示
LONG_PTR style = GetWindowLongPtr(_hwndTitleBar, GWL_STYLE);
SetWindowLongPtr(_hwndTitleBar, GWL_STYLE,
1 change: 1 addition & 0 deletions src/Magpie/MainWindow.h
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class MainWindow : public XamlWindowT<MainWindow, winrt::Magpie::App::MainPage>
void _ResizeTitleBarWindow() noexcept;

HWND _hwndTitleBar = NULL;
HWND _hwndMaximizeButton = NULL;
bool _trackingMouse = false;
};

1 change: 1 addition & 0 deletions src/Magpie/app.manifest
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
<!-- 启用 Segoe UI Variable 和 Segoe Fluent Icons -->
<maxversiontested Id="10.0.22000.0"/>
<maxversiontested Id="10.0.22621.0"/>
<maxversiontested Id="10.0.22631.0"/>
</application>
</compatibility>

Loading

0 comments on commit b3b3539

Please sign in to comment.