1f3a295e7d2ed1476f2f044e6b54e2e82ea0460e
[apps/agl-service-windowmanager.git] / src / wayland_ivi_wm.cpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <utility>
18 #include "wayland_ivi_wm.hpp"
19 #include "hmi-debug.h"
20
21 /**
22  * namespace wl
23  */
24 namespace wl
25 {
26
27 /**
28  * display
29  */
30 display::display()
31     : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
32           wl_display_connect(nullptr), &wl_display_disconnect)),
33       r(d.get()) {}
34
35 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
36
37 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
38
39 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
40
41 int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
42
43 int display::read_events()
44 {
45     ST();
46     while (wl_display_prepare_read(this->d.get()) == -1)
47     {
48         STN(pending_events_dispatch);
49         if (wl_display_dispatch_pending(this->d.get()) == -1)
50         {
51             return -1;
52         }
53     }
54
55     if (wl_display_flush(this->d.get()) == -1)
56     {
57         return -1;
58     }
59
60     if (wl_display_read_events(this->d.get()) == -1)
61     {
62         wl_display_cancel_read(this->d.get());
63     }
64
65     return 0;
66 }
67
68 void display::flush() { wl_display_flush(this->d.get()); }
69
70 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
71
72 int display::get_error() { return wl_display_get_error(this->d.get()); }
73
74 /**
75  * registry
76  */
77 namespace
78 {
79 void registry_global_created(void *data, struct wl_registry * /*r*/, uint32_t name,
80                              char const *iface, uint32_t v)
81 {
82     static_cast<struct registry *>(data)->global_created(name, iface, v);
83 }
84
85 void registry_global_removed(void *data, struct wl_registry * /*r*/,
86                              uint32_t name)
87 {
88     static_cast<struct registry *>(data)->global_removed(name);
89 }
90
91 constexpr struct wl_registry_listener registry_listener = {
92     registry_global_created, registry_global_removed};
93 } // namespace
94
95 registry::registry(struct wl_display *d)
96     : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d))
97 {
98     if (this->proxy != nullptr)
99     {
100         wl_registry_add_listener(this->proxy.get(), &registry_listener, this);
101     }
102 }
103
104 void registry::add_global_handler(char const *iface, binder bind)
105 {
106     this->bindings[iface] = std::move(bind);
107 }
108
109 void registry::global_created(uint32_t name, char const *iface, uint32_t v)
110 {
111     auto b = this->bindings.find(iface);
112     if (b != this->bindings.end())
113     {
114         b->second(this->proxy.get(), name, v);
115     }
116     HMI_DEBUG("wm", "wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
117               iface, v);
118 }
119
120 void registry::global_removed(uint32_t /*name*/) {}
121
122 /**
123  * output
124  */
125 namespace
126 {
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,
130                      int32_t transform)
131 {
132     static_cast<struct output *>(data)->geometry(
133         x, y, physical_width, physical_height, subpixel, make, model, transform);
134 }
135
136 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
137                  int32_t width, int32_t height, int32_t refresh)
138 {
139     static_cast<struct output *>(data)->mode(flags, width, height, refresh);
140 }
141
142 void output_done(void *data, struct wl_output * /*wl_output*/)
143 {
144     static_cast<struct output *>(data)->done();
145 }
146
147 void output_scale(void *data, struct wl_output * /*wl_output*/,
148                   int32_t factor)
149 {
150     static_cast<struct output *>(data)->scale(factor);
151 }
152
153 constexpr struct wl_output_listener output_listener = {
154     output_geometry, output_mode, output_done, output_scale};
155 } // namespace
156
157 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
158     : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v))
159 {
160     wl_output_add_listener(this->proxy.get(), &output_listener, this);
161 }
162
163 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
164                       int32_t subpel, char const *make, char const *model,
165                       int32_t tx)
166 {
167     HMI_DEBUG("wm",
168               "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
169               __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
170     this->physical_width = pw;
171     this->physical_height = ph;
172     this->transform = tx;
173 }
174
175 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r)
176 {
177     HMI_DEBUG("wm", "wl::output %s @ %p f %x w %i h %i r %i", __func__,
178               this->proxy.get(), flags, w, h, r);
179     if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u)
180     {
181         this->width = w;
182         this->height = h;
183         this->refresh = r;
184     }
185 }
186
187 void output::done()
188 {
189     HMI_DEBUG("wm", "wl::output %s @ %p done", __func__, this->proxy.get());
190     // Pivot and flipped
191     if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
192         this->transform == WL_OUTPUT_TRANSFORM_270 ||
193         this->transform == WL_OUTPUT_TRANSFORM_FLIPPED_90 ||
194         this->transform == WL_OUTPUT_TRANSFORM_FLIPPED_270)
195     {
196         std::swap(this->width, this->height);
197         std::swap(this->physical_width, this->physical_height);
198     }
199 }
200
201 void output::scale(int32_t factor)
202 {
203     HMI_DEBUG("wm", "wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
204 }
205 } // namespace wl
206
207 /**
208  * namespace compositor
209  */
210 namespace compositor
211 {
212
213 namespace
214 {
215
216 void surface_visibility_changed(
217     void *data, struct ivi_wm * /*ivi_wm*/,
218     uint32_t surface_id, int32_t visibility)
219 {
220     auto s = static_cast<struct surface *>(data);
221     s->parent->surface_visibility_changed(s, visibility);
222 }
223
224 void surface_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
225                              uint32_t surface_id, wl_fixed_t opacity)
226 {
227     auto s = static_cast<struct surface *>(data);
228     s->parent->surface_opacity_changed(s, float(wl_fixed_to_double(opacity)));
229 }
230
231 void surface_source_rectangle_changed(
232     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
233     int32_t x, int32_t y, int32_t width, int32_t height)
234 {
235     auto s = static_cast<struct surface *>(data);
236     s->parent->surface_source_rectangle_changed(s, x, y, width, height);
237 }
238
239 void surface_destination_rectangle_changed(
240     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
241     int32_t x, int32_t y, int32_t width, int32_t height)
242 {
243     auto s = static_cast<struct surface *>(data);
244     s->parent->surface_destination_rectangle_changed(s, x, y, width, height);
245 }
246
247 void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
248                      uint32_t id_surface)
249 {
250     static_cast<struct controller *>(data)->surface_created(id_surface);
251 }
252
253 void surface_destroyed(
254     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id)
255 {
256     auto s = static_cast<struct surface *>(data);
257     s->parent->surface_destroyed(s, surface_id);
258 }
259
260 void surface_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
261                             uint32_t error_code, const char *error_text)
262 {
263     static_cast<struct controller *>(data)->surface_error_detected(
264         object_id, error_code, error_text);
265 }
266
267 void surface_size_changed(
268     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
269     int32_t width, int32_t height)
270 {
271     auto s = static_cast<struct surface *>(data);
272     s->parent->surface_size_changed(s, width, height);
273 }
274
275 void surface_stats_received(void *data, struct ivi_wm * /*ivi_wm*/,
276                             uint32_t surface_id, uint32_t frame_count, uint32_t pid)
277 {
278     auto s = static_cast<struct surface *>(data);
279     s->parent->surface_stats_received(s, surface_id, frame_count, pid);
280 }
281
282 void surface_added_to_layer(void *data, struct ivi_wm * /*ivi_wm*/,
283                             uint32_t layer_id, uint32_t surface_id)
284 {
285     auto s = static_cast<struct surface *>(data);
286     s->parent->surface_added_to_layer(s, layer_id, surface_id);
287 }
288
289 void layer_visibility_changed(void *data, struct ivi_wm * /*ivi_wm*/,
290                               uint32_t layer_id, int32_t visibility)
291 {
292     auto l = static_cast<struct layer *>(data);
293     l->parent->layer_visibility_changed(l, layer_id, visibility);
294 }
295
296 void layer_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
297                            uint32_t layer_id, wl_fixed_t opacity)
298 {
299     auto l = static_cast<struct layer *>(data);
300     l->parent->layer_opacity_changed(l, layer_id, float(wl_fixed_to_double(opacity)));
301 }
302
303 void layer_source_rectangle_changed(
304     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
305     int32_t x, int32_t y, int32_t width, int32_t height)
306 {
307     auto l = static_cast<struct layer *>(data);
308     l->parent->layer_source_rectangle_changed(l, layer_id, x, y, width, height);
309 }
310
311 void layer_destination_rectangle_changed(
312     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
313     int32_t x, int32_t y, int32_t width, int32_t height)
314 {
315     auto l = static_cast<struct layer *>(data);
316     l->parent->layer_destination_rectangle_changed(l, layer_id, x, y, width, height);
317 }
318
319 void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
320                    uint32_t id_layer)
321 {
322     static_cast<struct controller *>(data)->layer_created(id_layer);
323 }
324
325 void layer_destroyed(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id)
326 {
327     auto l = static_cast<struct layer *>(data);
328     l->parent->layer_destroyed(l, layer_id);
329 }
330
331 void layer_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
332                           uint32_t error_code, const char *error_text)
333 {
334     static_cast<struct controller *>(data)->layer_error_detected(
335         object_id, error_code, error_text);
336 }
337
338 constexpr struct ivi_wm_listener listener = {
339     surface_visibility_changed,
340     layer_visibility_changed,
341     surface_opacity_changed,
342     layer_opacity_changed,
343     surface_source_rectangle_changed,
344     layer_source_rectangle_changed,
345     surface_destination_rectangle_changed,
346     layer_destination_rectangle_changed,
347     surface_created,
348     layer_created,
349     surface_destroyed,
350     layer_destroyed,
351     surface_error_detected,
352     layer_error_detected,
353     surface_size_changed,
354     surface_stats_received,
355     surface_added_to_layer,
356 };
357
358 void screen_created(void *data, struct ivi_wm_screen *ivi_wm_screen, uint32_t id)
359 {
360     static_cast<struct screen *>(data)->screen_created((struct screen *)data, id);
361 }
362
363 void layer_added(void *data,
364                  struct ivi_wm_screen *ivi_wm_screen,
365                  uint32_t layer_id)
366 {
367     HMI_DEBUG("wm", "added layer_id:%d", layer_id);
368 }
369
370 void connector_name(void *data,
371                     struct ivi_wm_screen *ivi_wm_screen,
372                     const char *process_name)
373 {
374     HMI_DEBUG("wm", "process_name:%s", process_name);
375 }
376
377 void screen_error(void *data,
378                   struct ivi_wm_screen *ivi_wm_screen,
379                   uint32_t error,
380                   const char *message)
381 {
382     HMI_DEBUG("wm", "screen error:%d message:%s", error, message);
383 }
384
385 constexpr struct ivi_wm_screen_listener screen_listener = {
386     screen_created,
387     layer_added,
388     connector_name,
389     screen_error,
390 };
391 } // namespace
392
393 /**
394  * surface
395  */
396 surface::surface(uint32_t i, struct controller *c)
397     : controller_child(c, i)
398 {
399     this->parent->add_proxy_to_sid_mapping(this->parent->proxy.get(), i);
400 }
401
402 void surface::set_visibility(uint32_t visibility)
403 {
404     HMI_DEBUG("wm", "compositor::surface id:%d v:%d", this->id, visibility);
405     ivi_wm_set_surface_visibility(this->parent->proxy.get(), this->id, visibility);
406 }
407
408 void surface::set_source_rectangle(int32_t x, int32_t y,
409                                    int32_t width, int32_t height)
410 {
411     ivi_wm_set_surface_source_rectangle(this->parent->proxy.get(), this->id,
412                                         x, y, width, height);
413 }
414
415 void surface::set_destination_rectangle(int32_t x, int32_t y,
416                                         int32_t width, int32_t height)
417 {
418     ivi_wm_set_surface_destination_rectangle(this->parent->proxy.get(), this->id,
419                                              x, y, width, height);
420 }
421
422 /**
423  * layer
424  */
425 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
426
427 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
428     : controller_child(c, i)
429 {
430     this->parent->add_proxy_to_lid_mapping(this->parent->proxy.get(), i);
431     ivi_wm_create_layout_layer(c->proxy.get(), i, w, h);
432 }
433
434 void layer::set_visibility(uint32_t visibility)
435 {
436     ivi_wm_set_layer_visibility(this->parent->proxy.get(), this->id, visibility);
437 }
438
439 void layer::set_destination_rectangle(int32_t x, int32_t y,
440                                       int32_t width, int32_t height)
441 {
442     ivi_wm_set_layer_destination_rectangle(this->parent->proxy.get(), this->id,
443                                            x, y, width, height);
444 }
445
446 void layer::add_surface(uint32_t surface_id)
447 {
448     ivi_wm_layer_add_surface(this->parent->proxy.get(), this->id, surface_id);
449 }
450
451 void layer::remove_surface(uint32_t surface_id)
452 {
453     ivi_wm_layer_remove_surface(this->parent->proxy.get(), this->id, surface_id);
454 }
455
456 /**
457  * screen
458  */
459 screen::screen(uint32_t i, struct controller *c, struct wl_output *o)
460     : wayland_proxy(ivi_wm_create_screen(c->proxy.get(), o)),
461       controller_child(c, i)
462 {
463     HMI_DEBUG("wm", "compositor::screen @ %p id %u o %p", this->proxy.get(), i, o);
464
465     // Add listener for screen
466     ivi_wm_screen_add_listener(this->proxy.get(), &screen_listener, this);
467 }
468
469 void screen::clear() { ivi_wm_screen_clear(this->proxy.get()); }
470
471 void screen::screen_created(struct screen *screen, uint32_t id)
472 {
473     HMI_DEBUG("wm", "compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(),
474               id, id, screen);
475     this->id = id;
476     this->parent->screens[id] = screen;
477 }
478
479 void screen::set_render_order(std::vector<uint32_t> const &ro)
480 {
481     std::size_t i;
482
483     // Remove all layers from the screen render order
484     ivi_wm_screen_clear(this->proxy.get());
485
486     for (i = 0; i < ro.size(); i++)
487     {
488         HMI_DEBUG("wm", "compositor::screen @ %p add layer %u", this->proxy.get(), ro[i]);
489         // Add the layer to screen render order at nearest z-position
490         ivi_wm_screen_add_layer(this->proxy.get(), ro[i]);
491     }
492 }
493
494 /**
495  * controller
496  */
497 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
498     : wayland_proxy(
499           wl_registry_bind(r, name, &ivi_wm_interface, version)),
500       output_size{}
501 {
502     ivi_wm_add_listener(this->proxy.get(), &listener, this);
503 }
504
505 void controller::layer_create(uint32_t id, int32_t w, int32_t h)
506 {
507     this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
508 }
509
510 void controller::surface_create(uint32_t id)
511 {
512     this->surfaces[id] = std::make_unique<struct surface>(id, this);
513
514     // TODO: If Clipping is necessary, this process should be modified.
515     {
516         // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
517         // for resizing wayland surface when switching from split to full surface.
518         ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
519
520         // Set source reactangle even if we should not need to set it
521         // for enable setting for destination region.
522         this->surfaces[id]->set_source_rectangle(0, 0, this->output_size.w, this->output_size.h);
523
524         // Flush display
525         this->display->flush();
526     }
527 }
528
529 void controller::create_screen(struct wl_output *output)
530 {
531     // TODO: screen id is 0 (WM manages one screen for now)
532     this->screen = std::make_unique<struct screen>(0, this, output);
533 }
534
535 void controller::layer_created(uint32_t id)
536 {
537     HMI_DEBUG("wm", "compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
538     if (this->layers.find(id) != this->layers.end())
539     {
540         HMI_DEBUG("wm", "WindowManager has created layer %u (%x) already", id, id);
541     }
542     else
543     {
544         this->layers[id] = std::make_unique<struct layer>(id, this);
545     }
546 }
547
548 void controller::layer_error_detected(uint32_t object_id,
549                                       uint32_t error_code, const char *error_text)
550 {
551     HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s",
552               this->proxy.get(), object_id, error_code, error_text);
553 }
554
555 void controller::surface_visibility_changed(struct surface *s, int32_t visibility)
556 {
557     HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, s->id,
558               visibility);
559     this->sprops[s->id].visibility = visibility;
560     this->chooks->surface_visibility(s->id, visibility);
561 }
562
563 void controller::surface_opacity_changed(struct surface *s, float opacity)
564 {
565     HMI_DEBUG("wm", "compositor::surface %s @ %d o %f", __func__, s->id,
566               opacity);
567     this->sprops[s->id].opacity = opacity;
568 }
569
570 void controller::surface_source_rectangle_changed(struct surface *s, int32_t x,
571                                                   int32_t y, int32_t width,
572                                                   int32_t height)
573 {
574     HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
575               s->id, x, y, width, height);
576     this->sprops[s->id].src_rect = rect{width, height, x, y};
577 }
578
579 void controller::surface_destination_rectangle_changed(struct surface *s, int32_t x,
580                                                        int32_t y, int32_t width,
581                                                        int32_t height)
582 {
583     HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
584               s->id, x, y, width, height);
585     this->sprops[s->id].dst_rect = rect{width, height, x, y};
586     this->chooks->surface_destination_rectangle(s->id, x, y, width, height);
587 }
588
589 void controller::surface_size_changed(struct surface *s, int32_t width,
590                                       int32_t height)
591 {
592     HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, s->id,
593               width, height);
594     this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
595 }
596
597 void controller::surface_added_to_layer(struct surface *s,
598                                         uint32_t layer_id, uint32_t surface_id)
599 {
600     HMI_DEBUG("wm", "compositor::surface %s @ %d l %u",
601               __func__, layer_id, surface_id);
602 }
603
604 void controller::surface_stats_received(struct surface *s, uint32_t surface_id,
605                                         uint32_t frame_count, uint32_t pid)
606 {
607     HMI_DEBUG("wm", "compositor::surface %s @ %d f %u pid %u",
608               __func__, surface_id, frame_count, pid);
609 }
610
611 void controller::surface_created(uint32_t id)
612 {
613     HMI_DEBUG("wm", "compositor::controller @ %p surface %u (%x)", this->proxy.get(), id,
614               id);
615     if (this->surfaces.find(id) == this->surfaces.end())
616     {
617         this->surfaces[id] = std::make_unique<struct surface>(id, this);
618         this->chooks->surface_created(id);
619
620         // TODO: If Clipping is necessary, this process should be modified.
621         {
622             // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
623             // for resizing wayland surface when switching from split to full surface.
624             ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
625
626             // Set source reactangle even if we should not need to set it
627             // for enable setting for destination region.
628             this->surfaces[id]->set_source_rectangle(0, 0, this->output_size.w, this->output_size.h);
629
630             // Flush display
631             this->display->flush();
632         }
633     }
634 }
635
636 void controller::surface_destroyed(struct surface *s, uint32_t surface_id)
637 {
638     HMI_DEBUG("wm", "compositor::surface %s @ %d", __func__, surface_id);
639     this->chooks->surface_removed(surface_id);
640     this->sprops.erase(surface_id);
641     this->surfaces.erase(surface_id);
642 }
643
644 void controller::surface_error_detected(uint32_t object_id,
645                                         uint32_t error_code, const char *error_text)
646 {
647     HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s",
648               this->proxy.get(), object_id, error_code, error_text);
649 }
650
651 void controller::layer_visibility_changed(struct layer *l, uint32_t layer_id, int32_t visibility)
652 {
653     HMI_DEBUG("wm", "compositor::layer %s @ %d v %i", __func__, layer_id, visibility);
654     this->lprops[layer_id].visibility = visibility;
655 }
656
657 void controller::layer_opacity_changed(struct layer *l, uint32_t layer_id, float opacity)
658 {
659     HMI_DEBUG("wm", "compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
660     this->lprops[layer_id].opacity = opacity;
661 }
662
663 void controller::layer_source_rectangle_changed(struct layer *l, uint32_t layer_id,
664                                                 int32_t x, int32_t y,
665                                                 int32_t width, int32_t height)
666 {
667     HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i",
668               __func__, layer_id, x, y, width, height);
669     this->lprops[layer_id].src_rect = rect{width, height, x, y};
670 }
671
672 void controller::layer_destination_rectangle_changed(struct layer *l, uint32_t layer_id,
673                                                      int32_t x, int32_t y,
674                                                      int32_t width, int32_t height)
675 {
676     HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i",
677               __func__, layer_id, x, y, width, height);
678     this->lprops[layer_id].dst_rect = rect{width, height, x, y};
679 }
680
681 void controller::layer_configuration(struct layer *l, int32_t width,
682                                      int32_t height)
683 {
684     HMI_DEBUG("wm", "compositor::layer %s @ %d w %i h %i", __func__, l->id,
685               width, height);
686     this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
687 }
688
689 void controller::layer_orientation(struct layer *l, int32_t orientation)
690 {
691     HMI_DEBUG("wm", "compositor::layer %s @ %d o %i", __func__, l->id,
692               orientation);
693     this->lprops[l->id].orientation = orientation;
694 }
695
696 void controller::layer_screen(struct layer *l, struct wl_output *screen)
697 {
698     HMI_DEBUG("wm", "compositor::layer %s @ %d s %p", __func__, l->id, screen);
699 }
700
701 void controller::layer_destroyed(struct layer *l, uint32_t layer_id)
702 {
703     HMI_DEBUG("wm", "compositor::layer %s @ %d", __func__, layer_id);
704     this->lprops.erase(layer_id);
705     this->layers.erase(layer_id);
706 }
707
708 void controller::add_proxy_to_sid_mapping(struct ivi_wm *p,
709                                           uint32_t id)
710 {
711     HMI_DEBUG("wm", "Add surface proxy mapping for %p (%u)", p, id);
712     this->surface_proxy_to_id[uintptr_t(p)] = id;
713     this->sprops[id].id = id;
714 }
715
716 void controller::remove_proxy_to_sid_mapping(struct ivi_wm *p)
717 {
718     HMI_DEBUG("wm", "Remove surface proxy mapping for %p", p);
719     this->surface_proxy_to_id.erase(uintptr_t(p));
720 }
721
722 void controller::add_proxy_to_lid_mapping(struct ivi_wm *p,
723                                           uint32_t id)
724 {
725     HMI_DEBUG("wm", "Add layer proxy mapping for %p (%u)", p, id);
726     this->layer_proxy_to_id[uintptr_t(p)] = id;
727     this->lprops[id].id = id;
728 }
729
730 void controller::remove_proxy_to_lid_mapping(struct ivi_wm *p)
731 {
732     HMI_DEBUG("wm", "Remove layer proxy mapping for %p", p);
733     this->layer_proxy_to_id.erase(uintptr_t(p));
734 }
735
736 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id)
737 {
738     HMI_DEBUG("wm", "Add screen proxy mapping for %p (%u)", p, id);
739     this->screen_proxy_to_id[uintptr_t(p)] = id;
740 }
741
742 void controller::remove_proxy_to_id_mapping(struct wl_output *p)
743 {
744     HMI_DEBUG("wm", "Remove screen proxy mapping for %p", p);
745     this->screen_proxy_to_id.erase(uintptr_t(p));
746 }
747
748 } // namespace compositor