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