Skip to content

Commit

Permalink
feat: support delay window such as AnLink
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Aug 19, 2024
1 parent 8e0b4ed commit 5628a7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/MakeDark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<PublishTrimmed>false</PublishTrimmed>
<ApplicationIcon>Favicon.ico</ApplicationIcon>
<AssemblyName>makedark</AssemblyName>
<AssemblyVersion>0.2.0</AssemblyVersion>
<FileVersion>0.2.0</FileVersion>
<Version>$(VersionPrefix)0.2.0</Version>
<AssemblyVersion>0.3.0</AssemblyVersion>
<FileVersion>0.3.0</FileVersion>
<Version>$(VersionPrefix)0.3.0</Version>
<Company>Lemutec</Company>
</PropertyGroup>

Expand Down
20 changes: 19 additions & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void Main(string[] args)
process.Start();
process.WaitForInputIdle();

SpinWait.SpinUntil(() => process.HasExited || process.MainWindowHandle != IntPtr.Zero);
_ = SpinWait.SpinUntil(() => process.HasExited || process.MainWindowHandle != IntPtr.Zero, 30000);

if (process.HasExited)
{
Expand All @@ -72,6 +72,24 @@ public static void Main(string[] args)
Interop.SetRoundedCorners(hWnd);
}
}

if (process.HasExited)
{
return;
}

_ = SpinWait.SpinUntil(() =>
{
foreach (nint hWnd in Interop.GetWindowHandleByProcessId(process.Id))
{
if (!Interop.IsDarkModeForWindow(hWnd))
{
Interop.EnableDarkModeForWindow(hWnd);
Interop.SetRoundedCorners(hWnd);
}
}
return false;
}, 3000);
}
}
}

0 comments on commit 5628a7a

Please sign in to comment.