#pragma once

#include "BaseWindow.h"

#include <wayland-client.h>
#include "xdg-shell-client-protocol.h"

namespace ehs
{
	class Window : public BaseWindow
	{
	private:
		wl_display* display;
		wl_registry *registry;
		wl_compositor* compositor;
		wl_surface* surface;
		xdg_wm_base *xdgShell;
		xdg_surface *xdgSurface;
		xdg_toplevel *xdgToplevel;

		static void SurfaceConfigure(void *data, xdg_surface *xdg_surface, UInt_32 serial);

		static void ShellPing(void *data, xdg_wm_base *shell, UInt_32 serial);

		static void RegistryHandler(void *data, wl_registry *registry, UInt_32 id, const char *interface, UInt_32 version);

		static void RegistryRemoved(void *data, wl_registry *registry, UInt_32 id);

	public:
		~Window() override;

		Window();

		void Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale) override;

		void Create_16(const Str_16& title, const Vec2_s32& pos, const Vec2_u32 scale) override;

		void Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale) override;

		void OnCreated() override;

		void Close() override;

		void Show() override;

		void Hide() override;

		bool Poll() override;

		void ShowCursor(bool toggle) override;

		void ConstrainCursor(const bool constrain) override;

		void SetTitle_32(const Str_32& newTitle) override;

		Str_32 GetTitle_32() const override;

		void SetTitle_16(const Str_16& newTitle) override;

		Str_16 GetTitle_16() const override;

		void SetTitle_8(const Str_8& newTitle) override;

		Str_8 GetTitle_8() const override;

		void SetPos(const Vec2_s32& newPos) override;

		Vec2_s32 GetPos() const override;

		void SetScale(const Vec2_u32& newScale) override;

		Vec2_u32 GetScale() const override;

		Serializer<UInt_64> GetClipboard() override;

		void SetClipboard(Serializer<UInt_64> data) override;

		void SetCursorImg(const CursorImg img) override;
	};
}