Pause plugins when covered by other window

This commit is contained in:
Stone_Red
2026-10-04 19:04:02 +02:00
parent 4ba39c67ce
commit 1507f7a36d
15 changed files with 744 additions and 108 deletions
+8 -4
View File
@@ -8,14 +8,17 @@ namespace DesktopMagic.Api;
/// <summary>
/// Provides an abstract base class for creating asynchronous plugins using SkiaSharp rendering.
/// Plugins override <see cref="MainAsync(SKCanvas, CancellationToken)"/> instead of <see cref="Plugin.Main()"/>.
/// Plugins override <see cref="RenderAsync(CancellationToken)"/> and return an <see cref="SKImage"/>
/// of their own size, just like <see cref="AsyncPlugin.MainAsync(CancellationToken)"/> returns a
/// <see cref="Bitmap"/>. The returned image is scaled to fit the plugin window while preserving
/// its aspect ratio.
/// All existing <see cref="Plugin"/>, <see cref="AsyncPlugin"/>, and <see cref="SkiaPlugin"/> code is unaffected.
/// </summary>
public abstract class SkiaAsyncPlugin : AsyncPlugin
{
/// <summary>
/// This method is sealed and returns null for async Skia plugins.
/// Override <see cref="MainAsync(SKCanvas, CancellationToken)"/> instead.
/// Override <see cref="RenderAsync(CancellationToken)"/> instead.
/// </summary>
public sealed override Task<Bitmap?> MainAsync(CancellationToken cancellationToken)
{
@@ -24,8 +27,9 @@ public abstract class SkiaAsyncPlugin : AsyncPlugin
/// <summary>
/// Called every <see cref="Plugin.UpdateInterval"/> milliseconds to render the plugin asynchronously.
/// Return <see langword="null"/> to keep the previously rendered image.
/// </summary>
/// <param name="canvas">The SkiaSharp canvas to draw on.</param>
/// <param name="cancellationToken">Token signaled when the host requests cancellation.</param>
public abstract Task MainAsync(SKCanvas canvas, CancellationToken cancellationToken);
/// <returns>The rendered image, or <see langword="null"/> to keep the previous frame.</returns>
public abstract Task<SKImage?> RenderAsync(CancellationToken cancellationToken);
}