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