1// LAF OS Library
2// Copyright (C) 2021 Igara Studio S.A.
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#ifndef OS_X11_CURSOR_H
8#define OS_X11_CURSOR_H
9#pragma once
10
11#include "os/cursor.h"
12#include "os/x11/x11.h"
13
14#include <X11/Xlib.h>
15
16namespace os {
17
18class CursorX11 : public Cursor {
19public:
20 CursorX11(::Cursor xcursor) : m_xcursor(xcursor) { }
21 ~CursorX11() {
22 if (m_xcursor != None) {
23 auto x11 = X11::instance();
24 ASSERT(x11);
25 if (x11)
26 XFreeCursor(x11->display(), m_xcursor);
27 }
28 }
29
30 void* nativeHandle() override {
31 return (void*)m_xcursor;
32 }
33
34private:
35 ::Cursor m_xcursor;
36};
37
38} // namespace os
39
40#endif
41