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