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
+7 -1
View File
@@ -13,10 +13,16 @@ public interface IPluginData
ITheme Theme { get; }
/// <summary>
/// Gets the window size of the plugin window.
/// Gets the window size of the plugin window in device independent pixels.
/// </summary>
Size WindowSize { get; }
/// <summary>
/// Gets the window size of the plugin window in physical (device) pixels.
/// Use this to create a rendering surface that maps 1:1 to the display.
/// </summary>
Size WindowPixelSize { get; }
/// <summary>
/// Gets the window position of the plugin window.
/// </summary>
+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);
}
+7 -4
View File
@@ -6,14 +6,16 @@ namespace DesktopMagic.Api;
/// <summary>
/// Provides an abstract base class for creating plugins using SkiaSharp rendering.
/// Plugins override <see cref="Main(SKCanvas)"/> instead of <see cref="Plugin.Main()"/>.
/// Plugins override <see cref="Render()"/> and return an <see cref="SKImage"/> of their own size,
/// just like <see cref="Plugin.Main()"/> 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"/> and <see cref="AsyncPlugin"/> code is unaffected.
/// </summary>
public abstract class SkiaPlugin : Plugin
{
/// <summary>
/// This method is sealed and returns null for Skia plugins.
/// Override <see cref="Main(SKCanvas)"/> instead.
/// Override <see cref="Render()"/> instead.
/// </summary>
/// <returns>Always null.</returns>
public sealed override Bitmap? Main()
@@ -23,7 +25,8 @@ public abstract class SkiaPlugin : Plugin
/// <summary>
/// Called every <see cref="Plugin.UpdateInterval"/> milliseconds to render the plugin.
/// Return <see langword="null"/> to keep the previously rendered image.
/// </summary>
/// <param name="canvas">The SkiaSharp canvas to draw on.</param>
public abstract void Main(SKCanvas canvas);
/// <returns>The rendered image, or <see langword="null"/> to keep the previous frame.</returns>
public abstract SKImage? Render();
}