using System;
using Avalonia;

namespace ClaudeDo.Ui.Views.Controls;

/// <summary>
/// Pure, DPI-aware screen-rectangle hit testing for the custom drag. Kept free of any view
/// dependency so the "is the cursor over that window?" decision is unit-testable.
/// </summary>
public static class DragHitTest
{
    /// <summary>
    /// True when <paramref name="cursor"/> (physical px) falls inside a window whose top-left is
    /// <paramref name="position"/> (physical px) and whose <paramref name="clientSize"/> is in
    /// logical units at the given <paramref name="scaling"/>.
    /// </summary>
    public static bool WindowContains(PixelPoint position, Size clientSize, double scaling, PixelPoint cursor)
    {
        var right = position.X + (int)Math.Round(clientSize.Width * scaling);
        var bottom = position.Y + (int)Math.Round(clientSize.Height * scaling);
        return cursor.X >= position.X && cursor.X < right
            && cursor.Y >= position.Y && cursor.Y < bottom;
    }
}
