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