4 #include "ivi-controller-client-protocol.h"
14 // __ ____ _ _ _| | __ _ _ __ __| | _ __ _ __ _____ ___ _
15 // \ \ /\ / / _` | | | | |/ _` | '_ \ / _` | | '_ \| '__/ _ \ \/ / | | |
16 // \ V V / (_| | |_| | | (_| | | | | (_| | | |_) | | | (_) > <| |_| |
17 // \_/\_/ \__,_|\__, |_|\__,_|_| |_|\__,_|____| .__/|_| \___/_/\_\\__, |
18 // |___/ |_____|_| |___/
19 template <typename ProxyT>
20 struct wayland_proxy {
23 wayland_proxy(void *p) : proxy(static_cast<ProxyT *>(p)) {}
25 virtual ~wayland_proxy() {
26 // If this is the nullptr, then it means it already was destroyed by a
27 // custom wayland dtor
29 logdebug("%s %p @ %p", __func__, this, this->proxy);
30 wl_proxy_destroy(reinterpret_cast<struct wl_proxy *>(proxy));
36 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
37 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
38 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
39 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
45 // __| (_)___ _ __ | | __ _ _ _
46 // / _` | / __| '_ \| |/ _` | | | |
47 // | (_| | \__ \ |_) | | (_| | |_| |
48 // \__,_|_|___/ .__/|_|\__,_|\__, |
51 std::unique_ptr<struct wl_display, std::function<void(struct wl_display *)>>
53 std::unique_ptr<struct registry> r;
63 // _ __ ___ __ _(_)___| |_ _ __ _ _
64 // | '__/ _ \/ _` | / __| __| '__| | | |
65 // | | | __/ (_| | \__ \ |_| | | |_| |
66 // |_| \___|\__, |_|___/\__|_| \__, |
68 struct registry : public wayland_proxy<struct wl_registry> {
69 typedef std::function<void(struct wl_registry *, uint32_t, uint32_t)> binder;
70 std::map<std::string, binder> bindings;
72 registry(struct wl_display *d);
75 void add_global_handler(char const *iface, binder bind);
78 void global(uint32_t name, char const *iface, uint32_t v);
79 void global_remove(uint32_t name);
83 // ___ _ _| |_ _ __ _ _| |_
84 // / _ \| | | | __| '_ \| | | | __|
85 // | (_) | |_| | |_| |_) | |_| | |_
86 // \___/ \__,_|\__| .__/ \__,_|\__|
88 struct output : wayland_proxy<struct wl_output> {
89 output(struct wl_registry *registry, uint32_t name, uint32_t version);
92 void geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, int32_t subpel,
93 char const *make, char const *model, int32_t tx);
94 void mode(uint32_t flags, int32_t w, int32_t h, int32_t r);
96 void scale(int32_t factor);
100 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
101 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
102 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
103 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
106 // __ _ ___ _ __ (_)_ _(_)
107 // / _` |/ _ \ '_ \| \ \ / / |
108 // | (_| | __/ | | | |\ V /| |
109 // \__, |\___|_| |_|_| \_/ |_|
114 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
115 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
116 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
117 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
120 // _ __ ___ | |_(_)/ _|_ _
121 // | '_ \ / _ \| __| | |_| | | |
122 // | | | | (_) | |_| | _| |_| |
123 // |_| |_|\___/ \__|_|_| \__, |
127 Dimensions, // i.e. configure
140 template <typename ObjectT>
142 typedef std::function<void(enum property, ObjectT *)> ReceiverT;
144 std::vector<ReceiverT> receivers;
146 virtual ~notifier() {}
148 void add_receiver(ReceiverT);
149 void notify(enum property) const;
155 struct controlled_entity {
156 struct controller *parent;
159 controlled_entity(struct controller *c, uint32_t i) : parent(c), id(i) {}
160 virtual ~controlled_entity() {}
164 // ___ _ _ _ __ / _| __ _ ___ ___
165 // / __| | | | '__| |_ / _` |/ __/ _ \
166 // \__ \ |_| | | | _| (_| | (_| __/
167 // |___/\__,_|_| |_| \__,_|\___\___|
169 struct surface : public wayland_proxy<struct ivi_controller_surface>,
171 surface(uint32_t i, struct controller *c);
175 inline void set_visibility(uint32_t visibility) {
176 ivi_controller_surface_set_visibility(this->proxy, visibility);
179 inline void set_opacity(wl_fixed_t opacity) {
180 ivi_controller_surface_set_opacity(this->proxy, opacity);
183 inline void set_source_rectangle(int32_t x, int32_t y, int32_t width,
185 ivi_controller_surface_set_source_rectangle(this->proxy, x, y, width,
189 inline void set_destination_rectangle(int32_t x, int32_t y, int32_t width,
191 ivi_controller_surface_set_destination_rectangle(this->proxy, x, y, width,
195 inline void set_configuration(int32_t width, int32_t height) {
196 ivi_controller_surface_set_configuration(this->proxy, width, height);
199 inline void set_orientation(int32_t orientation) {
200 ivi_controller_surface_set_orientation(this->proxy, orientation);
203 inline void screenshot(const char *filename) {
204 ivi_controller_surface_screenshot(this->proxy, filename);
207 inline void send_stats() { ivi_controller_surface_send_stats(this->proxy); }
209 inline void destroy(int32_t destroy_scene_object) {
210 ivi_controller_surface_destroy(this->proxy, destroy_scene_object);
215 // | | __ _ _ _ ___ _ __
216 // | |/ _` | | | |/ _ \ '__|
217 // | | (_| | |_| | __/ |
218 // |_|\__,_|\__, |\___|_|
220 struct layer : public wayland_proxy<struct ivi_controller_layer>,
222 layer(uint32_t i, struct controller *c);
226 inline void set_visibility(uint32_t visibility) {
227 ivi_controller_layer_set_visibility(this->proxy, visibility);
230 inline void set_opacity(wl_fixed_t opacity) {
231 ivi_controller_layer_set_opacity(this->proxy, opacity);
234 inline void set_source_rectangle(int32_t x, int32_t y, int32_t width,
236 ivi_controller_layer_set_source_rectangle(this->proxy, x, y, width,
240 inline void set_destination_rectangle(int32_t x, int32_t y, int32_t width,
242 ivi_controller_layer_set_destination_rectangle(this->proxy, x, y, width,
246 inline void set_configuration(int32_t width, int32_t height) {
247 ivi_controller_layer_set_configuration(this->proxy, width, height);
250 inline void set_orientation(int32_t orientation) {
251 ivi_controller_layer_set_orientation(this->proxy, orientation);
254 inline void screenshot(const char *filename) {
255 ivi_controller_layer_screenshot(this->proxy, filename);
258 inline void clear_surfaces() {
259 ivi_controller_layer_clear_surfaces(this->proxy);
262 inline void add_surface(struct surface *surface) {
263 ivi_controller_layer_add_surface(this->proxy, surface->proxy);
266 inline void remove_surface(struct surface *surface) {
267 ivi_controller_layer_remove_surface(this->proxy, surface->proxy);
270 inline void set_render_order(struct wl_array *surfaces) {
271 ivi_controller_layer_set_render_order(this->proxy, surfaces);
276 // ___ ___ _ __ ___ ___ _ __
277 // / __|/ __| '__/ _ \/ _ \ '_ \
278 // \__ \ (__| | | __/ __/ | | |
279 // |___/\___|_| \___|\___|_| |_|
281 struct screen : public wayland_proxy<struct ivi_controller_screen>,
283 screen(uint32_t i, struct controller *c, struct ivi_controller_screen *p);
287 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
288 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
289 // | (_| (_) | | | | |_| | | (_) | | | __/ |
290 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
292 struct controller : public wayland_proxy<struct ivi_controller> {
293 std::map<uint32_t, std::unique_ptr<struct surface>> surfaces;
294 std::map<uint32_t, std::unique_ptr<struct layer>> layers;
295 std::map<uint32_t, std::unique_ptr<struct screen>> screens;
297 controller(struct wl_registry *r, uint32_t name, uint32_t version);
298 ~controller() override;
302 void screen(uint32_t id, struct ivi_controller_screen *screen);
303 void layer(uint32_t id);
304 void surface(uint32_t id);
305 void error(int32_t oid, int32_t otype, int32_t code, char const *text);
308 void surface_visibility(uint32_t id, int32_t visibility);
309 void surface_opacity(uint32_t id, float opacity);
310 void surface_source_rectangle(uint32_t id, int32_t x, int32_t y,
311 int32_t width, int32_t height);
312 void surface_destination_rectangle(uint32_t id, int32_t x, int32_t y,
313 int32_t width, int32_t height);
314 void surface_configuration(uint32_t id, int32_t width, int32_t height);
315 void surface_orientation(uint32_t id, int32_t orientation);
316 void surface_pixelformat(uint32_t id, int32_t pixelformat);
317 void surface_layer(uint32_t id, struct ivi_controller_layer *layer);
318 void surface_stats(uint32_t id, uint32_t redraw_count, uint32_t frame_count,
319 uint32_t update_count, uint32_t pid,
320 const char *process_name);
321 void surface_destroyed(uint32_t id);
322 void surface_content(uint32_t id, int32_t content_state);
325 void layer_visibility(uint32_t id, int32_t visibility);
326 void layer_opacity(uint32_t id, float opacity);
327 void layer_source_rectangle(uint32_t id, int32_t x, int32_t y, int32_t width,
329 void layer_destination_rectangle(uint32_t id, int32_t x, int32_t y,
330 int32_t width, int32_t height);
331 void layer_configuration(uint32_t id, int32_t width, int32_t height);
332 void layer_orientation(uint32_t id, int32_t orientation);
333 void layer_screen(uint32_t id, struct wl_output *screen);
334 void layer_destroyed(uint32_t id);
338 #endif // !WM_WAYLAND_HPP