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),
23 [](struct wl_display *d) {
24 logdebug("wl::display ~display @ %p", d);
25 wl_display_disconnect(d);
28 &wl_display_disconnect)),
33 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
35 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
37 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
39 void display::flush() { wl_display_flush(this->d.get()); }
41 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
44 // _ __ ___ __ _(_)___| |_ _ __ _ _
45 // | '__/ _ \/ _` | / __| __| '__| | | |
46 // | | | __/ (_| | \__ \ |_| | | |_| |
47 // |_| \___|\__, |_|___/\__|_| \__, |
50 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
51 char const *iface, uint32_t v) {
52 static_cast<struct registry *>(data)->global(name, iface, v);
55 void registry_global_remove(void *data, struct wl_registry * /*r*/,
57 static_cast<struct registry *>(data)->global_remove(name);
60 constexpr struct wl_registry_listener registry_listener = {
61 registry_global, registry_global_remove};
64 registry::registry(struct wl_display *d)
65 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
66 if (this->proxy != nullptr) {
67 wl_registry_add_listener(this->proxy, ®istry_listener, this);
71 void registry::add_global_handler(char const *iface, binder bind) {
72 this->bindings[iface] = std::move(bind);
75 void registry::global(uint32_t name, char const *iface, uint32_t v) {
76 auto b = this->bindings.find(iface);
77 if (b != this->bindings.end()) {
78 b->second(this->proxy, name, v);
80 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy, name, iface,
84 void registry::global_remove(uint32_t /*name*/) {}
87 // ___ _ _| |_ _ __ _ _| |_
88 // / _ \| | | | __| '_ \| | | | __|
89 // | (_) | |_| | |_| |_) | |_| | |_
90 // \___/ \__,_|\__| .__/ \__,_|\__|
93 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
94 int32_t y, int32_t physical_width, int32_t physical_height,
95 int32_t subpixel, const char *make, const char *model,
97 static_cast<struct output *>(data)->geometry(
98 x, y, physical_width, physical_height, subpixel, make, model, transform);
101 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
102 int32_t width, int32_t height, int32_t refresh) {
103 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
106 void output_done(void *data, struct wl_output * /*wl_output*/) {
107 static_cast<struct output *>(data)->done();
110 void output_scale(void *data, struct wl_output * /*wl_output*/,
112 static_cast<struct output *>(data)->scale(factor);
115 constexpr struct wl_output_listener output_listener = {
116 output_geometry, output_mode, output_done, output_scale};
119 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
120 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
121 wl_output_add_listener(this->proxy, &output_listener, this);
124 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
125 int32_t subpel, char const *make, char const *model,
128 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
129 __func__, this->proxy, x, y, pw, ph, subpel, make, model, tx);
132 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
133 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__, this->proxy,
135 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
142 void output::done() {
143 logdebug("wl::output %s @ %p done", __func__, this->proxy);
146 void output::scale(int32_t factor) {
147 logdebug("wl::output %s @ %p f %i", __func__, this->proxy, factor);
151 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
152 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
153 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
154 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
157 // __ _ ___ _ __ (_)_ _(_)
158 // / _` |/ _ \ '_ \| \ \ / / |
159 // | (_| | __/ | | | |\ V /| |
160 // \__, |\___|_| |_|_| \_/ |_|
165 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
166 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
167 // | (_| (_) | | | | |_| | | (_) | | | __/ |
168 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
171 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
173 struct ivi_controller_screen *screen) {
174 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
177 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
179 static_cast<struct controller *>(data)->controller_layer(id_layer);
182 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
183 uint32_t id_surface) {
184 static_cast<struct controller *>(data)->controller_surface(id_surface);
187 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
188 int32_t object_id, int32_t object_type,
189 int32_t error_code, const char *error_text) {
190 static_cast<struct controller *>(data)->controller_error(
191 object_id, object_type, error_code, error_text);
194 constexpr struct ivi_controller_listener listener = {
195 controller_screen, controller_layer, controller_surface, controller_error};
198 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
200 wl_registry_bind(r, name, &ivi_controller_interface, version)),
201 surface_proxy_to_id{},
203 screen_proxy_to_id{},
209 ivi_controller_add_listener(this->proxy, &listener, this);
212 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
213 this->layers[id] = std::make_unique<layer>(id, w, h, this);
216 void controller::surface_create(uint32_t id) {
217 this->surfaces[id] = std::make_unique<surface>(id, this);
220 void controller::controller_screen(uint32_t id,
221 struct ivi_controller_screen *screen) {
222 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy, id, id,
224 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
227 void controller::controller_layer(uint32_t id) {
228 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy, id, id);
229 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
233 void controller::controller_surface(uint32_t id) {
234 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy, id, id);
235 this->surfaces[id] = std::make_unique<struct surface>(id, this);
237 add_task("fullscreen surface", [id](struct controller *c) {
238 auto &s = c->surfaces[id];
239 s->set_destination_rectangle(0, 0, c->output_size.w, c->output_size.h);
240 s->set_visibility(1);
241 uint32_t lid = id == 0x16180 ? 1000 : 100;
242 c->layers[lid]->add_surface(s.get());
243 logdebug("Surface %u now fullscreen on layer %u", id, lid);
247 void controller::controller_error(int32_t object_id, int32_t object_type,
248 int32_t error_code, const char *error_text) {
249 logdebug("genivi::controller @ %p error o %i t %i c %i text %s", this->proxy,
250 object_id, object_type, error_code, error_text);
254 // | | __ _ _ _ ___ _ __
255 // | |/ _` | | | |/ _ \ '__|
256 // | | (_| | |_| | __/ |
257 // |_|\__,_|\__, |\___|_|
260 void layer_visibility(void *data,
261 struct ivi_controller_layer * /*ivi_controller_layer*/,
262 int32_t visibility) {
263 auto l = static_cast<struct layer *>(data);
264 l->parent->layer_visibility(l->id, visibility);
267 void layer_opacity(void *data,
268 struct ivi_controller_layer * /*ivi_controller_layer*/,
269 wl_fixed_t opacity) {
270 auto l = static_cast<struct layer *>(data);
271 l->parent->layer_opacity(l->id, float(wl_fixed_to_double(opacity)));
274 void layer_source_rectangle(
275 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
276 int32_t x, int32_t y, int32_t width, int32_t height) {
277 auto l = static_cast<struct layer *>(data);
278 l->parent->layer_source_rectangle(l->id, x, y, width, height);
281 void layer_destination_rectangle(
282 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
283 int32_t x, int32_t y, int32_t width, int32_t height) {
284 auto l = static_cast<struct layer *>(data);
285 l->parent->layer_destination_rectangle(l->id, x, y, width, height);
288 void layer_configuration(void *data,
289 struct ivi_controller_layer * /*ivi_controller_layer*/,
290 int32_t width, int32_t height) {
291 auto l = static_cast<struct layer *>(data);
292 l->parent->layer_configuration(l->id, width, height);
295 void layer_orientation(void *data,
296 struct ivi_controller_layer * /*ivi_controller_layer*/,
297 int32_t orientation) {
298 auto l = static_cast<struct layer *>(data);
299 l->parent->layer_orientation(l->id, orientation);
302 void layer_screen(void *data,
303 struct ivi_controller_layer * /*ivi_controller_layer*/,
304 struct wl_output *screen) {
305 auto l = static_cast<struct layer *>(data);
306 l->parent->layer_screen(l->id, screen);
309 void layer_destroyed(void *data,
310 struct ivi_controller_layer * /*ivi_controller_layer*/) {
311 auto l = static_cast<struct layer *>(data);
312 l->parent->layer_destroyed(l->id);
315 constexpr struct ivi_controller_layer_listener layer_listener = {
316 layer_visibility, layer_opacity,
317 layer_source_rectangle, layer_destination_rectangle,
318 layer_configuration, layer_orientation,
319 layer_screen, layer_destroyed,
323 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
325 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
326 : wayland_proxy(ivi_controller_layer_create(c->proxy, i, w, h)),
327 controller_child(c, i),
334 this->parent->add_proxy_to_id_mapping(this->proxy, i);
335 ivi_controller_layer_add_listener(this->proxy, &layer_listener, this);
339 logdebug("%s layer %i @ %p", __func__, this->id, this->proxy);
340 this->parent->remove_proxy_to_id_mapping(this->proxy);
341 ivi_controller_layer_destroy(this->proxy, 1);
342 this->proxy = nullptr;
345 void layer::set_visibility(uint32_t visibility) {
346 ivi_controller_layer_set_visibility(this->proxy, visibility);
349 void layer::set_opacity(wl_fixed_t opacity) {
350 ivi_controller_layer_set_opacity(this->proxy, opacity);
353 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
355 ivi_controller_layer_set_source_rectangle(this->proxy, x, y, width, height);
358 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
360 ivi_controller_layer_set_destination_rectangle(this->proxy, x, y, width,
364 void layer::set_configuration(int32_t width, int32_t height) {
365 ivi_controller_layer_set_configuration(this->proxy, width, height);
368 void layer::set_orientation(int32_t orientation) {
369 ivi_controller_layer_set_orientation(this->proxy, orientation);
372 void layer::screenshot(const char *filename) {
373 ivi_controller_layer_screenshot(this->proxy, filename);
376 void layer::clear_surfaces() {
377 ivi_controller_layer_clear_surfaces(this->proxy);
380 void layer::add_surface(struct surface *surface) {
381 ivi_controller_layer_add_surface(this->proxy, surface->proxy);
384 void layer::remove_surface(struct surface *surface) {
385 ivi_controller_layer_remove_surface(this->proxy, surface->proxy);
388 void layer::set_render_order(std::vector<uint32_t> const &ro) {
389 struct wl_array wlro {
390 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
391 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
393 ivi_controller_layer_set_render_order(this->proxy, &wlro);
396 void controller::layer_visibility(uint32_t id, int32_t visibility) {
397 logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy, visibility);
398 this->layers[id]->visibility = visibility;
401 void controller::layer_opacity(uint32_t id, float opacity) {
402 logdebug("genivi::layer %s @ %p o %f", __func__, this->proxy, opacity);
403 this->layers[id]->opacity = opacity;
406 void controller::layer_source_rectangle(uint32_t id, int32_t x, int32_t y,
407 int32_t width, int32_t height) {
408 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy,
409 x, y, width, height);
410 this->layers[id]->src_rect = rect{uint32_t(width), uint32_t(height), x, y};
413 void controller::layer_destination_rectangle(uint32_t id, int32_t x, int32_t y,
414 int32_t width, int32_t height) {
415 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy,
416 x, y, width, height);
417 this->layers[id]->dst_rect = rect{uint32_t(width), uint32_t(height), x, y};
420 void controller::layer_configuration(uint32_t id, int32_t width,
422 logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy, width,
424 this->layers[id]->size = size{uint32_t(width), uint32_t(height)};
427 void controller::layer_orientation(uint32_t id, int32_t orientation) {
428 logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy, orientation);
429 this->layers[id]->orientation = orientation;
432 void controller::layer_screen(uint32_t /*id*/, struct wl_output *screen) {
433 logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy, screen);
436 void controller::layer_destroyed(uint32_t id) {
437 logdebug("genivi::layer %s @ %p", __func__, this->proxy);
438 add_task("remove layer",
439 [id](struct controller *c) { c->layers.erase(id); });
443 // ___ _ _ _ __ / _| __ _ ___ ___
444 // / __| | | | '__| |_ / _` |/ __/ _ \
445 // \__ \ |_| | | | _| (_| | (_| __/
446 // |___/\__,_|_| |_| \__,_|\___\___|
450 void surface_visibility(
451 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
452 int32_t visibility) {
453 auto s = static_cast<struct surface *>(data);
454 s->parent->surface_visibility(s->id, visibility);
457 void surface_opacity(void *data,
458 struct ivi_controller_surface * /*ivi_controller_surface*/,
459 wl_fixed_t opacity) {
460 auto s = static_cast<struct surface *>(data);
461 s->parent->surface_opacity(s->id, float(wl_fixed_to_double(opacity)));
464 void surface_source_rectangle(
465 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
466 int32_t x, int32_t y, int32_t width, int32_t height) {
467 auto s = static_cast<struct surface *>(data);
468 s->parent->surface_source_rectangle(s->id, x, y, width, height);
471 void surface_destination_rectangle(
472 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
473 int32_t x, int32_t y, int32_t width, int32_t height) {
474 auto s = static_cast<struct surface *>(data);
475 s->parent->surface_destination_rectangle(s->id, x, y, width, height);
478 void surface_configuration(
479 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
480 int32_t width, int32_t height) {
481 auto s = static_cast<struct surface *>(data);
482 s->parent->surface_configuration(s->id, width, height);
485 void surface_orientation(
486 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
487 int32_t orientation) {
488 auto s = static_cast<struct surface *>(data);
489 s->parent->surface_orientation(s->id, orientation);
492 void surface_pixelformat(
493 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
494 int32_t pixelformat) {
495 auto s = static_cast<struct surface *>(data);
496 s->parent->surface_pixelformat(s->id, pixelformat);
499 void surface_layer(void *data,
500 struct ivi_controller_surface * /*ivi_controller_surface*/,
501 struct ivi_controller_layer *layer) {
502 auto s = static_cast<struct surface *>(data);
503 s->parent->surface_layer(s->id, layer);
506 void surface_stats(void *data,
507 struct ivi_controller_surface * /*ivi_controller_surface*/,
508 uint32_t redraw_count, uint32_t frame_count,
509 uint32_t update_count, uint32_t pid,
510 const char *process_name) {
511 auto s = static_cast<struct surface *>(data);
512 s->parent->surface_stats(s->id, redraw_count, frame_count,
513 update_count, pid, process_name);
516 void surface_destroyed(
517 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
518 auto s = static_cast<struct surface *>(data);
519 s->parent->surface_destroyed(s->id);
522 void surface_content(void *data,
523 struct ivi_controller_surface * /*ivi_controller_surface*/,
524 int32_t content_state) {
525 auto s = static_cast<struct surface *>(data);
526 s->parent->surface_content(s->id, content_state);
529 constexpr struct ivi_controller_surface_listener surface_listener = {
532 surface_source_rectangle,
533 surface_destination_rectangle,
534 surface_configuration,
544 surface::surface(uint32_t i, struct controller *c)
545 : wayland_proxy(ivi_controller_surface_create(c->proxy, i)),
546 controller_child(c, i),
553 this->parent->add_proxy_to_id_mapping(this->proxy, i);
554 ivi_controller_surface_add_listener(this->proxy, &surface_listener, this);
557 surface::~surface() {
558 logdebug("%s surface %i @ %p", __func__, this->id, this->proxy);
559 this->parent->remove_proxy_to_id_mapping(this->proxy);
560 ivi_controller_surface_destroy(this->proxy, 1);
561 this->proxy = nullptr;
564 void surface::set_visibility(uint32_t visibility) {
565 ivi_controller_surface_set_visibility(this->proxy, visibility);
568 void surface::set_opacity(wl_fixed_t opacity) {
569 ivi_controller_surface_set_opacity(this->proxy, opacity);
572 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
574 ivi_controller_surface_set_source_rectangle(this->proxy, x, y, width,
578 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
580 ivi_controller_surface_set_destination_rectangle(this->proxy, x, y, width,
584 void surface::set_configuration(int32_t width, int32_t height) {
585 ivi_controller_surface_set_configuration(this->proxy, width, height);
588 void surface::set_orientation(int32_t orientation) {
589 ivi_controller_surface_set_orientation(this->proxy, orientation);
592 void surface::screenshot(const char *filename) {
593 ivi_controller_surface_screenshot(this->proxy, filename);
596 void surface::send_stats() { ivi_controller_surface_send_stats(this->proxy); }
598 void surface::destroy(int32_t destroy_scene_object) {
599 ivi_controller_surface_destroy(this->proxy, destroy_scene_object);
602 void controller::surface_visibility(uint32_t id, int32_t visibility) {
603 logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy, visibility);
604 this->surfaces[id]->visibility = visibility;
607 void controller::surface_opacity(uint32_t id, float opacity) {
608 logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy, opacity);
609 this->surfaces[id]->opacity = opacity;
612 void controller::surface_source_rectangle(uint32_t id, int32_t x, int32_t y,
613 int32_t width, int32_t height) {
614 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
615 this->proxy, x, y, width, height);
616 this->surfaces[id]->src_rect = rect{uint32_t(width), uint32_t(height), x, y};
619 void controller::surface_destination_rectangle(uint32_t id, int32_t x,
620 int32_t y, int32_t width,
622 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
623 this->proxy, x, y, width, height);
624 this->surfaces[id]->dst_rect = rect{uint32_t(width), uint32_t(height), x, y};
627 void controller::surface_configuration(uint32_t id, int32_t width,
629 logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy, width,
631 this->surfaces[id]->size = size{uint32_t(width), uint32_t(height)};
634 void controller::surface_orientation(uint32_t id, int32_t orientation) {
635 logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy, orientation);
636 this->surfaces[id]->orientation = orientation;
639 void controller::surface_pixelformat(uint32_t /*id*/, int32_t pixelformat) {
640 logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy, pixelformat);
643 void controller::surface_layer(uint32_t /*id*/,
644 struct ivi_controller_layer *layer) {
645 logdebug("genivi::surface %s @ %p l %u @ %p", __func__, this->proxy,
646 this->layer_proxy_to_id[uintptr_t(layer)], layer);
649 void controller::surface_stats(uint32_t /*id*/, uint32_t redraw_count,
650 uint32_t frame_count, uint32_t update_count,
651 uint32_t pid, const char *process_name) {
652 logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__,
653 this->proxy, redraw_count, frame_count, update_count, pid,
657 void controller::surface_destroyed(uint32_t id) {
658 logdebug("genivi::surface %s @ %p", __func__, this->proxy);
659 this->surfaces.erase(id);
662 void controller::surface_content(uint32_t id, int32_t content_state) {
663 logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy,
665 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
666 add_task("remove surface",
667 [id](struct controller *c) { c->surfaces.erase(id); });
671 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p, uint32_t id) {
672 this->surface_proxy_to_id[uintptr_t(p)] = id;
673 logdebug("Add surface proxy mapping for %p (%u)", p, id);
676 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
677 logdebug("Remove surface proxy mapping for %p", p);
678 this->surface_proxy_to_id.erase(uintptr_t(p));
681 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p, uint32_t id) {
682 logdebug("Add layer proxy mapping for %p (%u)", p, id);
683 this->layer_proxy_to_id[uintptr_t(p)] = id;
686 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
687 logdebug("Remove layer proxy mapping for %p", p);
688 this->layer_proxy_to_id.erase(uintptr_t(p));
691 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
692 logdebug("Add screen proxy mapping for %p (%u)", p, id);
693 this->screen_proxy_to_id[uintptr_t(p)] = id;
696 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
697 logdebug("Remove screen proxy mapping for %p", p);
698 this->screen_proxy_to_id.erase(uintptr_t(p));
701 void controller::add_task(char const *name, std::function<void(struct controller *)> &&f) {
702 this->pending.emplace_back(std::make_pair(name, f));
705 void controller::execute_pending() {
706 if (!this->pending.empty()) {
707 for (auto &t : this->pending) {
708 logdebug("executing task '%s'", t.first);
711 this->pending.clear();
712 ivi_controller_commit_changes(this->proxy);
713 // XXX: No flush here...
718 // ___ ___ _ __ ___ ___ _ __
719 // / __|/ __| '__/ _ \/ _ \ '_ \
720 // \__ \ (__| | | __/ __/ | | |
721 // |___/\___|_| \___|\___|_| |_|
723 screen::screen(uint32_t i, struct controller *c,
724 struct ivi_controller_screen *p)
725 : wayland_proxy(p), controller_child(c, i) {
726 logdebug("genivi::screen @ %p id %u", p, i);
729 void screen::clear() { ivi_controller_screen_clear(this->proxy); }
731 void screen::add_layer(layer *l) {
732 ivi_controller_screen_add_layer(this->proxy, l->proxy);
735 void screen::set_render_order(std::vector<uint32_t> const &ro) {
736 struct wl_array wlro {
737 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
738 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
740 ivi_controller_screen_set_render_order(this->proxy, &wlro);
743 } // namespace genivi