-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow.hpp
49 lines (38 loc) · 893 Bytes
/
Window.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <xcb/xcb.h>
#include <atomic>
#include <memory>
enum class EventType
{
Quit
};
class Event
{
public:
virtual ~Event() = default;
virtual EventType type() const noexcept = 0;
};
class QuitEvent : public Event
{
EventType type() const noexcept final { return EventType::Quit; }
};
class Window
{
public:
explicit Window(std::string_view window_name);
xcb_connection_t *connection() const noexcept;
std::unique_ptr<Event> poll_event();
xcb_window_t window() const noexcept;
private:
struct ConnectionDeleter
{
void operator()(xcb_connection_t *c) const noexcept;
};
struct FreeDeleter
{
void operator()(void *ptr) const noexcept;
};
std::unique_ptr<xcb_connection_t, ConnectionDeleter> _connection;
xcb_window_t _window;
xcb_atom_t _wm_delete_window_atom, _wm_protocols_atom;
};