#include "adapters/windows/display/WindowsDisplayMetrics.h"

#include <Windows.h>

namespace ta::adapters::windows::display
{
    std::optional<ta::application::DisplayMetrics> query_primary_display_metrics() noexcept
    {
        RECT desktop{};
        const HWND desktop_window = GetDesktopWindow();
        if (!desktop_window || !GetWindowRect(desktop_window, &desktop))
            return std::nullopt;

        const float width = static_cast<float>(desktop.right - desktop.left);
        const float height = static_cast<float>(desktop.bottom - desktop.top);
        const ta::application::DisplayMetrics metrics{width, height};
        return metrics.valid() ? std::optional{metrics} : std::nullopt;
    }
}
