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