#pragma once

#include <efi.h>
#include <common.h>
#include <string_utils.h>

#define LAYER_MAX 32
#define LAYER_NAME_LEN 32

typedef enum {
    LAYER_TYPE_DESKTOP,
    LAYER_TYPE_WINDOW,
    LAYER_TYPE_MOUSE,
    LAYER_TYPE_OVERLAY,
} layer_type_t;

typedef struct layer {
    UINT32 id;
    char name[LAYER_NAME_LEN];
    layer_type_t type;
    SSINT32 x, y;
    UINT32 w, h;
    SSINT32 z;
    bool visible;
    EFI_GRAPHICS_OUTPUT_BLT_PIXEL* buffer;
    struct layer* next;
} layer_t;

// Initialization — allocates back buffer, registers keyboard handler
void layer_init(void);

// Layer management
layer_t* layer_create(String name, layer_type_t type, UINT32 w, UINT32 h);
void     layer_destroy(layer_t* layer);
void     layer_set_z(layer_t* layer, SSINT32 z);
void     layer_set_pos(layer_t* layer, SSINT32 x, SSINT32 y);
void     layer_set_visible(layer_t* layer, bool visible);
layer_t* layer_get_by_id(UINT32 id);
layer_t* layer_get_focused(void);

// Compositor task entry
void layer_compositor_task(void);
