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