Skip to content

Commit 33f8f73

Browse files
committed
Hotfix Win10 (Closes #1529) and installer (Closes #1528) (#1260)
1 parent 4c29a56 commit 33f8f73

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

Daybreak.Installer/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ or HttpStatusCode.TemporaryRedirect
311311
var workingDirectory = args.Length > 2
312312
? args[1] : Path.GetFullPath("..", AppContext.BaseDirectory);
313313

314-
if (args.Length > 1 && args[1] is "update")
314+
if (mode is "install")
315315
{
316-
await PerformUpdate(workingDirectory);
316+
await PerformFreshInstall(workingDirectory);
317317
}
318318
else
319319
{
320-
await PerformFreshInstall(workingDirectory);
320+
await PerformUpdate(workingDirectory);
321321
}

Daybreak/Launch/Launcher.Shared.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Serilog;
99
using Serilog.Events;
1010
using Serilog.Sinks.SystemConsole.Themes;
11+
using System.Extensions.Core;
1112
using System.Runtime.InteropServices;
1213

1314
namespace Daybreak.Launch;
@@ -73,13 +74,30 @@ private static bool StopHostedServices(PhotinoBlazorApp app, CancellationTokenSo
7374

7475
private static void SetupRoundedWindows(PhotinoBlazorApp app)
7576
{
76-
var hwnd = app.MainWindow.WindowHandle;
77-
var preference = NativeMethods.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND;
78-
NativeMethods.DwmSetWindowAttribute(
79-
hwnd,
80-
NativeMethods.DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE,
81-
ref preference,
82-
sizeof(uint));
77+
var scopedLogger = app.Services.GetRequiredService<ILogger<Launcher>>().CreateScopedLogger();
78+
try
79+
{
80+
// DWMWA_WINDOW_CORNER_PREFERENCE is only supported on Windows 11 (Build 22000+)
81+
if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000))
82+
{
83+
scopedLogger.LogWarning("Rounded corners are not supported on this version of Windows.");
84+
return;
85+
}
86+
87+
88+
var hwnd = app.MainWindow.WindowHandle;
89+
var preference = NativeMethods.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND;
90+
NativeMethods.DwmSetWindowAttribute(
91+
hwnd,
92+
NativeMethods.DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE,
93+
ref preference,
94+
sizeof(uint));
95+
scopedLogger.LogDebug("Setup rounded corners");
96+
}
97+
catch (Exception ex)
98+
{
99+
scopedLogger.LogError(ex, "Failed to set rounded corners on window.");
100+
}
83101
}
84102

85103
private static void SetupBorderless(PhotinoBlazorApp app)

0 commit comments

Comments
 (0)