19 #ifndef MIRAL_WAYLAND_HELPERS_H 20 #define MIRAL_WAYLAND_HELPERS_H 22 #include <wayland-client.h> 26 #include <unordered_map> 28 template<
typename Type>
29 auto make_scoped(Type* owned,
void(*deleter)(Type*)) -> std::unique_ptr<Type, void(*)(Type*)>
31 return {owned, deleter};
34 wl_shm_pool*
make_shm_pool(
struct wl_shm* shm,
int size,
void **data);
41 std::function<
void(
Output const&)> on_constructed,
42 std::function<
void(
Output const&)> on_change);
55 static void output_done(
void* data, wl_output* output);
57 static wl_output_listener
const output_listener;
59 std::function<void(Output const&)> on_constructed;
60 std::function<void(Output const&)> on_change;
67 std::function<
void(
Output const&)> on_new_output,
68 std::function<
void(
Output const&)> on_output_changed,
69 std::function<
void(
Output const&)> on_output_gone);
71 wl_compositor* compositor =
nullptr;
72 wl_shm* shm =
nullptr;
73 wl_seat* seat =
nullptr;
74 wl_shell* shell =
nullptr;
76 void init(
struct wl_display* display);
80 static void new_global(
82 struct wl_registry* registry,
84 char const* interface,
87 static void global_remove(
89 struct wl_registry* registry,
92 wl_registry_listener
const registry_listener = {
97 std::unique_ptr<wl_registry, decltype(&wl_registry_destroy)> registry;
99 std::unordered_map<uint32_t, std::unique_ptr<Output>> bound_outputs;
101 std::function<void(Output const&)>
const on_new_output;
102 std::function<void(Output const&)>
const on_output_changed;
103 std::function<void(Output const&)>
const on_output_gone;
106 #endif //MIRAL_WAYLAND_HELPERS_H Definition: wayland_helpers.h:63
auto make_scoped(Type *owned, void(*deleter)(Type *)) -> std::unique_ptr< Type, void(*)(Type *)>
Definition: wayland_helpers.h:29
int32_t transform
Definition: wayland_helpers.h:51
wl_output * output
Definition: wayland_helpers.h:53
~Output()
Definition: wayland_helpers.cpp:160
Definition: wayland_helpers.h:36
int scale
Definition: wayland_helpers.h:52
Output(wl_output *output, std::function< void(Output const &)> on_constructed, std::function< void(Output const &)> on_change)
Definition: wayland_helpers.cpp:149
char const * name
Definition: client_types.h:177
wl_shm_pool * make_shm_pool(struct wl_shm *shm, int size, void **data)
Definition: wayland_helpers.cpp:31
Output & operator=(Output const &)=delete