#include <Core/HAL/Display/DisplayDevice.h>
#include <Core/HAL/Display/Win32/Win32DisplayEvent.h>
#include <Core/HAL/Display/Win32/Win32Window.h>

namespace Juliet::Win32
{
    namespace
    {
        bool Initialize(NonNullPtr<DisplayDevice> /*self*/)
        {
            return true;
        }
        void Shutdown(NonNullPtr<DisplayDevice> /*self*/) {}
        void Free(NonNullPtr<DisplayDevice> device)
        {
            device->Windows.Destroy();
        }

        DisplayDevice* CreateDevice(Arena* arena)
        {
            auto device = ArenaPushStruct<DisplayDevice>(arena);

            if (!device)
            {
                return nullptr;
            }

            device->Initialize = Initialize;
            device->Shutdown   = Shutdown;
            device->Free       = Free;

            device->CreatePlatformWindow  = CreatePlatformWindow;
            device->DestroyPlatformWindow = DestroyPlatformWindow;
            device->ShowWindow            = ShowWindow;
            device->HideWindow            = HideWindow;
            device->SetWindowTitle        = SetWindowTitle;

            device->PumpEvents = PumpEvents;

            device->Windows.Create(arena JULIET_DEBUG_PARAM("Display Windows"));

            return device;
        }
    } // namespace

} // namespace Juliet::Win32

// Factory cannot be in an anonymous/unknown namespace
namespace Juliet
{
    DisplayDeviceFactory Win32DisplayDeviceFactory = { .Name = "Win32", .CreateDevice = Win32::CreateDevice };
}
