2 * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "wayland.hpp"
22 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
23 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
24 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
25 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
30 // __| (_)___ _ __ | | __ _ _ _
31 // / _` | / __| '_ \| |/ _` | | | |
32 // | (_| | \__ \ |_) | | (_| | |_| |
33 // \__,_|_|___/ .__/|_|\__,_|\__, |
36 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
37 wl_display_connect(nullptr), &wl_display_disconnect)),
40 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
42 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
44 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
46 int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
48 int display::read_events() {
50 while (wl_display_prepare_read(this->d.get()) == -1) {
51 if (wl_display_dispatch_pending(this->d.get()) == -1) {
56 if (wl_display_flush(this->d.get()) == -1) {
60 if (wl_display_read_events(this->d.get()) == -1) {
61 wl_display_cancel_read(this->d.get());
67 void display::flush() { wl_display_flush(this->d.get()); }
69 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
71 int display::get_error() { return wl_display_get_error(this->d.get()); }
74 // _ __ ___ __ _(_)___| |_ _ __ _ _
75 // | '__/ _ \/ _` | / __| __| '__| | | |
76 // | | | __/ (_| | \__ \ |_| | | |_| |
77 // |_| \___|\__, |_|___/\__|_| \__, |
80 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
81 char const *iface, uint32_t v) {
82 static_cast<struct registry *>(data)->global(name, iface, v);
85 void registry_global_remove(void *data, struct wl_registry * /*r*/,
87 static_cast<struct registry *>(data)->global_remove(name);
90 constexpr struct wl_registry_listener registry_listener = {
91 registry_global, registry_global_remove};
94 registry::registry(struct wl_display *d)
95 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
96 if (this->proxy != nullptr) {
97 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
101 void registry::add_global_handler(char const *iface, binder bind) {
102 this->bindings[iface] = std::move(bind);
105 void registry::global(uint32_t name, char const *iface, uint32_t v) {
106 auto b = this->bindings.find(iface);
107 if (b != this->bindings.end()) {
108 b->second(this->proxy.get(), name, v);
110 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
114 void registry::global_remove(uint32_t /*name*/) {}
117 // ___ _ _| |_ _ __ _ _| |_
118 // / _ \| | | | __| '_ \| | | | __|
119 // | (_) | |_| | |_| |_) | |_| | |_
120 // \___/ \__,_|\__| .__/ \__,_|\__|
123 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
124 int32_t y, int32_t physical_width, int32_t physical_height,
125 int32_t subpixel, const char *make, const char *model,
127 static_cast<struct output *>(data)->geometry(
128 x, y, physical_width, physical_height, subpixel, make, model, transform);
131 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
132 int32_t width, int32_t height, int32_t refresh) {
133 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
136 void output_done(void *data, struct wl_output * /*wl_output*/) {
137 static_cast<struct output *>(data)->done();
140 void output_scale(void *data, struct wl_output * /*wl_output*/,
142 static_cast<struct output *>(data)->scale(factor);
145 constexpr struct wl_output_listener output_listener = {
146 output_geometry, output_mode, output_done, output_scale};
149 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
150 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
151 wl_output_add_listener(this->proxy.get(), &output_listener, this);
154 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
155 int32_t subpel, char const *make, char const *model,
158 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
159 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
160 this->transform = tx;
163 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
164 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__,
165 this->proxy.get(), flags, w, h, r);
166 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
173 void output::done() {
174 logdebug("wl::output %s @ %p done", __func__, this->proxy.get());
175 // Let's just disregard the flipped ones...
176 if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
177 this->transform == WL_OUTPUT_TRANSFORM_270) {
178 std::swap(this->width, this->height);
182 void output::scale(int32_t factor) {
183 logdebug("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
187 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
188 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
189 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
190 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
193 // __ _ ___ _ __ (_)_ _(_)
194 // / _` |/ _ \ '_ \| \ \ / / |
195 // | (_| | __/ | | | |\ V /| |
196 // \__, |\___|_| |_|_| \_/ |_|
201 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
202 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
203 // | (_| (_) | | | | |_| | | (_) | | | __/ |
204 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
207 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
209 struct ivi_controller_screen *screen) {
210 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
213 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
215 static_cast<struct controller *>(data)->controller_layer(id_layer);
218 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
219 uint32_t id_surface) {
220 static_cast<struct controller *>(data)->controller_surface(id_surface);
223 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
224 int32_t object_id, int32_t object_type,
225 int32_t error_code, const char *error_text) {
226 static_cast<struct controller *>(data)->controller_error(
227 object_id, object_type, error_code, error_text);
230 constexpr struct ivi_controller_listener listener = {
231 controller_screen, controller_layer, controller_surface, controller_error};
234 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
236 wl_registry_bind(r, name, &ivi_controller_interface, version)),
238 ivi_controller_add_listener(this->proxy.get(), &listener, this);
241 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
242 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
245 void controller::surface_create(uint32_t id) {
246 this->surfaces[id] = std::make_unique<struct surface>(id, this);
249 void controller::controller_screen(uint32_t id,
250 struct ivi_controller_screen *screen) {
251 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
253 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
256 void controller::controller_layer(uint32_t id) {
257 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
258 if (this->layers.find(id) != this->layers.end()) {
259 logerror("Someone created a layer without asking US! (%d)", id);
261 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
266 void controller::controller_surface(uint32_t id) {
267 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
269 if (this->surfaces.find(id) == this->surfaces.end()) {
270 this->surfaces[id] = std::make_unique<struct surface>(id, this);
271 this->chooks->surface_created(id);
275 void controller::controller_error(int32_t object_id, int32_t object_type,
276 int32_t error_code, const char *error_text) {
277 logdebug("genivi::controller @ %p error o %i t %i c %i text %s",
278 this->proxy.get(), object_id, object_type, error_code, error_text);
282 // | | __ _ _ _ ___ _ __
283 // | |/ _` | | | |/ _ \ '__|
284 // | | (_| | |_| | __/ |
285 // |_|\__,_|\__, |\___|_|
288 void layer_visibility(void *data,
289 struct ivi_controller_layer * /*ivi_controller_layer*/,
290 int32_t visibility) {
291 auto l = static_cast<struct layer *>(data);
292 l->parent->layer_visibility(l, visibility);
295 void layer_opacity(void *data,
296 struct ivi_controller_layer * /*ivi_controller_layer*/,
297 wl_fixed_t opacity) {
298 auto l = static_cast<struct layer *>(data);
299 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
302 void layer_source_rectangle(
303 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
304 int32_t x, int32_t y, int32_t width, int32_t height) {
305 auto l = static_cast<struct layer *>(data);
306 l->parent->layer_source_rectangle(l, x, y, width, height);
309 void layer_destination_rectangle(
310 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
311 int32_t x, int32_t y, int32_t width, int32_t height) {
312 auto l = static_cast<struct layer *>(data);
313 l->parent->layer_destination_rectangle(l, x, y, width, height);
316 void layer_configuration(void *data,
317 struct ivi_controller_layer * /*ivi_controller_layer*/,
318 int32_t width, int32_t height) {
319 auto l = static_cast<struct layer *>(data);
320 l->parent->layer_configuration(l, width, height);
323 void layer_orientation(void *data,
324 struct ivi_controller_layer * /*ivi_controller_layer*/,
325 int32_t orientation) {
326 auto l = static_cast<struct layer *>(data);
327 l->parent->layer_orientation(l, orientation);
330 void layer_screen(void *data,
331 struct ivi_controller_layer * /*ivi_controller_layer*/,
332 struct wl_output *screen) {
333 auto l = static_cast<struct layer *>(data);
334 l->parent->layer_screen(l, screen);
337 void layer_destroyed(void *data,
338 struct ivi_controller_layer * /*ivi_controller_layer*/) {
339 auto l = static_cast<struct layer *>(data);
340 l->parent->layer_destroyed(l);
343 constexpr struct ivi_controller_layer_listener layer_listener = {
344 layer_visibility, layer_opacity,
345 layer_source_rectangle, layer_destination_rectangle,
346 layer_configuration, layer_orientation,
347 layer_screen, layer_destroyed,
351 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
353 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
354 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
355 [c, i](ivi_controller_layer *l) {
356 logdebug("~layer layer %i @ %p", i, l);
357 c->remove_proxy_to_id_mapping(l);
358 ivi_controller_layer_destroy(l, 1);
360 controller_child(c, i) {
361 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
362 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
365 void layer::set_visibility(uint32_t visibility) {
366 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
369 void layer::set_opacity(wl_fixed_t opacity) {
370 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
373 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
375 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
379 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
381 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
385 void layer::set_configuration(int32_t width, int32_t height) {
386 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
389 void layer::set_orientation(int32_t orientation) {
390 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
393 void layer::screenshot(const char *filename) {
394 ivi_controller_layer_screenshot(this->proxy.get(), filename);
397 void layer::clear_surfaces() {
398 ivi_controller_layer_clear_surfaces(this->proxy.get());
401 void layer::add_surface(struct surface *surface) {
402 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
405 void layer::remove_surface(struct surface *surface) {
406 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
409 void layer::set_render_order(std::vector<uint32_t> const &ro) {
410 struct wl_array wlro {
411 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
412 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
414 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
417 void controller::layer_visibility(struct layer *l, int32_t visibility) {
418 logdebug("genivi::layer %s @ %d v %i", __func__, l->id, visibility);
419 this->lprops[l->id].visibility = visibility;
422 void controller::layer_opacity(struct layer *l, float opacity) {
423 logdebug("genivi::layer %s @ %d o %f", __func__, l->id, opacity);
424 this->lprops[l->id].opacity = opacity;
427 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
428 int32_t width, int32_t height) {
429 logdebug("genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
430 l->id, x, y, width, height);
431 this->lprops[l->id].src_rect = rect{width, height, x, y};
434 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
435 int32_t y, int32_t width,
437 logdebug("genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
438 l->id, x, y, width, height);
439 this->lprops[l->id].dst_rect = rect{width, height, x, y};
442 void controller::layer_configuration(struct layer *l, int32_t width,
444 logdebug("genivi::layer %s @ %d w %i h %i", __func__, l->id,
446 this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
449 void controller::layer_orientation(struct layer *l, int32_t orientation) {
450 logdebug("genivi::layer %s @ %d o %i", __func__, l->id,
452 this->lprops[l->id].orientation = orientation;
455 void controller::layer_screen(struct layer *l, struct wl_output *screen) {
456 logdebug("genivi::layer %s @ %d s %p", __func__, l->id, screen);
459 void controller::layer_destroyed(struct layer *l) {
460 logdebug("genivi::layer %s @ %d", __func__, l->id);
461 this->lprops.erase(l->id);
462 this->layers.erase(l->id);
466 // ___ _ _ _ __ / _| __ _ ___ ___
467 // / __| | | | '__| |_ / _` |/ __/ _ \
468 // \__ \ |_| | | | _| (_| | (_| __/
469 // |___/\__,_|_| |_| \__,_|\___\___|
473 void surface_visibility(
474 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
475 int32_t visibility) {
476 auto s = static_cast<struct surface *>(data);
477 s->parent->surface_visibility(s, visibility);
480 void surface_opacity(void *data,
481 struct ivi_controller_surface * /*ivi_controller_surface*/,
482 wl_fixed_t opacity) {
483 auto s = static_cast<struct surface *>(data);
484 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
487 void surface_source_rectangle(
488 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
489 int32_t x, int32_t y, int32_t width, int32_t height) {
490 auto s = static_cast<struct surface *>(data);
491 s->parent->surface_source_rectangle(s, x, y, width, height);
494 void surface_destination_rectangle(
495 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
496 int32_t x, int32_t y, int32_t width, int32_t height) {
497 auto s = static_cast<struct surface *>(data);
498 s->parent->surface_destination_rectangle(s, x, y, width, height);
501 void surface_configuration(
502 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
503 int32_t width, int32_t height) {
504 auto s = static_cast<struct surface *>(data);
505 s->parent->surface_configuration(s, width, height);
508 void surface_orientation(
509 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
510 int32_t orientation) {
511 auto s = static_cast<struct surface *>(data);
512 s->parent->surface_orientation(s, orientation);
515 void surface_pixelformat(
516 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
517 int32_t pixelformat) {
518 auto s = static_cast<struct surface *>(data);
519 s->parent->surface_pixelformat(s, pixelformat);
522 void surface_layer(void *data,
523 struct ivi_controller_surface * /*ivi_controller_surface*/,
524 struct ivi_controller_layer *layer) {
525 auto s = static_cast<struct surface *>(data);
526 s->parent->surface_layer(s, layer);
529 void surface_stats(void *data,
530 struct ivi_controller_surface * /*ivi_controller_surface*/,
531 uint32_t redraw_count, uint32_t frame_count,
532 uint32_t update_count, uint32_t pid,
533 const char *process_name) {
534 auto s = static_cast<struct surface *>(data);
535 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
539 void surface_destroyed(
540 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
541 auto s = static_cast<struct surface *>(data);
542 s->parent->surface_destroyed(s);
545 void surface_content(void *data,
546 struct ivi_controller_surface * /*ivi_controller_surface*/,
547 int32_t content_state) {
548 auto s = static_cast<struct surface *>(data);
549 s->parent->surface_content(s, content_state);
552 constexpr struct ivi_controller_surface_listener surface_listener = {
555 surface_source_rectangle,
556 surface_destination_rectangle,
557 surface_configuration,
567 surface::surface(uint32_t i, struct controller *c)
568 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
569 [c, i](ivi_controller_surface *s) {
570 logdebug("~surface surface %i @ %d", i, s);
571 c->remove_proxy_to_id_mapping(s);
572 ivi_controller_surface_destroy(s, 1);
574 controller_child(c, i) {
575 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
576 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
580 void surface::set_visibility(uint32_t visibility) {
581 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
584 void surface::set_opacity(wl_fixed_t opacity) {
585 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
588 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
590 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
594 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
596 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
600 void surface::set_configuration(int32_t width, int32_t height) {
601 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
604 void surface::set_orientation(int32_t orientation) {
605 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
608 void surface::screenshot(const char *filename) {
609 ivi_controller_surface_screenshot(this->proxy.get(), filename);
612 void surface::send_stats() {
613 ivi_controller_surface_send_stats(this->proxy.get());
616 void surface::destroy(int32_t destroy_scene_object) {
617 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
620 void controller::surface_visibility(struct surface *s, int32_t visibility) {
621 logdebug("genivi::surface %s @ %d v %i", __func__, s->id,
623 this->sprops[s->id].visibility = visibility;
626 void controller::surface_opacity(struct surface *s, float opacity) {
627 logdebug("genivi::surface %s @ %d o %f", __func__, s->id,
629 this->sprops[s->id].opacity = opacity;
632 void controller::surface_source_rectangle(struct surface *s, int32_t x,
633 int32_t y, int32_t width,
635 logdebug("genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
636 s->id, x, y, width, height);
637 this->sprops[s->id].src_rect = rect{width, height, x, y};
640 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
641 int32_t y, int32_t width,
643 logdebug("genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
644 s->id, x, y, width, height);
645 this->sprops[s->id].dst_rect = rect{width, height, x, y};
648 void controller::surface_configuration(struct surface *s, int32_t width,
650 logdebug("genivi::surface %s @ %d w %i h %i", __func__, s->id,
652 this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
655 void controller::surface_orientation(struct surface *s, int32_t orientation) {
656 logdebug("genivi::surface %s @ %d o %i", __func__, s->id,
658 this->sprops[s->id].orientation = orientation;
661 void controller::surface_pixelformat(struct surface * s,
662 int32_t pixelformat) {
663 logdebug("genivi::surface %s @ %d f %i", __func__, s->id,
667 void controller::surface_layer(struct surface * s,
668 struct ivi_controller_layer *layer) {
669 logdebug("genivi::surface %s @ %d l %u @ %p", __func__, s->id,
670 this->layer_proxy_to_id[uintptr_t(layer)], layer);
673 void controller::surface_stats(struct surface *s, uint32_t redraw_count,
674 uint32_t frame_count, uint32_t update_count,
675 uint32_t pid, const char *process_name) {
676 logdebug("genivi::surface %s @ %d r %u f %u u %u pid %u p %s", __func__,
677 this->proxy.get(), redraw_count, frame_count, update_count, pid,
681 void controller::surface_destroyed(struct surface *s) {
682 logdebug("genivi::surface %s @ %d", __func__, s->id);
683 this->chooks->surface_removed(s->id);
684 // XXX: do I need to actually remove the surface late, i.e. using add_task()?
685 this->sprops.erase(s->id);
686 this->surfaces.erase(s->id);
689 void controller::surface_content(struct surface *s, int32_t content_state) {
690 logdebug("genivi::surface %s @ %d s %i", __func__, s->id,
692 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
693 // XXX is this the right thing to do?
694 this->chooks->surface_removed(s->id);
695 this->sprops.erase(s->id);
696 this->surfaces.erase(s->id);
700 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
702 logdebug("Add surface proxy mapping for %p (%u)", p, id);
703 this->surface_proxy_to_id[uintptr_t(p)] = id;
704 this->sprops[id].id = id;
707 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
708 logdebug("Remove surface proxy mapping for %p", p);
709 this->surface_proxy_to_id.erase(uintptr_t(p));
712 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
714 logdebug("Add layer proxy mapping for %p (%u)", p, id);
715 this->layer_proxy_to_id[uintptr_t(p)] = id;
716 this->lprops[id].id = id;
719 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
720 logdebug("Remove layer proxy mapping for %p", p);
721 this->layer_proxy_to_id.erase(uintptr_t(p));
724 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
725 logdebug("Add screen proxy mapping for %p (%u)", p, id);
726 this->screen_proxy_to_id[uintptr_t(p)] = id;
729 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
730 logdebug("Remove screen proxy mapping for %p", p);
731 this->screen_proxy_to_id.erase(uintptr_t(p));
735 // ___ ___ _ __ ___ ___ _ __
736 // / __|/ __| '__/ _ \/ _ \ '_ \
737 // \__ \ (__| | | __/ __/ | | |
738 // |___/\___|_| \___|\___|_| |_|
740 screen::screen(uint32_t i, struct controller *c,
741 struct ivi_controller_screen *p)
742 : wayland_proxy(p), controller_child(c, i) {
743 logdebug("genivi::screen @ %p id %u", p, i);
746 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
748 void screen::add_layer(layer *l) {
749 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
752 void screen::set_render_order(std::vector<uint32_t> const &ro) {
753 struct wl_array wlro {
754 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
755 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
757 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
760 } // namespace genivi