forked from zhanggyb/set-user-data
/
surface.hpp
59 lines (41 loc) · 1.15 KB
/
surface.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
50
51
52
53
54
55
56
57
58
59
//
// surface.hpp
//
#ifndef DISPLAY_DISPATCH_SURFACE_HPP
#define DISPLAY_DISPATCH_SURFACE_HPP
#include "compositor.hpp"
#include "buffer.hpp"
struct Surface {
Surface()
: native(nullptr) {}
~Surface() {
if (native) wl_surface_destroy(native);
}
void Setup(const Compositor &compositor) {
Destroy();
native = wl_compositor_create_surface(compositor.native);
wl_surface_add_listener(native, &kListener, this);
}
void Destroy() {
if (native) {
wl_surface_destroy(native);
native = nullptr;
}
}
void Attach(const Buffer &buffer, int32_t x, int32_t y) {
wl_surface_attach(native, buffer.native, x, y);
}
void Commit() {
wl_surface_commit(native);
}
void SetUserData(void *user_data) {
wl_surface_set_user_data(native, user_data);
}
const int placeholder1 = 0;
struct wl_surface *native;
const int placeholder2 = 0;
static void OnEnter(void *data, struct wl_surface *surface, struct wl_output *output);
static void OnLeave(void *data, struct wl_surface *surface, struct wl_output *output);
static const wl_surface_listener kListener;
};
#endif //DISPLAY_DISPATCH_SURFACE_HPP