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.
20 #include "wayland.hpp"
23 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
24 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
25 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
26 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
31 // __| (_)___ _ __ | | __ _ _ _
32 // / _` | / __| '_ \| |/ _` | | | |
33 // | (_| | \__ \ |_) | | (_| | |_| |
34 // \__,_|_|___/ .__/|_|\__,_|\__, |
37 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
38 wl_display_connect(nullptr), &wl_display_disconnect)),
41 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
43 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
45 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
47 int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
49 int display::read_events() {
52 while (wl_display_prepare_read(this->d.get()) == -1) {
53 STN(pending_events_dispatch);
54 if (wl_display_dispatch_pending(this->d.get()) == -1) {
59 if (wl_display_flush(this->d.get()) == -1) {
63 if (wl_display_read_events(this->d.get()) == -1) {
64 wl_display_cancel_read(this->d.get());
70 void display::flush() { wl_display_flush(this->d.get()); }
72 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
74 int display::get_error() { return wl_display_get_error(this->d.get()); }
77 // _ __ ___ __ _(_)___| |_ _ __ _ _
78 // | '__/ _ \/ _` | / __| __| '__| | | |
79 // | | | __/ (_| | \__ \ |_| | | |_| |
80 // |_| \___|\__, |_|___/\__|_| \__, |
83 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
84 char const *iface, uint32_t v) {
85 static_cast<struct registry *>(data)->global(name, iface, v);
88 void registry_global_remove(void *data, struct wl_registry * /*r*/,
90 static_cast<struct registry *>(data)->global_remove(name);
93 constexpr struct wl_registry_listener registry_listener = {
94 registry_global, registry_global_remove};
97 registry::registry(struct wl_display *d)
98 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
99 if (this->proxy != nullptr) {
100 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
104 void registry::add_global_handler(char const *iface, binder bind) {
105 this->bindings[iface] = std::move(bind);
108 void registry::global(uint32_t name, char const *iface, uint32_t v) {
109 auto b = this->bindings.find(iface);
110 if (b != this->bindings.end()) {
111 b->second(this->proxy.get(), name, v);
113 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
117 void registry::global_remove(uint32_t /*name*/) {}
120 // ___ _ _| |_ _ __ _ _| |_
121 // / _ \| | | | __| '_ \| | | | __|
122 // | (_) | |_| | |_| |_) | |_| | |_
123 // \___/ \__,_|\__| .__/ \__,_|\__|
126 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
127 int32_t y, int32_t physical_width, int32_t physical_height,
128 int32_t subpixel, const char *make, const char *model,
130 static_cast<struct output *>(data)->geometry(
131 x, y, physical_width, physical_height, subpixel, make, model, transform);
134 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
135 int32_t width, int32_t height, int32_t refresh) {
136 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
139 void output_done(void *data, struct wl_output * /*wl_output*/) {
140 static_cast<struct output *>(data)->done();
143 void output_scale(void *data, struct wl_output * /*wl_output*/,
145 static_cast<struct output *>(data)->scale(factor);
148 constexpr struct wl_output_listener output_listener = {
149 output_geometry, output_mode, output_done, output_scale};
152 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
153 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
154 wl_output_add_listener(this->proxy.get(), &output_listener, this);
157 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
158 int32_t subpel, char const *make, char const *model,
161 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
162 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
163 this->transform = tx;
166 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
167 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__,
168 this->proxy.get(), flags, w, h, r);
169 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
176 void output::done() {
177 logdebug("wl::output %s @ %p done", __func__, this->proxy.get());
178 // Let's just disregard the flipped ones...
179 if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
180 this->transform == WL_OUTPUT_TRANSFORM_270) {
181 std::swap(this->width, this->height);
185 void output::scale(int32_t factor) {
186 logdebug("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
190 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
191 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
192 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
193 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
196 // __ _ ___ _ __ (_)_ _(_)
197 // / _` |/ _ \ '_ \| \ \ / / |
198 // | (_| | __/ | | | |\ V /| |
199 // \__, |\___|_| |_|_| \_/ |_|
204 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
205 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
206 // | (_| (_) | | | | |_| | | (_) | | | __/ |
207 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
210 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
212 struct ivi_controller_screen *screen) {
213 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
216 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
218 static_cast<struct controller *>(data)->controller_layer(id_layer);
221 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
222 uint32_t id_surface) {
223 static_cast<struct controller *>(data)->controller_surface(id_surface);
226 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
227 int32_t object_id, int32_t object_type,
228 int32_t error_code, const char *error_text) {
229 static_cast<struct controller *>(data)->controller_error(
230 object_id, object_type, error_code, error_text);
233 constexpr struct ivi_controller_listener listener = {
234 controller_screen, controller_layer, controller_surface, controller_error};
237 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
239 wl_registry_bind(r, name, &ivi_controller_interface, version)),
241 ivi_controller_add_listener(this->proxy.get(), &listener, this);
244 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
245 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
248 void controller::surface_create(uint32_t id) {
249 this->surfaces[id] = std::make_unique<struct surface>(id, this);
252 void controller::controller_screen(uint32_t id,
253 struct ivi_controller_screen *screen) {
254 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
256 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
259 void controller::controller_layer(uint32_t id) {
260 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
261 if (this->layers.find(id) != this->layers.end()) {
262 logerror("Someone created a layer without asking US! (%d)", id);
264 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
269 void controller::controller_surface(uint32_t id) {
270 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
272 if (this->surfaces.find(id) == this->surfaces.end()) {
273 this->surfaces[id] = std::make_unique<struct surface>(id, this);
274 this->chooks->surface_created(id);
278 void controller::controller_error(int32_t object_id, int32_t object_type,
279 int32_t error_code, const char *error_text) {
280 logdebug("genivi::controller @ %p error o %i t %i c %i text %s",
281 this->proxy.get(), object_id, object_type, error_code, error_text);
285 // | | __ _ _ _ ___ _ __
286 // | |/ _` | | | |/ _ \ '__|
287 // | | (_| | |_| | __/ |
288 // |_|\__,_|\__, |\___|_|
291 void layer_visibility(void *data,
292 struct ivi_controller_layer * /*ivi_controller_layer*/,
293 int32_t visibility) {
294 auto l = static_cast<struct layer *>(data);
295 l->parent->layer_visibility(l, visibility);
298 void layer_opacity(void *data,
299 struct ivi_controller_layer * /*ivi_controller_layer*/,
300 wl_fixed_t opacity) {
301 auto l = static_cast<struct layer *>(data);
302 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
305 void layer_source_rectangle(
306 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
307 int32_t x, int32_t y, int32_t width, int32_t height) {
308 auto l = static_cast<struct layer *>(data);
309 l->parent->layer_source_rectangle(l, x, y, width, height);
312 void layer_destination_rectangle(
313 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
314 int32_t x, int32_t y, int32_t width, int32_t height) {
315 auto l = static_cast<struct layer *>(data);
316 l->parent->layer_destination_rectangle(l, x, y, width, height);
319 void layer_configuration(void *data,
320 struct ivi_controller_layer * /*ivi_controller_layer*/,
321 int32_t width, int32_t height) {
322 auto l = static_cast<struct layer *>(data);
323 l->parent->layer_configuration(l, width, height);
326 void layer_orientation(void *data,
327 struct ivi_controller_layer * /*ivi_controller_layer*/,
328 int32_t orientation) {
329 auto l = static_cast<struct layer *>(data);
330 l->parent->layer_orientation(l, orientation);
333 void layer_screen(void *data,
334 struct ivi_controller_layer * /*ivi_controller_layer*/,
335 struct wl_output *screen) {
336 auto l = static_cast<struct layer *>(data);
337 l->parent->layer_screen(l, screen);
340 void layer_destroyed(void *data,
341 struct ivi_controller_layer * /*ivi_controller_layer*/) {
342 auto l = static_cast<struct layer *>(data);
343 l->parent->layer_destroyed(l);
346 constexpr struct ivi_controller_layer_listener layer_listener = {
347 layer_visibility, layer_opacity,
348 layer_source_rectangle, layer_destination_rectangle,
349 layer_configuration, layer_orientation,
350 layer_screen, layer_destroyed,
354 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
356 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
357 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
358 [c, i](ivi_controller_layer *l) {
359 logdebug("~layer layer %i @ %p", i, l);
360 c->remove_proxy_to_id_mapping(l);
361 ivi_controller_layer_destroy(l, 1);
363 controller_child(c, i) {
364 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
365 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
368 void layer::set_visibility(uint32_t visibility) {
369 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
372 void layer::set_opacity(wl_fixed_t opacity) {
373 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
376 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
378 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
382 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
384 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
388 void layer::set_configuration(int32_t width, int32_t height) {
389 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
392 void layer::set_orientation(int32_t orientation) {
393 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
396 void layer::screenshot(const char *filename) {
397 ivi_controller_layer_screenshot(this->proxy.get(), filename);
400 void layer::clear_surfaces() {
401 ivi_controller_layer_clear_surfaces(this->proxy.get());
404 void layer::add_surface(struct surface *surface) {
405 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
408 void layer::remove_surface(struct surface *surface) {
409 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
412 void layer::set_render_order(std::vector<uint32_t> const &ro) {
413 struct wl_array wlro {
414 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
415 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
417 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
420 void controller::layer_visibility(struct layer *l, int32_t visibility) {
421 logdebug("genivi::layer %s @ %d v %i", __func__, l->id, visibility);
422 this->lprops[l->id].visibility = visibility;
425 void controller::layer_opacity(struct layer *l, float opacity) {
426 logdebug("genivi::layer %s @ %d o %f", __func__, l->id, opacity);
427 this->lprops[l->id].opacity = opacity;
430 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
431 int32_t width, int32_t height) {
432 logdebug("genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
433 l->id, x, y, width, height);
434 this->lprops[l->id].src_rect = rect{width, height, x, y};
437 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
438 int32_t y, int32_t width,
440 logdebug("genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
441 l->id, x, y, width, height);
442 this->lprops[l->id].dst_rect = rect{width, height, x, y};
445 void controller::layer_configuration(struct layer *l, int32_t width,
447 logdebug("genivi::layer %s @ %d w %i h %i", __func__, l->id,
449 this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
452 void controller::layer_orientation(struct layer *l, int32_t orientation) {
453 logdebug("genivi::layer %s @ %d o %i", __func__, l->id,
455 this->lprops[l->id].orientation = orientation;
458 void controller::layer_screen(struct layer *l, struct wl_output *screen) {
459 logdebug("genivi::layer %s @ %d s %p", __func__, l->id, screen);
462 void controller::layer_destroyed(struct layer *l) {
463 logdebug("genivi::layer %s @ %d", __func__, l->id);
464 this->lprops.erase(l->id);
465 this->layers.erase(l->id);
469 // ___ _ _ _ __ / _| __ _ ___ ___
470 // / __| | | | '__| |_ / _` |/ __/ _ \
471 // \__ \ |_| | | | _| (_| | (_| __/
472 // |___/\__,_|_| |_| \__,_|\___\___|
476 void surface_visibility(
477 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
478 int32_t visibility) {
479 auto s = static_cast<struct surface *>(data);
480 s->parent->surface_visibility(s, visibility);
483 void surface_opacity(void *data,
484 struct ivi_controller_surface * /*ivi_controller_surface*/,
485 wl_fixed_t opacity) {
486 auto s = static_cast<struct surface *>(data);
487 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
490 void surface_source_rectangle(
491 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
492 int32_t x, int32_t y, int32_t width, int32_t height) {
493 auto s = static_cast<struct surface *>(data);
494 s->parent->surface_source_rectangle(s, x, y, width, height);
497 void surface_destination_rectangle(
498 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
499 int32_t x, int32_t y, int32_t width, int32_t height) {
500 auto s = static_cast<struct surface *>(data);
501 s->parent->surface_destination_rectangle(s, x, y, width, height);
504 void surface_configuration(
505 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
506 int32_t width, int32_t height) {
507 auto s = static_cast<struct surface *>(data);
508 s->parent->surface_configuration(s, width, height);
511 void surface_orientation(
512 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
513 int32_t orientation) {
514 auto s = static_cast<struct surface *>(data);
515 s->parent->surface_orientation(s, orientation);
518 void surface_pixelformat(
519 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
520 int32_t pixelformat) {
521 auto s = static_cast<struct surface *>(data);
522 s->parent->surface_pixelformat(s, pixelformat);
525 void surface_layer(void *data,
526 struct ivi_controller_surface * /*ivi_controller_surface*/,
527 struct ivi_controller_layer *layer) {
528 auto s = static_cast<struct surface *>(data);
529 s->parent->surface_layer(s, layer);
532 void surface_stats(void *data,
533 struct ivi_controller_surface * /*ivi_controller_surface*/,
534 uint32_t redraw_count, uint32_t frame_count,
535 uint32_t update_count, uint32_t pid,
536 const char *process_name) {
537 auto s = static_cast<struct surface *>(data);
538 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
542 void surface_destroyed(
543 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
544 auto s = static_cast<struct surface *>(data);
545 s->parent->surface_destroyed(s);
548 void surface_content(void *data,
549 struct ivi_controller_surface * /*ivi_controller_surface*/,
550 int32_t content_state) {
551 auto s = static_cast<struct surface *>(data);
552 s->parent->surface_content(s, content_state);
555 constexpr struct ivi_controller_surface_listener surface_listener = {
558 surface_source_rectangle,
559 surface_destination_rectangle,
560 surface_configuration,
570 surface::surface(uint32_t i, struct controller *c)
571 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
572 [c, i](ivi_controller_surface *s) {
573 logdebug("~surface surface %i @ %p", i, s);
574 c->remove_proxy_to_id_mapping(s);
575 ivi_controller_surface_destroy(s, 1);
577 controller_child(c, i) {
578 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
579 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
583 void surface::set_visibility(uint32_t visibility) {
584 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
587 void surface::set_opacity(wl_fixed_t opacity) {
588 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
591 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
593 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
597 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
599 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
603 void surface::set_configuration(int32_t width, int32_t height) {
604 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
607 void surface::set_orientation(int32_t orientation) {
608 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
611 void surface::screenshot(const char *filename) {
612 ivi_controller_surface_screenshot(this->proxy.get(), filename);
615 void surface::send_stats() {
616 ivi_controller_surface_send_stats(this->proxy.get());
619 void surface::destroy(int32_t destroy_scene_object) {
620 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
623 void controller::surface_visibility(struct surface *s, int32_t visibility) {
624 logdebug("genivi::surface %s @ %d v %i", __func__, s->id,
626 this->sprops[s->id].visibility = visibility;
627 this->chooks->surface_visibility(s->id, visibility);
630 void controller::surface_opacity(struct surface *s, float opacity) {
631 logdebug("genivi::surface %s @ %d o %f", __func__, s->id,
633 this->sprops[s->id].opacity = opacity;
636 void controller::surface_source_rectangle(struct surface *s, int32_t x,
637 int32_t y, int32_t width,
639 logdebug("genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
640 s->id, x, y, width, height);
641 this->sprops[s->id].src_rect = rect{width, height, x, y};
644 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
645 int32_t y, int32_t width,
647 logdebug("genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
648 s->id, x, y, width, height);
649 this->sprops[s->id].dst_rect = rect{width, height, x, y};
650 this->chooks->surface_destination_rectangle(s->id, x, y, width, height);
653 void controller::surface_configuration(struct surface *s, int32_t width,
655 logdebug("genivi::surface %s @ %d w %i h %i", __func__, s->id,
657 this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
660 void controller::surface_orientation(struct surface *s, int32_t orientation) {
661 logdebug("genivi::surface %s @ %d o %i", __func__, s->id,
663 this->sprops[s->id].orientation = orientation;
666 void controller::surface_pixelformat(struct surface * s,
667 int32_t pixelformat) {
668 logdebug("genivi::surface %s @ %d f %i", __func__, s->id,
672 void controller::surface_layer(struct surface * s,
673 struct ivi_controller_layer *layer) {
674 logdebug("genivi::surface %s @ %d l %u @ %p", __func__, s->id,
675 this->layer_proxy_to_id[uintptr_t(layer)], layer);
678 void controller::surface_stats(struct surface *s, uint32_t redraw_count,
679 uint32_t frame_count, uint32_t update_count,
680 uint32_t pid, const char *process_name) {
681 logdebug("genivi::surface %s @ %d r %u f %u u %u pid %u p %s", __func__,
682 s->id, redraw_count, frame_count, update_count, pid,
686 void controller::surface_destroyed(struct surface *s) {
687 logdebug("genivi::surface %s @ %d", __func__, s->id);
688 this->chooks->surface_removed(s->id);
689 // XXX: do I need to actually remove the surface late, i.e. using add_task()?
690 this->sprops.erase(s->id);
691 this->surfaces.erase(s->id);
694 void controller::surface_content(struct surface *s, int32_t content_state) {
695 logdebug("genivi::surface %s @ %d s %i", __func__, s->id,
697 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
698 // XXX is this the right thing to do?
699 this->chooks->surface_removed(s->id);
700 this->sprops.erase(s->id);
701 this->surfaces.erase(s->id);
705 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
707 logdebug("Add surface proxy mapping for %p (%u)", p, id);
708 this->surface_proxy_to_id[uintptr_t(p)] = id;
709 this->sprops[id].id = id;
712 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
713 logdebug("Remove surface proxy mapping for %p", p);
714 this->surface_proxy_to_id.erase(uintptr_t(p));
717 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
719 logdebug("Add layer proxy mapping for %p (%u)", p, id);
720 this->layer_proxy_to_id[uintptr_t(p)] = id;
721 this->lprops[id].id = id;
724 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
725 logdebug("Remove layer proxy mapping for %p", p);
726 this->layer_proxy_to_id.erase(uintptr_t(p));
729 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
730 logdebug("Add screen proxy mapping for %p (%u)", p, id);
731 this->screen_proxy_to_id[uintptr_t(p)] = id;
734 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
735 logdebug("Remove screen proxy mapping for %p", p);
736 this->screen_proxy_to_id.erase(uintptr_t(p));
740 // ___ ___ _ __ ___ ___ _ __
741 // / __|/ __| '__/ _ \/ _ \ '_ \
742 // \__ \ (__| | | __/ __/ | | |
743 // |___/\___|_| \___|\___|_| |_|
745 screen::screen(uint32_t i, struct controller *c,
746 struct ivi_controller_screen *p)
747 : wayland_proxy(p), controller_child(c, i) {
748 logdebug("genivi::screen @ %p id %u", p, i);
751 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
753 void screen::add_layer(layer *l) {
754 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
757 void screen::set_render_order(std::vector<uint32_t> const &ro) {
758 struct wl_array wlro {
759 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
760 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
762 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
765 } // namespace genivi