6 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
7 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
8 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
9 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
14 // __| (_)___ _ __ | | __ _ _ _
15 // / _` | / __| '_ \| |/ _` | | | |
16 // | (_| | \__ \ |_) | | (_| | |_| |
17 // \__,_|_|___/ .__/|_|\__,_|\__, |
20 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
21 wl_display_connect(nullptr), &wl_display_disconnect)),
24 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
26 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
28 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
30 void display::flush() { wl_display_flush(this->d.get()); }
32 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
34 int display::get_error() { return wl_display_get_error(this->d.get()); }
37 // _ __ ___ __ _(_)___| |_ _ __ _ _
38 // | '__/ _ \/ _` | / __| __| '__| | | |
39 // | | | __/ (_| | \__ \ |_| | | |_| |
40 // |_| \___|\__, |_|___/\__|_| \__, |
43 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
44 char const *iface, uint32_t v) {
45 static_cast<struct registry *>(data)->global(name, iface, v);
48 void registry_global_remove(void *data, struct wl_registry * /*r*/,
50 static_cast<struct registry *>(data)->global_remove(name);
53 constexpr struct wl_registry_listener registry_listener = {
54 registry_global, registry_global_remove};
57 registry::registry(struct wl_display *d)
58 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
59 if (this->proxy != nullptr) {
60 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
64 void registry::add_global_handler(char const *iface, binder bind) {
65 this->bindings[iface] = std::move(bind);
68 void registry::global(uint32_t name, char const *iface, uint32_t v) {
69 auto b = this->bindings.find(iface);
70 if (b != this->bindings.end()) {
71 b->second(this->proxy.get(), name, v);
73 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
77 void registry::global_remove(uint32_t /*name*/) {}
80 // ___ _ _| |_ _ __ _ _| |_
81 // / _ \| | | | __| '_ \| | | | __|
82 // | (_) | |_| | |_| |_) | |_| | |_
83 // \___/ \__,_|\__| .__/ \__,_|\__|
86 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
87 int32_t y, int32_t physical_width, int32_t physical_height,
88 int32_t subpixel, const char *make, const char *model,
90 static_cast<struct output *>(data)->geometry(
91 x, y, physical_width, physical_height, subpixel, make, model, transform);
94 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
95 int32_t width, int32_t height, int32_t refresh) {
96 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
99 void output_done(void *data, struct wl_output * /*wl_output*/) {
100 static_cast<struct output *>(data)->done();
103 void output_scale(void *data, struct wl_output * /*wl_output*/,
105 static_cast<struct output *>(data)->scale(factor);
108 constexpr struct wl_output_listener output_listener = {
109 output_geometry, output_mode, output_done, output_scale};
112 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
113 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
114 wl_output_add_listener(this->proxy.get(), &output_listener, this);
117 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
118 int32_t subpel, char const *make, char const *model,
121 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
122 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
125 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
126 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__,
127 this->proxy.get(), flags, w, h, r);
128 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
135 void output::done() {
136 logdebug("wl::output %s @ %p done", __func__, this->proxy.get());
139 void output::scale(int32_t factor) {
140 logdebug("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
144 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
145 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
146 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
147 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
150 // __ _ ___ _ __ (_)_ _(_)
151 // / _` |/ _ \ '_ \| \ \ / / |
152 // | (_| | __/ | | | |\ V /| |
153 // \__, |\___|_| |_|_| \_/ |_|
158 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
159 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
160 // | (_| (_) | | | | |_| | | (_) | | | __/ |
161 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
164 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
166 struct ivi_controller_screen *screen) {
167 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
170 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
172 static_cast<struct controller *>(data)->controller_layer(id_layer);
175 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
176 uint32_t id_surface) {
177 static_cast<struct controller *>(data)->controller_surface(id_surface);
180 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
181 int32_t object_id, int32_t object_type,
182 int32_t error_code, const char *error_text) {
183 static_cast<struct controller *>(data)->controller_error(
184 object_id, object_type, error_code, error_text);
187 constexpr struct ivi_controller_listener listener = {
188 controller_screen, controller_layer, controller_surface, controller_error};
191 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
193 wl_registry_bind(r, name, &ivi_controller_interface, version)),
195 ivi_controller_add_listener(this->proxy.get(), &listener, this);
198 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
199 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
202 void controller::surface_create(uint32_t id) {
203 this->surfaces[id] = std::make_unique<struct surface>(id, this);
206 void controller::controller_screen(uint32_t id,
207 struct ivi_controller_screen *screen) {
208 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
210 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
213 void controller::controller_layer(uint32_t id) {
214 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
215 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
219 void controller::controller_surface(uint32_t id) {
220 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
222 this->surfaces[id] = std::make_unique<struct surface>(id, this);
223 this->chooks->surface_created(id);
226 void controller::controller_error(int32_t object_id, int32_t object_type,
227 int32_t error_code, const char *error_text) {
228 logdebug("genivi::controller @ %p error o %i t %i c %i text %s",
229 this->proxy.get(), object_id, object_type, error_code, error_text);
233 // | | __ _ _ _ ___ _ __
234 // | |/ _` | | | |/ _ \ '__|
235 // | | (_| | |_| | __/ |
236 // |_|\__,_|\__, |\___|_|
239 void layer_visibility(void *data,
240 struct ivi_controller_layer * /*ivi_controller_layer*/,
241 int32_t visibility) {
242 auto l = static_cast<struct layer *>(data);
243 l->parent->layer_visibility(l, visibility);
246 void layer_opacity(void *data,
247 struct ivi_controller_layer * /*ivi_controller_layer*/,
248 wl_fixed_t opacity) {
249 auto l = static_cast<struct layer *>(data);
250 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
253 void layer_source_rectangle(
254 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
255 int32_t x, int32_t y, int32_t width, int32_t height) {
256 auto l = static_cast<struct layer *>(data);
257 l->parent->layer_source_rectangle(l, x, y, width, height);
260 void layer_destination_rectangle(
261 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
262 int32_t x, int32_t y, int32_t width, int32_t height) {
263 auto l = static_cast<struct layer *>(data);
264 l->parent->layer_destination_rectangle(l, x, y, width, height);
267 void layer_configuration(void *data,
268 struct ivi_controller_layer * /*ivi_controller_layer*/,
269 int32_t width, int32_t height) {
270 auto l = static_cast<struct layer *>(data);
271 l->parent->layer_configuration(l, width, height);
274 void layer_orientation(void *data,
275 struct ivi_controller_layer * /*ivi_controller_layer*/,
276 int32_t orientation) {
277 auto l = static_cast<struct layer *>(data);
278 l->parent->layer_orientation(l, orientation);
281 void layer_screen(void *data,
282 struct ivi_controller_layer * /*ivi_controller_layer*/,
283 struct wl_output *screen) {
284 auto l = static_cast<struct layer *>(data);
285 l->parent->layer_screen(l, screen);
288 void layer_destroyed(void *data,
289 struct ivi_controller_layer * /*ivi_controller_layer*/) {
290 auto l = static_cast<struct layer *>(data);
291 l->parent->layer_destroyed(l);
294 constexpr struct ivi_controller_layer_listener layer_listener = {
295 layer_visibility, layer_opacity,
296 layer_source_rectangle, layer_destination_rectangle,
297 layer_configuration, layer_orientation,
298 layer_screen, layer_destroyed,
302 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
304 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
305 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
306 [c, i](ivi_controller_layer *l) {
307 logdebug("~layer layer %i @ %p", i, l);
308 c->remove_proxy_to_id_mapping(l);
309 ivi_controller_layer_destroy(l, 1);
311 controller_child(c, i) {
312 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
313 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
316 void layer::set_visibility(uint32_t visibility) {
317 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
320 void layer::set_opacity(wl_fixed_t opacity) {
321 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
324 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
326 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
330 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
332 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
336 void layer::set_configuration(int32_t width, int32_t height) {
337 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
340 void layer::set_orientation(int32_t orientation) {
341 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
344 void layer::screenshot(const char *filename) {
345 ivi_controller_layer_screenshot(this->proxy.get(), filename);
348 void layer::clear_surfaces() {
349 ivi_controller_layer_clear_surfaces(this->proxy.get());
352 void layer::add_surface(struct surface *surface) {
353 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
356 void layer::remove_surface(struct surface *surface) {
357 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
360 void layer::set_render_order(std::vector<uint32_t> const &ro) {
361 struct wl_array wlro {
362 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
363 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
365 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
368 void controller::layer_visibility(struct layer *l, int32_t visibility) {
369 logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy.get(),
371 this->lprops[l->id].visibility = visibility;
374 void controller::layer_opacity(struct layer *l, float opacity) {
375 logdebug("genivi::layer %s @ %p o %f", __func__, this->proxy.get(), opacity);
376 this->lprops[l->id].opacity = opacity;
379 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
380 int32_t width, int32_t height) {
381 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
382 this->proxy.get(), x, y, width, height);
383 this->lprops[l->id].src_rect = rect{width, height, x, y};
386 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
387 int32_t y, int32_t width,
389 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
390 this->proxy.get(), x, y, width, height);
391 this->lprops[l->id].dst_rect = rect{width, height, x, y};
394 void controller::layer_configuration(struct layer *l, int32_t width,
396 logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy.get(),
398 this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
401 void controller::layer_orientation(struct layer *l, int32_t orientation) {
402 logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy.get(),
404 this->lprops[l->id].orientation = orientation;
407 void controller::layer_screen(struct layer * /*l*/, struct wl_output *screen) {
408 logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy.get(), screen);
411 void controller::layer_destroyed(struct layer *l) {
412 logdebug("genivi::layer %s @ %p", __func__, this->proxy.get());
413 add_task("remove layer", [l](struct controller *c) {
414 c->lprops.erase(l->id);
415 c->layers.erase(l->id);
420 // ___ _ _ _ __ / _| __ _ ___ ___
421 // / __| | | | '__| |_ / _` |/ __/ _ \
422 // \__ \ |_| | | | _| (_| | (_| __/
423 // |___/\__,_|_| |_| \__,_|\___\___|
427 void surface_visibility(
428 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
429 int32_t visibility) {
430 auto s = static_cast<struct surface *>(data);
431 s->parent->surface_visibility(s, visibility);
434 void surface_opacity(void *data,
435 struct ivi_controller_surface * /*ivi_controller_surface*/,
436 wl_fixed_t opacity) {
437 auto s = static_cast<struct surface *>(data);
438 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
441 void surface_source_rectangle(
442 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
443 int32_t x, int32_t y, int32_t width, int32_t height) {
444 auto s = static_cast<struct surface *>(data);
445 s->parent->surface_source_rectangle(s, x, y, width, height);
448 void surface_destination_rectangle(
449 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
450 int32_t x, int32_t y, int32_t width, int32_t height) {
451 auto s = static_cast<struct surface *>(data);
452 s->parent->surface_destination_rectangle(s, x, y, width, height);
455 void surface_configuration(
456 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
457 int32_t width, int32_t height) {
458 auto s = static_cast<struct surface *>(data);
459 s->parent->surface_configuration(s, width, height);
462 void surface_orientation(
463 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
464 int32_t orientation) {
465 auto s = static_cast<struct surface *>(data);
466 s->parent->surface_orientation(s, orientation);
469 void surface_pixelformat(
470 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
471 int32_t pixelformat) {
472 auto s = static_cast<struct surface *>(data);
473 s->parent->surface_pixelformat(s, pixelformat);
476 void surface_layer(void *data,
477 struct ivi_controller_surface * /*ivi_controller_surface*/,
478 struct ivi_controller_layer *layer) {
479 auto s = static_cast<struct surface *>(data);
480 s->parent->surface_layer(s, layer);
483 void surface_stats(void *data,
484 struct ivi_controller_surface * /*ivi_controller_surface*/,
485 uint32_t redraw_count, uint32_t frame_count,
486 uint32_t update_count, uint32_t pid,
487 const char *process_name) {
488 auto s = static_cast<struct surface *>(data);
489 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
493 void surface_destroyed(
494 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
495 auto s = static_cast<struct surface *>(data);
496 s->parent->surface_destroyed(s);
499 void surface_content(void *data,
500 struct ivi_controller_surface * /*ivi_controller_surface*/,
501 int32_t content_state) {
502 auto s = static_cast<struct surface *>(data);
503 s->parent->surface_content(s, content_state);
506 constexpr struct ivi_controller_surface_listener surface_listener = {
509 surface_source_rectangle,
510 surface_destination_rectangle,
511 surface_configuration,
521 surface::surface(uint32_t i, struct controller *c)
522 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
523 [c, i](ivi_controller_surface *s) {
524 logdebug("~surface surface %i @ %p", i, s);
525 c->remove_proxy_to_id_mapping(s);
526 ivi_controller_surface_destroy(s, 1);
528 controller_child(c, i) {
529 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
530 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
534 void surface::set_visibility(uint32_t visibility) {
535 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
538 void surface::set_opacity(wl_fixed_t opacity) {
539 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
542 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
544 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
548 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
550 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
554 void surface::set_configuration(int32_t width, int32_t height) {
555 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
558 void surface::set_orientation(int32_t orientation) {
559 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
562 void surface::screenshot(const char *filename) {
563 ivi_controller_surface_screenshot(this->proxy.get(), filename);
566 void surface::send_stats() {
567 ivi_controller_surface_send_stats(this->proxy.get());
570 void surface::destroy(int32_t destroy_scene_object) {
571 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
574 void controller::surface_visibility(struct surface *s, int32_t visibility) {
575 logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy.get(),
577 this->sprops[s->id].visibility = visibility;
580 void controller::surface_opacity(struct surface *s, float opacity) {
581 logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy.get(),
583 this->sprops[s->id].opacity = opacity;
586 void controller::surface_source_rectangle(struct surface *s, int32_t x,
587 int32_t y, int32_t width,
589 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
590 this->proxy.get(), x, y, width, height);
591 this->sprops[s->id].src_rect = rect{width, height, x, y};
594 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
595 int32_t y, int32_t width,
597 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
598 this->proxy.get(), x, y, width, height);
599 this->sprops[s->id].dst_rect = rect{width, height, x, y};
602 void controller::surface_configuration(struct surface *s, int32_t width,
604 logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy.get(),
606 this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
609 void controller::surface_orientation(struct surface *s, int32_t orientation) {
610 logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy.get(),
612 this->sprops[s->id].orientation = orientation;
615 void controller::surface_pixelformat(struct surface * /*s*/,
616 int32_t pixelformat) {
617 logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy.get(),
621 void controller::surface_layer(struct surface * /*s*/,
622 struct ivi_controller_layer *layer) {
623 logdebug("genivi::surface %s @ %p l %u @ %p", __func__, this->proxy.get(),
624 this->layer_proxy_to_id[uintptr_t(layer)], layer);
627 void controller::surface_stats(struct surface * /*s*/, uint32_t redraw_count,
628 uint32_t frame_count, uint32_t update_count,
629 uint32_t pid, const char *process_name) {
630 logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__,
631 this->proxy.get(), redraw_count, frame_count, update_count, pid,
635 void controller::surface_destroyed(struct surface *s) {
636 logdebug("genivi::surface %s @ %p", __func__, this->proxy.get());
637 this->chooks->surface_removed(s->id);
638 // XXX: do I need to actually remove the surface late, i.e. using add_task()?
639 this->sprops.erase(s->id);
640 this->surfaces.erase(s->id);
643 void controller::surface_content(struct surface *s, int32_t content_state) {
644 logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy.get(),
646 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
647 // XXX is this the right thing to do?
648 this->chooks->surface_removed(s->id);
649 add_task("remove surface", [s](struct controller *c) {
650 c->sprops.erase(s->id);
651 c->surfaces.erase(s->id);
656 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
658 logdebug("Add surface proxy mapping for %p (%u)", p, id);
659 this->surface_proxy_to_id[uintptr_t(p)] = id;
660 this->sprops[id].id = id;
663 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
664 logdebug("Remove surface proxy mapping for %p", p);
665 this->surface_proxy_to_id.erase(uintptr_t(p));
668 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
670 logdebug("Add layer proxy mapping for %p (%u)", p, id);
671 this->layer_proxy_to_id[uintptr_t(p)] = id;
672 this->lprops[id].id = id;
675 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
676 logdebug("Remove layer proxy mapping for %p", p);
677 this->layer_proxy_to_id.erase(uintptr_t(p));
680 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
681 logdebug("Add screen proxy mapping for %p (%u)", p, id);
682 this->screen_proxy_to_id[uintptr_t(p)] = id;
685 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
686 logdebug("Remove screen proxy mapping for %p", p);
687 this->screen_proxy_to_id.erase(uintptr_t(p));
690 void controller::add_task(char const *name,
691 std::function<void(struct controller *)> &&f) {
692 this->pending.emplace_back(std::make_pair(name, f));
695 void controller::execute_pending() {
696 if (!this->pending.empty()) {
697 for (auto &t : this->pending) {
698 logdebug("executing task '%s'", t.first);
701 this->pending.clear();
702 ivi_controller_commit_changes(this->proxy.get());
703 // XXX: No flush here...
708 // ___ ___ _ __ ___ ___ _ __
709 // / __|/ __| '__/ _ \/ _ \ '_ \
710 // \__ \ (__| | | __/ __/ | | |
711 // |___/\___|_| \___|\___|_| |_|
713 screen::screen(uint32_t i, struct controller *c,
714 struct ivi_controller_screen *p)
715 : wayland_proxy(p), controller_child(c, i) {
716 logdebug("genivi::screen @ %p id %u", p, i);
719 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
721 void screen::add_layer(layer *l) {
722 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
725 void screen::set_render_order(std::vector<uint32_t> const &ro) {
726 struct wl_array wlro {
727 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
728 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
730 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
733 } // namespace genivi