af552b564501ef95f41b2cc2822adbc49faca4a7
[apps/agl-service-windowmanager-2017.git] / src / app.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 "app.hpp"
18 #include "json_helper.hpp"
19 #include "layers.hpp"
20 #include "layout.hpp"
21 #include "util.hpp"
22 #include "wayland.hpp"
23
24 #include <cstdio>
25 #include <memory>
26
27 #include <cassert>
28
29 #include <json-c/json.h>
30
31 #include <algorithm>
32 #include <bits/signum.h>
33 #include <csignal>
34 #include <fstream>
35 #include <json.hpp>
36 #include <regex>
37 #include <thread>
38
39
40 namespace wm {
41
42 namespace {
43
44 using nlohmann::json;
45
46 result<json> file_to_json(char const *filename) {
47    json j;
48    std::ifstream i(filename);
49    if (i.fail()) {
50       HMI_DEBUG("wm", "Could not open config file, so use default layer information");
51       j = default_layers_json;
52    }
53    else {
54       i >> j;
55    }
56
57    return Ok(j);
58 }
59
60 struct result<layer_map> load_layer_map(char const *filename) {
61    HMI_DEBUG("wm", "loading IDs from %s", filename);
62
63    auto j = file_to_json(filename);
64    if (j.is_err()) {
65       return Err<layer_map>(j.unwrap_err());
66    }
67    json jids = j.unwrap();
68
69    return to_layer_map(jids);
70 }
71
72 }  // namespace
73
74
75 /**
76  * App Impl
77  */
78 App::App(wl::display *d)
79    : api{this},
80      chooks{this},
81      display{d},
82      controller{},
83      outputs(),
84      config(),
85      layers(),
86      id_alloc{},
87      pending_events(false),
88      policy{} {
89    try {
90       {
91          auto l = load_layer_map(
92             this->config.get_string("layers.json").value().c_str());
93          if (l.is_ok()) {
94             this->layers = l.unwrap();
95          } else {
96             HMI_ERROR("wm", "%s", l.err().value());
97          }
98       }
99    } catch (std::exception &e) {
100       HMI_ERROR("wm", "Loading of configuration failed: %s", e.what());
101    }
102 }
103
104 int App::init() {
105    if (!this->display->ok()) {
106       return -1;
107    }
108
109    if (this->layers.mapping.empty()) {
110       HMI_ERROR("wm", "No surface -> layer mapping loaded");
111       return -1;
112    }
113
114    // Make afb event
115    for (int i=Event_Val_Min; i<=Event_Val_Max; i++) {
116       map_afb_event[kListEventName[i]] = afb_daemon_make_event(kListEventName[i]);
117    }
118
119    this->display->add_global_handler(
120       "wl_output", [this](wl_registry *r, uint32_t name, uint32_t v) {
121          this->outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
122       });
123
124    this->display->add_global_handler(
125       "ivi_controller", [this](wl_registry *r, uint32_t name, uint32_t v) {
126          this->controller =
127             std::make_unique<struct compositor::controller>(r, name, v);
128
129          // Init controller hooks
130          this->controller->chooks = &this->chooks;
131
132          // This protocol needs the output, so lets just add our mapping here...
133          this->controller->add_proxy_to_id_mapping(
134             this->outputs.back()->proxy.get(),
135             wl_proxy_get_id(reinterpret_cast<struct wl_proxy *>(
136                this->outputs.back()->proxy.get())));
137       });
138
139    // First level objects
140    this->display->roundtrip();
141    // Second level objects
142    this->display->roundtrip();
143    // Third level objects
144    this->display->roundtrip();
145
146    return init_layers();
147 }
148
149 int App::dispatch_events() {
150    if (this->dispatch_events() == 0) {
151       return 0;
152    }
153
154    int ret = this->display->dispatch();
155    if (ret == -1) {
156       HMI_ERROR("wm", "wl_display_dipatch() returned error %d",
157                this->display->get_error());
158       return -1;
159    }
160    this->display->flush();
161
162    return 0;
163 }
164
165 int App::dispatch_pending_events() {
166    if (this->pop_pending_events()) {
167       this->display->dispatch_pending();
168       return 0;
169    }
170    return -1;
171 }
172
173 bool App::pop_pending_events() {
174    bool x{true};
175    return this->pending_events.compare_exchange_strong(
176       x, false, std::memory_order_consume);
177 }
178
179 void App::set_pending_events() {
180    this->pending_events.store(true, std::memory_order_release);
181 }
182
183 optional<int> App::lookup_id(char const *name) {
184    return this->id_alloc.lookup(std::string(name));
185 }
186 optional<std::string> App::lookup_name(int id) {
187    return this->id_alloc.lookup(id);
188 }
189
190 /**
191  * init_layers()
192  */
193 int App::init_layers() {
194    if (!this->controller) {
195       HMI_ERROR("wm", "ivi_controller global not available");
196       return -1;
197    }
198
199    if (this->outputs.empty()) {
200       HMI_ERROR("wm", "no output was set up!");
201       return -1;
202    }
203
204    auto &c = this->controller;
205
206    auto &o = this->outputs.front();
207    auto &s = c->screens.begin()->second;
208    auto &layers = c->layers;
209
210    // Write output dimensions to ivi controller...
211    c->output_size = compositor::size{uint32_t(o->width), uint32_t(o->height)};
212
213    // Clear scene
214    layers.clear();
215
216    // Clear screen
217    s->clear();
218
219    // Quick and dirty setup of layers
220    for (auto const &i : this->layers.mapping) {
221       c->layer_create(i.second.layer_id, o->width, o->height);
222       auto &l = layers[i.second.layer_id];
223       l->set_destination_rectangle(0, 0, o->width, o->height);
224       l->set_visibility(1);
225       HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"",
226                i.second.name.c_str(), i.second.layer_id, i.second.role.c_str());
227    }
228
229    // Add layers to screen
230    s->set_render_order(this->layers.layers);
231
232    this->layout_commit();
233
234    return 0;
235 }
236
237 void App::surface_set_layout(int surface_id, optional<int> sub_surface_id) {
238    if (!this->controller->surface_exists(surface_id)) {
239       HMI_ERROR("wm", "Surface %d does not exist", surface_id);
240       return;
241    }
242
243    auto o_layer_id = this->layers.get_layer_id(surface_id);
244
245    if (!o_layer_id) {
246       HMI_ERROR("wm", "Surface %d is not associated with any layer!", surface_id);
247       return;
248    }
249
250    uint32_t layer_id = *o_layer_id;
251
252    auto const &layer = this->layers.get_layer(layer_id);
253    auto rect = layer.value().rect;
254    auto &s = this->controller->surfaces[surface_id];
255
256    int x = rect.x;
257    int y = rect.y;
258    int w = rect.w;
259    int h = rect.h;
260
261    // less-than-0 values refer to MAX + 1 - $VALUE
262    // e.g. MAX is either screen width or height
263    if (w < 0) {
264       w = this->controller->output_size.w + 1 + w;
265    }
266    if (h < 0) {
267       h = this->controller->output_size.h + 1 + h;
268    }
269
270    if (sub_surface_id) {
271       if (o_layer_id != this->layers.get_layer_id(*sub_surface_id)) {
272          HMI_ERROR("wm",
273             "surface_set_layout: layers of surfaces (%d and %d) don't match!",
274             surface_id, *sub_surface_id);
275          return;
276       }
277
278       int x_off = 0;
279       int y_off = 0;
280
281       // split along major axis
282       if (w > h) {
283          w /= 2;
284          x_off = w;
285       } else {
286          h /= 2;
287          y_off = h;
288       }
289
290       auto &ss = this->controller->surfaces[*sub_surface_id];
291
292       HMI_DEBUG("wm", "surface_set_layout for sub surface %u on layer %u",
293                *sub_surface_id, layer_id);
294
295       // configure surface to wxh dimensions
296       ss->set_configuration(w, h);
297       // set source reactangle, even if we should not need to set it.
298       ss->set_source_rectangle(0, 0, w, h);
299       // set destination to the display rectangle
300       ss->set_destination_rectangle(x + x_off, y + y_off, w, h);
301
302    }
303
304    HMI_DEBUG("wm", "surface_set_layout for surface %u on layer %u", surface_id,
305             layer_id);
306
307    // configure surface to wxh dimensions
308    s->set_configuration(w, h);
309    // set source reactangle, even if we should not need to set it.
310    s->set_source_rectangle(0, 0, w, h);
311
312    // set destination to the display rectangle
313    s->set_destination_rectangle(x, y, w, h);
314
315    HMI_DEBUG("wm", "Surface %u now on layer %u with rect { %d, %d, %d, %d }",
316             surface_id, layer_id, x, y, w, h);
317 }
318
319 void App::layout_commit() {
320    this->controller->commit_changes();
321    this->display->flush();
322 }
323
324 char const *App::api_activate_surface(char const *drawing_name, char const *drawing_area) {
325    ST();
326
327    auto const &surface_id = this->lookup_id(drawing_name);
328
329    if (!surface_id) {
330       return "Surface does not exist";
331    }
332
333    if (!this->controller->surface_exists(*surface_id)) {
334       return "Surface does not exist in controller!";
335    }
336
337    auto layer_id = this->layers.get_layer_id(*surface_id);
338
339    if (!layer_id) {
340       return "Surface is not on any layer!";
341    }
342
343    auto o_state = *this->layers.get_layout_state(*surface_id);
344
345    if (o_state == nullptr) {
346       return "Could not find layer for surface";
347    }
348
349    struct LayoutState &state = *o_state;
350
351    // disable layers that are above our current layer
352    for (auto const &l : this->layers.mapping) {
353       if (l.second.layer_id <= *layer_id) {
354          continue;
355       }
356
357       bool flush = false;
358       if (l.second.state.main != -1) {
359          this->deactivate(l.second.state.main);
360          l.second.state.main = -1;
361          flush = true;
362       }
363
364       if (l.second.state.sub != -1) {
365          this->deactivate(l.second.state.sub);
366          l.second.state.sub = -1;
367          flush = true;
368       }
369
370       if (flush) {
371          this->layout_commit();
372       }
373    }
374
375    auto layer = this->layers.get_layer(*layer_id);
376
377    if (state.main == -1) {
378       this->try_layout(
379          state, LayoutState{*surface_id}, [&] (LayoutState const &nl) {
380             HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
381             this->surface_set_layout(*surface_id);
382             state = nl;
383
384             // Commit for configuraton
385             this->layout_commit();
386
387             if (!(layer->is_normal_layout_only)) {
388                // Wait for configuration listener
389                controller->is_configured = false;
390                while (!(controller->is_configured)) {
391                   dispatch_pending_events();
392                }
393             }
394
395             std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
396             this->emit_syncdraw(drawing_name, str_area.c_str());
397             this->enqueue_flushdraw(state.main);
398          });
399    } else {
400       if (0 == strcmp(drawing_name, "HomeScreen")) {
401          this->try_layout(
402             state, LayoutState{*surface_id}, [&] (LayoutState const &nl) {
403                HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
404                std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
405                this->emit_syncdraw(drawing_name, str_area.c_str());
406                this->enqueue_flushdraw(state.main);
407             });
408       } else {
409          bool can_split = this->can_split(state, *surface_id);
410
411          if (can_split) {
412             this->try_layout(
413                state,
414                LayoutState{state.main, *surface_id},
415                [&] (LayoutState const &nl) {
416                   HMI_DEBUG("wm", "Layout: %s", kNameLayoutSplit);
417                   std::string main =
418                      std::move(*this->lookup_name(state.main));
419
420                   this->surface_set_layout(state.main, surface_id);
421                   if (state.sub != *surface_id) {
422                       if (state.sub != -1) {
423                          this->deactivate(state.sub);
424                       }
425                   }
426                   state = nl;
427
428                   // Commit for configuraton and visibility(0)
429                   this->layout_commit();
430
431                   // Wait for configuration listener
432                   controller->is_configured = false;
433                   while (!(controller->is_configured)) {
434                      dispatch_pending_events();
435                   }
436
437                   std::string str_area_main = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaMain);
438                   std::string str_area_sub = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaSub);
439                   this->emit_syncdraw(main.c_str(), str_area_main.c_str());
440                   this->emit_syncdraw(drawing_name, str_area_sub.c_str());
441                   this->enqueue_flushdraw(state.main);
442                   this->enqueue_flushdraw(state.sub);
443                });
444          } else {
445             this->try_layout(
446                state, LayoutState{*surface_id}, [&] (LayoutState const &nl) {
447                   HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
448
449                   this->surface_set_layout(*surface_id);
450                   if (state.main != *surface_id) {
451                       this->deactivate(state.main);
452                   }
453                   if (state.sub != -1) {
454                       if (state.sub != *surface_id) {
455                          this->deactivate(state.sub);
456                       }
457                   }
458                   state = nl;
459
460                   // Commit for configuraton and visibility(0)
461                   this->layout_commit();
462
463                   if (!(layer->is_normal_layout_only)) {
464                      // Wait for configuration listener
465                      controller->is_configured = false;
466                      while (!(controller->is_configured)) {
467                         dispatch_pending_events();
468                      }
469                   }
470
471                   std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
472                   this->emit_syncdraw(drawing_name, str_area.c_str());
473                   this->enqueue_flushdraw(state.main);
474                });
475          }
476       }
477    }
478
479    // no error
480    return nullptr;
481 }
482
483 char const *App::api_deactivate_surface(char const *drawing_name) {
484    ST();
485    auto const &surface_id = this->lookup_id(drawing_name);
486
487    if (!surface_id) {
488          return "Surface does not exist";
489       }
490
491    if (*surface_id == this->layers.main_surface) {
492       return "Cannot deactivate main_surface";
493    }
494
495    auto o_state = *this->layers.get_layout_state(*surface_id);
496
497    if (o_state == nullptr) {
498       return "Could not find layer for surface";
499    }
500
501    struct LayoutState &state = *o_state;
502
503    if (state.main == -1) {
504       return "No surface active";
505    }
506
507    // XXX: check against main_surface, main_surface_name is the configuration
508    // item.
509    if (*surface_id == this->layers.main_surface) {
510       HMI_DEBUG("wm", "Refusing to deactivate main_surface %d", *surface_id);
511       return nullptr;
512    }
513
514    if (state.main == *surface_id) {
515       if (state.sub != -1) {
516          this->try_layout(
517             state, LayoutState{state.sub, -1}, [&] (LayoutState const &nl) {
518                std::string sub = std::move(*this->lookup_name(state.sub));
519
520                this->deactivate(*surface_id);
521                this->surface_set_layout(state.sub);
522                state = nl;
523
524                this->layout_commit();
525                std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
526                this->emit_syncdraw(sub.c_str(), str_area.c_str());
527                this->enqueue_flushdraw(state.sub);
528             });
529       } else {
530          this->try_layout(state, LayoutState{-1, -1}, [&] (LayoutState const &nl) {
531             this->deactivate(*surface_id);
532             state = nl;
533             this->layout_commit();
534          });
535       }
536    } else if (state.sub == *surface_id) {
537       this->try_layout(
538          state, LayoutState{state.main, -1}, [&] (LayoutState const &nl) {
539             std::string main = std::move(*this->lookup_name(state.main));
540
541             this->deactivate(*surface_id);
542             this->surface_set_layout(state.main);
543             state = nl;
544
545             this->layout_commit();
546             std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
547             this->emit_syncdraw(main.c_str(), str_area.c_str());
548             this->enqueue_flushdraw(state.main);
549          });
550    } else {
551       return "Surface is not active";
552    }
553
554    return nullptr;
555 }
556
557 void App::enqueue_flushdraw(int surface_id) {
558    this->check_flushdraw(surface_id);
559    HMI_DEBUG("wm", "Enqueuing EndDraw for surface_id %d", surface_id);
560    this->pending_end_draw.push_back(surface_id);
561 }
562
563 void App::check_flushdraw(int surface_id) {
564    auto i = std::find(std::begin(this->pending_end_draw),
565                       std::end(this->pending_end_draw), surface_id);
566    if (i != std::end(this->pending_end_draw)) {
567       auto n = this->lookup_name(surface_id);
568       HMI_ERROR("wm", "Application %s (%d) has pending EndDraw call(s)!",
569                n ? n->c_str() : "unknown-name", surface_id);
570       std::swap(this->pending_end_draw[std::distance(
571                    std::begin(this->pending_end_draw), i)],
572                 this->pending_end_draw.back());
573       this->pending_end_draw.resize(this->pending_end_draw.size() - 1);
574    }
575 }
576
577 char const *App::api_enddraw(char const *drawing_name) {
578    for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
579       auto n = this->lookup_name(this->pending_end_draw[i]);
580       if (n && *n == drawing_name) {
581          std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]);
582          this->pending_end_draw.resize(iend - 1);
583          // XXX: Please tell the compositor to thaw the surface...
584          this->activate(this->pending_end_draw[i]);
585          this->layout_commit();
586          this->emit_flushdraw(drawing_name);
587          return nullptr;
588       }
589    }
590    return "No EndDraw pending for surface";
591 }
592
593 void App::api_ping() { this->dispatch_pending_events(); }
594
595 /**
596  * proxied events
597  */
598 void App::surface_created(uint32_t surface_id) {
599    auto layer_id = this->layers.get_layer_id(surface_id);
600    if (!layer_id) {
601       HMI_DEBUG("wm", "Newly created surfce %d is not associated with any layer!",
602                surface_id);
603       return;
604    }
605
606    HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", surface_id, *layer_id);
607
608    this->controller->layers[*layer_id]->add_surface(
609       this->controller->surfaces[surface_id].get());
610
611    // activate the main_surface right away
612    /*if (surface_id == static_cast<unsigned>(this->layers.main_surface)) {
613       HMI_DEBUG("wm", "Activating main_surface (%d)", surface_id);
614
615       this->api_activate_surface(
616          this->lookup_name(surface_id).value_or("unknown-name").c_str());
617    }*/
618 }
619
620 void App::surface_removed(uint32_t surface_id) {
621    HMI_DEBUG("wm", "surface_id is %u", surface_id);
622
623    // We cannot normally deactivate the main_surface, so be explicit
624    // about it:
625    if (int(surface_id) == this->layers.main_surface) {
626       this->deactivate_main_surface();
627    } else {
628       auto drawing_name = this->lookup_name(surface_id);
629       if (drawing_name) {
630          this->api_deactivate_surface(drawing_name->c_str());
631       }
632    }
633
634    this->id_alloc.remove_id(surface_id);
635    this->layers.remove_surface(surface_id);
636 }
637
638 void App::emit_activated(char const *label) {
639    this->api.send_event(kListEventName[Event_Active], label);
640 }
641
642 void App::emit_deactivated(char const *label) {
643    this->api.send_event(kListEventName[Event_Inactive], label);
644 }
645
646 void App::emit_syncdraw(char const *label, char const *area) {
647     this->api.send_event(kListEventName[Event_SyncDraw], label, area);
648 }
649
650 void App::emit_flushdraw(char const *label) {
651    this->api.send_event(kListEventName[Event_FlushDraw], label);
652 }
653
654 void App::emit_visible(char const *label, bool is_visible) {
655    this->api.send_event(is_visible ? kListEventName[Event_Visible] : kListEventName[Event_Invisible], label);
656 }
657
658 void App::emit_invisible(char const *label) {
659    return emit_visible(label, false);
660 }
661
662 void App::emit_visible(char const *label) { return emit_visible(label, true); }
663
664 result<int> App::api_request_surface(char const *drawing_name) {
665    auto lid = this->layers.get_layer_id(std::string(drawing_name));
666    if (!lid) {
667       // TODO: Do we need to put these applications on the App layer?
668       return Err<int>("Drawing name does not match any role");
669    }
670
671    auto rname = this->lookup_id(drawing_name);
672    if (!rname) {
673       // name does not exist yet, allocate surface id...
674       auto id = int(this->id_alloc.generate_id(drawing_name));
675       this->layers.add_surface(id, *lid);
676
677       // set the main_surface[_name] here and now
678       if (!this->layers.main_surface_name.empty() &&
679           this->layers.main_surface_name == drawing_name) {
680          this->layers.main_surface = id;
681          HMI_DEBUG("wm", "Set main_surface id to %u", id);
682       }
683
684       return Ok<int>(id);
685    }
686
687    // Check currently registered drawing names if it is already there.
688    return Err<int>("Surface already present");
689 }
690
691 void App::activate(int id) {
692    auto ip = this->controller->sprops.find(id);
693    if (ip != this->controller->sprops.end()) {
694       this->controller->surfaces[id]->set_visibility(0);
695       this->layout_commit();
696       this->controller->surfaces[id]->set_visibility(1);
697       char const *label =
698          this->lookup_name(id).value_or("unknown-name").c_str();
699       this->emit_visible(label);
700       this->emit_activated(label);
701    }
702 }
703
704 void App::deactivate(int id) {
705    auto ip = this->controller->sprops.find(id);
706    if (ip != this->controller->sprops.end() && ip->second.visibility != 0) {
707       this->controller->surfaces[id]->set_visibility(0);
708       char const *label =
709          this->lookup_name(id).value_or("unknown-name").c_str();
710       this->emit_deactivated(label);
711       this->emit_invisible(label);
712    }
713 }
714
715 void App::deactivate_main_surface() {
716    this->layers.main_surface = -1;
717    this->api_deactivate_surface(this->layers.main_surface_name.c_str());
718 }
719
720 bool App::can_split(struct LayoutState const &state, int new_id) {
721    if (state.main != -1 && state.main != new_id) {
722       auto new_id_layer = this->layers.get_layer_id(new_id).value();
723       auto current_id_layer = this->layers.get_layer_id(state.main).value();
724
725       // surfaces are on separate layers, don't bother.
726       if (new_id_layer != current_id_layer) {
727          return false;
728       }
729
730       std::string const &new_id_str = this->lookup_name(new_id).value();
731       std::string const &cur_id_str = this->lookup_name(state.main).value();
732
733       auto const &layer = this->layers.get_layer(new_id_layer);
734
735       HMI_DEBUG("wm", "layer info name: %s", layer->name.c_str());
736
737       if (layer->layouts.empty()) {
738          return false;
739       }
740
741       for (auto i = layer->layouts.cbegin(); i != layer->layouts.cend(); i++) {
742          HMI_DEBUG("wm", "%d main_match '%s'", new_id_layer, i->main_match.c_str());
743          auto rem = std::regex(i->main_match);
744          if (std::regex_match(cur_id_str, rem)) {
745             // build the second one only if the first already matched
746             HMI_DEBUG("wm", "%d sub_match '%s'", new_id_layer, i->sub_match.c_str());
747             auto res = std::regex(i->sub_match);
748             if (std::regex_match(new_id_str, res)) {
749                HMI_DEBUG("wm", "layout matched!");
750                return true;
751             }
752          }
753       }
754    }
755
756    return false;
757 }
758
759 void App::try_layout(struct LayoutState & /*state*/,
760                      struct LayoutState const &new_layout,
761                      std::function<void(LayoutState const &nl)> apply) {
762    if (this->policy.layout_is_valid(new_layout)) {
763       apply(new_layout);
764    }
765 }
766
767 /**
768  * controller_hooks
769  */
770 void controller_hooks::surface_created(uint32_t surface_id) {
771    this->app->surface_created(surface_id);
772 }
773
774 void controller_hooks::surface_removed(uint32_t surface_id) {
775    this->app->surface_removed(surface_id);
776 }
777
778 void controller_hooks::surface_visibility(uint32_t /*surface_id*/,
779                                           uint32_t /*v*/) {}
780
781 void controller_hooks::surface_destination_rectangle(uint32_t /*surface_id*/,
782                                                      uint32_t /*x*/,
783                                                      uint32_t /*y*/,
784                                                      uint32_t /*w*/,
785                                                      uint32_t /*h*/) {}
786
787 }  // namespace wm