
#ifndef PLATFORM_UNIX_X11DISPLAY_H
#define PLATFORM_UNIX_X11DISPLAY_H

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <cstdint>
#include <Platform/PlatformDisplay.h>

namespace sp {

// NOTE: This class wraps a X11 Window and Screen handle
// and is NOT a Class wrapper around X11's `Display` type.
class X11Display : public PlatformDisplay
{
public :

	static X11Display* getFocused();

	X11Display();

	virtual bool	create(DisplayDescription description);

	virtual void	destroy();

	virtual bool	isValid();

	virtual void*	getHandle() const;

	virtual void	setSize(unsigned int width, unsigned int height);

	virtual Vector2u getSize() const;

	virtual void	setPosition(unsigned int x, unsigned int y);

	virtual Vector2u getPosition() const;

	virtual void 	setVisible(bool visible);

	virtual void 	setDecoration(unsigned decoration);

	virtual void 	minimize();

	virtual void 	maximize();

	virtual void 	enterFullscreen(DisplayMode mode);

	virtual void 	exitFullscreen();

	virtual void	setCaption(const std::string& caption);

	virtual void	setIcon(unsigned int width, unsigned int height, const uint8_t *pixels);

	virtual void	showCursor(bool value);

	virtual void 	grabCursor(bool value);

	void 			processEvent(const ::XEvent& event);

protected :

	void			createHiddenCursor();

protected :

	::Window		m_win;

	int 			m_screen;

	::Cursor		m_cur_hidden;
	::Cursor		m_cur_last;

	Vector2u	m_size;
};

} // namespace sp

#endif /* PLATFORM_UNIX_X11DISPLAY_H */
