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