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"
21 #include "hmi-debug.h"
24 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
25 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
26 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
27 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
32 // __| (_)___ _ __ | | __ _ _ _
33 // / _` | / __| '_ \| |/ _` | | | |
34 // | (_| | \__ \ |_) | | (_| | |_| |
35 // \__,_|_|___/ .__/|_|\__,_|\__, |
38 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
39 wl_display_connect(nullptr), &wl_display_disconnect)),
42 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
44 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
46 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
48 int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
50 int display::read_events() {
53 while (wl_display_prepare_read(this->d.get()) == -1) {
54 STN(pending_events_dispatch);
55 if (wl_display_dispatch_pending(this->d.get()) == -1) {
60 if (wl_display_flush(this->d.get()) == -1) {
64 if (wl_display_read_events(this->d.get()) == -1) {
65 wl_display_cancel_read(this->d.get());
71 void display::flush() { wl_display_flush(this->d.get()); }
73 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
75 int display::get_error() { return wl_display_get_error(this->d.get()); }
78 // _ __ ___ __ _(_)___| |_ _ __ _ _
79 // | '__/ _ \/ _` | / __| __| '__| | | |
80 // | | | __/ (_| | \__ \ |_| | | |_| |
81 // |_| \___|\__, |_|___/\__|_| \__, |
84 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
85 char const *iface, uint32_t v) {
86 static_cast<struct registry *>(data)->global(name, iface, v);
89 void registry_global_remove(void *data, struct wl_registry * /*r*/,
91 static_cast<struct registry *>(data)->global_remove(name);
94 constexpr struct wl_registry_listener registry_listener = {
95 registry_global, registry_global_remove};
98 registry::registry(struct wl_display *d)
99 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
100 if (this->proxy != nullptr) {
101 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
105 void registry::add_global_handler(char const *iface, binder bind) {
106 this->bindings[iface] = std::move(bind);
109 void registry::global(uint32_t name, char const *iface, uint32_t v) {
110 auto b = this->bindings.find(iface);
111 if (b != this->bindings.end()) {
112 b->second(this->proxy.get(), name, v);
114 HMI_DEBUG("wm", "wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
118 void registry::global_remove(uint32_t /*name*/) {}
121 // ___ _ _| |_ _ __ _ _| |_
122 // / _ \| | | | __| '_ \| | | | __|
123 // | (_) | |_| | |_| |_) | |_| | |_
124 // \___/ \__,_|\__| .__/ \__,_|\__|
127 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
128 int32_t y, int32_t physical_width, int32_t physical_height,
129 int32_t subpixel, const char *make, const char *model,
131 static_cast<struct output *>(data)->geometry(
132 x, y, physical_width, physical_height, subpixel, make, model, transform);
135 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
136 int32_t width, int32_t height, int32_t refresh) {
137 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
140 void output_done(void *data, struct wl_output * /*wl_output*/) {
141 static_cast<struct output *>(data)->done();
144 void output_scale(void *data, struct wl_output * /*wl_output*/,
146 static_cast<struct output *>(data)->scale(factor);
149 constexpr struct wl_output_listener output_listener = {
150 output_geometry, output_mode, output_done, output_scale};
153 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
154 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
155 wl_output_add_listener(this->proxy.get(), &output_listener, this);
158 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
159 int32_t subpel, char const *make, char const *model,
162 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
163 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
164 this->transform = tx;
167 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
168 HMI_DEBUG("wm", "wl::output %s @ %p f %x w %i h %i r %i", __func__,
169 this->proxy.get(), flags, w, h, r);
170 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
177 void output::done() {
178 HMI_DEBUG("wm", "wl::output %s @ %p done", __func__, this->proxy.get());
179 // Let's just disregard the flipped ones...
180 if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
181 this->transform == WL_OUTPUT_TRANSFORM_270) {
182 std::swap(this->width, this->height);
186 void output::scale(int32_t factor) {
187 HMI_DEBUG("wm", "wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
191 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
192 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
193 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
194 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
197 // __ _ ___ _ __ (_)_ _(_)
198 // / _` |/ _ \ '_ \| \ \ / / |
199 // | (_| | __/ | | | |\ V /| |
200 // \__, |\___|_| |_|_| \_/ |_|
205 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
206 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
207 // | (_| (_) | | | | |_| | | (_) | | | __/ |
208 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
211 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
213 struct ivi_controller_screen *screen) {
214 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
217 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
219 static_cast<struct controller *>(data)->controller_layer(id_layer);
222 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
223 uint32_t id_surface) {
224 static_cast<struct controller *>(data)->controller_surface(id_surface);
227 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
228 int32_t object_id, int32_t object_type,
229 int32_t error_code, const char *error_text) {
230 static_cast<struct controller *>(data)->controller_error(
231 object_id, object_type, error_code, error_text);
234 constexpr struct ivi_controller_listener listener = {
235 controller_screen, controller_layer, controller_surface, controller_error};
238 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
240 wl_registry_bind(r, name, &ivi_controller_interface, version)),
242 ivi_controller_add_listener(this->proxy.get(), &listener, this);
245 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
246 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
249 void controller::surface_create(uint32_t id) {
250 this->surfaces[id] = std::make_unique<struct surface>(id, this);
253 void controller::controller_screen(uint32_t id,
254 struct ivi_controller_screen *screen) {
255 HMI_DEBUG("wm", "genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
257 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
260 void controller::controller_layer(uint32_t id) {
261 HMI_DEBUG("wm", "genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
262 if (this->layers.find(id) != this->layers.end()) {
263 HMI_ERROR("wm", "Someone created a layer without asking US! (%d)", id);
265 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
270 void controller::controller_surface(uint32_t id) {
271 HMI_DEBUG("wm", "genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
273 if (this->surfaces.find(id) == this->surfaces.end()) {
274 this->surfaces[id] = std::make_unique<struct surface>(id, this);
275 this->chooks->surface_created(id);
279 void controller::controller_error(int32_t object_id, int32_t object_type,
280 int32_t error_code, const char *error_text) {
281 HMI_DEBUG("wm", "genivi::controller @ %p error o %i t %i c %i text %s",
282 this->proxy.get(), object_id, object_type, error_code, error_text);
286 // | | __ _ _ _ ___ _ __
287 // | |/ _` | | | |/ _ \ '__|
288 // | | (_| | |_| | __/ |
289 // |_|\__,_|\__, |\___|_|
292 void layer_visibility(void *data,
293 struct ivi_controller_layer * /*ivi_controller_layer*/,
294 int32_t visibility) {
295 auto l = static_cast<struct layer *>(data);
296 l->parent->layer_visibility(l, visibility);
299 void layer_opacity(void *data,
300 struct ivi_controller_layer * /*ivi_controller_layer*/,
301 wl_fixed_t opacity) {
302 auto l = static_cast<struct layer *>(data);
303 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
306 void layer_source_rectangle(
307 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
308 int32_t x, int32_t y, int32_t width, int32_t height) {
309 auto l = static_cast<struct layer *>(data);
310 l->parent->layer_source_rectangle(l, x, y, width, height);
313 void layer_destination_rectangle(
314 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
315 int32_t x, int32_t y, int32_t width, int32_t height) {
316 auto l = static_cast<struct layer *>(data);
317 l->parent->layer_destination_rectangle(l, x, y, width, height);
320 void layer_configuration(void *data,
321 struct ivi_controller_layer * /*ivi_controller_layer*/,
322 int32_t width, int32_t height) {
323 auto l = static_cast<struct layer *>(data);
324 l->parent->layer_configuration(l, width, height);
327 void layer_orientation(void *data,
328 struct ivi_controller_layer * /*ivi_controller_layer*/,
329 int32_t orientation) {
330 auto l = static_cast<struct layer *>(data);
331 l->parent->layer_orientation(l, orientation);
334 void layer_screen(void *data,
335 struct ivi_controller_layer * /*ivi_controller_layer*/,
336 struct wl_output *screen) {
337 auto l = static_cast<struct layer *>(data);
338 l->parent->layer_screen(l, screen);
341 void layer_destroyed(void *data,
342 struct ivi_controller_layer * /*ivi_controller_layer*/) {
343 auto l = static_cast<struct layer *>(data);
344 l->parent->layer_destroyed(l);
347 constexpr struct ivi_controller_layer_listener layer_listener = {
348 layer_visibility, layer_opacity,
349 layer_source_rectangle, layer_destination_rectangle,
350 layer_configuration, layer_orientation,
351 layer_screen, layer_destroyed,
355 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
357 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
358 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
359 [c, i](ivi_controller_layer *l) {
360 HMI_DEBUG("wm", "~layer layer %i @ %p", i, l);
361 c->remove_proxy_to_id_mapping(l);
362 ivi_controller_layer_destroy(l, 1);
364 controller_child(c, i) {
365 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
366 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
369 void layer::set_visibility(uint32_t visibility) {
370 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
373 void layer::set_opacity(wl_fixed_t opacity) {
374 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
377 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
379 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
383 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
385 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
389 void layer::set_configuration(int32_t width, int32_t height) {
390 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
393 void layer::set_orientation(int32_t orientation) {
394 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
397 void layer::screenshot(const char *filename) {
398 ivi_controller_layer_screenshot(this->proxy.get(), filename);
401 void layer::clear_surfaces() {
402 ivi_controller_layer_clear_surfaces(this->proxy.get());
405 void layer::add_surface(struct surface *surface) {
406 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
409 void layer::remove_surface(struct surface *surface) {
410 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
413 void layer::set_render_order(std::vector<uint32_t> const &ro) {
414 struct wl_array wlro {
415 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
416 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
418 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
421 void controller::layer_visibility(struct layer *l, int32_t visibility) {
422 HMI_DEBUG("wm", "genivi::layer %s @ %d v %i", __func__, l->id, visibility);
423 this->lprops[l->id].visibility = visibility;
426 void controller::layer_opacity(struct layer *l, float opacity) {
427 HMI_DEBUG("wm", "genivi::layer %s @ %d o %f", __func__, l->id, opacity);
428 this->lprops[l->id].opacity = opacity;
431 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
432 int32_t width, int32_t height) {
433 HMI_DEBUG("wm", "genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
434 l->id, x, y, width, height);
435 this->lprops[l->id].src_rect = rect{width, height, x, y};
438 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
439 int32_t y, int32_t width,
441 HMI_DEBUG("wm", "genivi::layer %s @ %d x %i y %i w %i h %i", __func__,
442 l->id, x, y, width, height);
443 this->lprops[l->id].dst_rect = rect{width, height, x, y};
446 void controller::layer_configuration(struct layer *l, int32_t width,
448 HMI_DEBUG("wm", "genivi::layer %s @ %d w %i h %i", __func__, l->id,
450 this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
453 void controller::layer_orientation(struct layer *l, int32_t orientation) {
454 HMI_DEBUG("wm", "genivi::layer %s @ %d o %i", __func__, l->id,
456 this->lprops[l->id].orientation = orientation;
459 void controller::layer_screen(struct layer *l, struct wl_output *screen) {
460 HMI_DEBUG("wm", "genivi::layer %s @ %d s %p", __func__, l->id, screen);
463 void controller::layer_destroyed(struct layer *l) {
464 HMI_DEBUG("wm", "genivi::layer %s @ %d", __func__, l->id);
465 this->lprops.erase(l->id);
466 this->layers.erase(l->id);
470 // ___ _ _ _ __ / _| __ _ ___ ___
471 // / __| | | | '__| |_ / _` |/ __/ _ \
472 // \__ \ |_| | | | _| (_| | (_| __/
473 // |___/\__,_|_| |_| \__,_|\___\___|
477 void surface_visibility(
478 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
479 int32_t visibility) {
480 auto s = static_cast<struct surface *>(data);
481 s->parent->surface_visibility(s, visibility);
484 void surface_opacity(void *data,
485 struct ivi_controller_surface * /*ivi_controller_surface*/,
486 wl_fixed_t opacity) {
487 auto s = static_cast<struct surface *>(data);
488 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
491 void surface_source_rectangle(
492 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
493 int32_t x, int32_t y, int32_t width, int32_t height) {
494 auto s = static_cast<struct surface *>(data);
495 s->parent->surface_source_rectangle(s, x, y, width, height);
498 void surface_destination_rectangle(
499 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
500 int32_t x, int32_t y, int32_t width, int32_t height) {
501 auto s = static_cast<struct surface *>(data);
502 s->parent->surface_destination_rectangle(s, x, y, width, height);
505 void surface_configuration(
506 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
507 int32_t width, int32_t height) {
508 auto s = static_cast<struct surface *>(data);
509 s->parent->surface_configuration(s, width, height);
512 void surface_orientation(
513 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
514 int32_t orientation) {
515 auto s = static_cast<struct surface *>(data);
516 s->parent->surface_orientation(s, orientation);
519 void surface_pixelformat(
520 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
521 int32_t pixelformat) {
522 auto s = static_cast<struct surface *>(data);
523 s->parent->surface_pixelformat(s, pixelformat);
526 void surface_layer(void *data,
527 struct ivi_controller_surface * /*ivi_controller_surface*/,
528 struct ivi_controller_layer *layer) {
529 auto s = static_cast<struct surface *>(data);
530 s->parent->surface_layer(s, layer);
533 void surface_stats(void *data,
534 struct ivi_controller_surface * /*ivi_controller_surface*/,
535 uint32_t redraw_count, uint32_t frame_count,
536 uint32_t update_count, uint32_t pid,
537 const char *process_name) {
538 auto s = static_cast<struct surface *>(data);
539 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
543 void surface_destroyed(
544 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
545 auto s = static_cast<struct surface *>(data);
546 s->parent->surface_destroyed(s);
549 void surface_content(void *data,
550 struct ivi_controller_surface * /*ivi_controller_surface*/,
551 int32_t content_state) {
552 auto s = static_cast<struct surface *>(data);
553 s->parent->surface_content(s, content_state);
556 constexpr struct ivi_controller_surface_listener surface_listener = {
559 surface_source_rectangle,
560 surface_destination_rectangle,
561 surface_configuration,
571 surface::surface(uint32_t i, struct controller *c)
572 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
573 [c, i](ivi_controller_surface *s) {
574 HMI_DEBUG("wm", "~surface surface %i @ %p", i, s);
575 c->remove_proxy_to_id_mapping(s);
576 ivi_controller_surface_destroy(s, 1);
578 controller_child(c, i) {
579 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
580 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
584 void surface::set_visibility(uint32_t visibility) {
585 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
588 void surface::set_opacity(wl_fixed_t opacity) {
589 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
592 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
594 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
598 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
600 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
604 void surface::set_configuration(int32_t width, int32_t height) {
605 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
608 void surface::set_orientation(int32_t orientation) {
609 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
612 void surface::screenshot(const char *filename) {
613 ivi_controller_surface_screenshot(this->proxy.get(), filename);
616 void surface::send_stats() {
617 ivi_controller_surface_send_stats(this->proxy.get());
620 void surface::destroy(int32_t destroy_scene_object) {
621 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
624 void controller::surface_visibility(struct surface *s, int32_t visibility) {
625 HMI_DEBUG("wm", "genivi::surface %s @ %d v %i", __func__, s->id,
627 this->sprops[s->id].visibility = visibility;
628 this->chooks->surface_visibility(s->id, visibility);
631 void controller::surface_opacity(struct surface *s, float opacity) {
632 HMI_DEBUG("wm", "genivi::surface %s @ %d o %f", __func__, s->id,
634 this->sprops[s->id].opacity = opacity;
637 void controller::surface_source_rectangle(struct surface *s, int32_t x,
638 int32_t y, int32_t width,
640 HMI_DEBUG("wm", "genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
641 s->id, x, y, width, height);
642 this->sprops[s->id].src_rect = rect{width, height, x, y};
645 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
646 int32_t y, int32_t width,
648 HMI_DEBUG("wm", "genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
649 s->id, x, y, width, height);
650 this->sprops[s->id].dst_rect = rect{width, height, x, y};
651 this->chooks->surface_destination_rectangle(s->id, x, y, width, height);
654 void controller::surface_configuration(struct surface *s, int32_t width,
656 HMI_DEBUG("wm", "genivi::surface %s @ %d w %i h %i", __func__, s->id,
658 this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
659 is_configured = true;
662 void controller::surface_orientation(struct surface *s, int32_t orientation) {
663 HMI_DEBUG("wm", "genivi::surface %s @ %d o %i", __func__, s->id,
665 this->sprops[s->id].orientation = orientation;
668 void controller::surface_pixelformat(struct surface * s,
669 int32_t pixelformat) {
670 HMI_DEBUG("wm", "genivi::surface %s @ %d f %i", __func__, s->id,
674 void controller::surface_layer(struct surface * s,
675 struct ivi_controller_layer *layer) {
676 HMI_DEBUG("wm", "genivi::surface %s @ %d l %u @ %p", __func__, s->id,
677 this->layer_proxy_to_id[uintptr_t(layer)], layer);
680 void controller::surface_stats(struct surface *s, uint32_t redraw_count,
681 uint32_t frame_count, uint32_t update_count,
682 uint32_t pid, const char *process_name) {
683 HMI_DEBUG("wm", "genivi::surface %s @ %d r %u f %u u %u pid %u p %s", __func__,
684 s->id, redraw_count, frame_count, update_count, pid,
688 void controller::surface_destroyed(struct surface *s) {
689 HMI_DEBUG("wm", "genivi::surface %s @ %d", __func__, s->id);
690 this->chooks->surface_removed(s->id);
691 // XXX: do I need to actually remove the surface late, i.e. using add_task()?
692 this->sprops.erase(s->id);
693 this->surfaces.erase(s->id);
696 void controller::surface_content(struct surface *s, int32_t content_state) {
697 HMI_DEBUG("wm", "genivi::surface %s @ %d s %i", __func__, s->id,
699 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
700 // XXX is this the right thing to do?
701 this->chooks->surface_removed(s->id);
702 this->sprops.erase(s->id);
703 this->surfaces.erase(s->id);
707 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
709 HMI_DEBUG("wm", "Add surface proxy mapping for %p (%u)", p, id);
710 this->surface_proxy_to_id[uintptr_t(p)] = id;
711 this->sprops[id].id = id;
714 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
715 HMI_DEBUG("wm", "Remove surface proxy mapping for %p", p);
716 this->surface_proxy_to_id.erase(uintptr_t(p));
719 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
721 HMI_DEBUG("wm", "Add layer proxy mapping for %p (%u)", p, id);
722 this->layer_proxy_to_id[uintptr_t(p)] = id;
723 this->lprops[id].id = id;
726 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
727 HMI_DEBUG("wm", "Remove layer proxy mapping for %p", p);
728 this->layer_proxy_to_id.erase(uintptr_t(p));
731 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
732 HMI_DEBUG("wm", "Add screen proxy mapping for %p (%u)", p, id);
733 this->screen_proxy_to_id[uintptr_t(p)] = id;
736 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
737 HMI_DEBUG("wm", "Remove screen proxy mapping for %p", p);
738 this->screen_proxy_to_id.erase(uintptr_t(p));
742 // ___ ___ _ __ ___ ___ _ __
743 // / __|/ __| '__/ _ \/ _ \ '_ \
744 // \__ \ (__| | | __/ __/ | | |
745 // |___/\___|_| \___|\___|_| |_|
747 screen::screen(uint32_t i, struct controller *c,
748 struct ivi_controller_screen *p)
749 : wayland_proxy(p), controller_child(c, i) {
750 HMI_DEBUG("wm", "genivi::screen @ %p id %u", p, i);
753 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
755 void screen::add_layer(layer *l) {
756 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
759 void screen::set_render_order(std::vector<uint32_t> const &ro) {
760 struct wl_array wlro {
761 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
762 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
764 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
767 } // namespace genivi