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