4 #include "ivi-controller-client-protocol.h"
13 // __ ____ _ _ _| | __ _ _ __ __| | _ __ _ __ _____ ___ _
14 // \ \ /\ / / _` | | | | |/ _` | '_ \ / _` | | '_ \| '__/ _ \ \/ / | | |
15 // \ V V / (_| | |_| | | (_| | | | | (_| | | |_) | | | (_) > <| |_| |
16 // \_/\_/ \__,_|\__, |_|\__,_|_| |_|\__,_|____| .__/|_| \___/_/\_\\__, |
17 // |___/ |_____|_| |___/
18 template <typename ProxyT>
19 struct wayland_proxy {
22 wayland_proxy(void *p) : proxy(static_cast<ProxyT *>(p)) {}
24 virtual ~wayland_proxy() {
25 // If this is the nullptr, then it means it already was destroyed by a
26 // custom wayland dtor
28 logdebug("%s %p @ %p", __func__, this, this->proxy);
29 wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy));
35 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
36 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
37 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
38 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
44 // __| (_)___ _ __ | | __ _ _ _
45 // / _` | / __| '_ \| |/ _` | | | |
46 // | (_| | \__ \ |_) | | (_| | |_| |
47 // \__,_|_|___/ .__/|_|\__,_|\__, |
50 std::unique_ptr<wl_display, void (*)(wl_display *)> d;
51 std::unique_ptr<registry> r;
61 // _ __ ___ __ _(_)___| |_ _ __ _ _
62 // | '__/ _ \/ _` | / __| __| '__| | | |
63 // | | | __/ (_| | \__ \ |_| | | |_| |
64 // |_| \___|\__, |_|___/\__|_| \__, |
66 struct registry : public wayland_proxy<wl_registry> {
67 typedef std::function<void(wl_registry *, uint32_t, uint32_t)> binder;
68 std::map<std::string, binder> bindings;
70 registry(wl_display *d);
73 void add_global_handler(char const *iface, binder bind);
76 void global(uint32_t name, char const *iface, uint32_t v);
77 void global_remove(uint32_t name);
81 // ___ _ _| |_ _ __ _ _| |_
82 // / _ \| | | | __| '_ \| | | | __|
83 // | (_) | |_| | |_| |_) | |_| | |_
84 // \___/ \__,_|\__| .__/ \__,_|\__|
86 struct output : wayland_proxy<wl_output> {
87 output(wl_registry *registry, uint32_t name, uint32_t version);
90 void geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, int32_t subpel,
91 char const *make, char const *model, int32_t tx);
92 void mode(uint32_t flags, int32_t w, int32_t h, int32_t r);
94 void scale(int32_t factor);
98 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
99 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
100 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
101 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
104 // __ _ ___ _ __ (_)_ _(_)
105 // / _` |/ _ \ '_ \| \ \ / / |
106 // | (_| | __/ | | | |\ V /| |
107 // \__, |\___|_| |_|_| \_/ |_|
112 // ___ _ _ _ __ / _| __ _ ___ ___
113 // / __| | | | '__| |_ / _` |/ __/ _ \
114 // \__ \ |_| | | | _| (_| | (_| __/
115 // |___/\__,_|_| |_| \__,_|\___\___|
117 struct surface : public wayland_proxy<ivi_controller_surface> {
120 surface(uint32_t i, ivi_controller *c);
124 void visibility(int32_t visibility);
125 void opacity(float opacity);
126 void source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
127 void destination_rectangle(int32_t x, int32_t y, int32_t width,
129 void configuration(int32_t width, int32_t height);
130 void orientation(int32_t orientation);
131 void pixelformat(int32_t pixelformat);
132 void layer(struct ivi_controller_layer *layer);
133 void stats(uint32_t redraw_count, uint32_t frame_count,
134 uint32_t update_count, uint32_t pid, const char *process_name);
136 void content(int32_t content_state);
140 // | | __ _ _ _ ___ _ __
141 // | |/ _` | | | |/ _ \ '__|
142 // | | (_| | |_| | __/ |
143 // |_|\__,_|\__, |\___|_|
145 struct layer : public wayland_proxy<ivi_controller_layer> {
148 layer(uint32_t i, ivi_controller *c);
152 void visibility(int32_t visibility);
153 void opacity(float opacity);
154 void source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
155 void destination_rectangle(int32_t x, int32_t y, int32_t width,
157 void configuration(int32_t width, int32_t height);
158 void orientation(int32_t orientation);
159 void screen(struct wl_output *screen);
163 void set_visibility(uint32_t visibility);
164 void set_opacity(wl_fixed_t opacity);
165 void set_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
166 void set_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
167 void set_configuration(int32_t width, int32_t height);
168 void set_orientation(int32_t orientation);
169 void screenshot(const char *filename);
170 void clear_surfaces();
171 void add_surface(struct surface *surface);
172 void remove_surface(struct surface *surface);
173 void set_render_order(struct wl_array *id_surfaces);
177 // ___ ___ _ __ ___ ___ _ __
178 /// __|/ __| '__/ _ \/ _ \ '_ \
179 //\__ \ (__| | | __/ __/ | | |
180 //|___/\___|_| \___|\___|_| |_|
182 struct screen : public wayland_proxy<ivi_controller_screen> {
185 screen(uint32_t i, ivi_controller_screen *p);
189 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
190 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
191 // | (_| (_) | | | | |_| | | (_) | | | __/ |
192 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
194 struct controller : public wayland_proxy<ivi_controller> {
195 std::map<uint32_t, std::unique_ptr<surface>> surfaces;
196 std::map<uint32_t, std::unique_ptr<layer>> layers;
197 std::map<uint32_t, std::unique_ptr<screen>> screens;
199 controller(wl_registry *r, uint32_t name, uint32_t version);
200 ~controller() override;
203 void screen(uint32_t id, ivi_controller_screen *screen);
204 void layer(uint32_t id);
205 void surface(uint32_t id);
206 void error(int32_t oid, int32_t otype, int32_t code, char const *text);
210 #endif // !WM_WAYLAND_HPP