app/afbclient: use the correct names for active/inactive events
[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      layers(),
84      id_alloc{},
85      pending_events(false),
86      policy{} {
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.second.layer_id, o->width, o->height);
226       auto &l = layers[i.second.layer_id];
227       l->set_destination_rectangle(0, 0, o->width, o->height);
228       l->set_visibility(1);
229       logdebug("Setting up layer %s (%d) for surface role match \"%s\"",
230                i.second.name.c_str(), i.second.layer_id, i.second.role.c_str());
231    }
232
233    // Add layers to screen (XXX: are they sorted correctly?)
234    s->set_render_order(this->layers.layers);
235
236    this->layout_commit();
237
238    return 0;
239 }
240
241 namespace {
242
243 #ifdef WE_LIKE_NOT_TO_USE_THIS
244 // This can fix the HomeScreen...
245 void redraw_fix(App *app, std::unique_ptr<genivi::surface> &s, int x, int y,
246                 int w, int h) {
247    {  // XXX: Work around weston redraw issues
248       // trigger an update by changing the source dimensions!
249       s->set_configuration(w + 1, h);
250       s->set_source_rectangle(0, 0, w + 1, h);
251       s->set_destination_rectangle(x, y, w + 1, h);
252       app->controller->commit_changes();
253       app->display->roundtrip();
254
255       // wait some time, for the process to do its thing...
256       using namespace std::chrono_literals;
257       std::this_thread::sleep_for(100ms);
258
259       // Set a different size then what we actually want.
260       s->set_configuration(w, h);
261       s->set_source_rectangle(0, 0, w, h);
262       s->set_destination_rectangle(x, y, w, h);
263       app->controller->commit_changes();
264       app->display->roundtrip();
265    }
266 }
267 #endif
268
269 }  // namespace
270
271 void App::surface_set_layout(int surface_id, optional<int> sub_surface_id) {
272    if (!this->controller->surface_exists(surface_id)) {
273       logerror("Surface %d does not exist", surface_id);
274       return;
275    }
276
277    auto o_layer_id = this->layers.get_layer_id(surface_id);
278
279    if (!o_layer_id) {
280       logerror("Surface %d is not associated with any layer!", surface_id);
281       return;
282    }
283
284    uint32_t layer_id = *o_layer_id;
285
286    auto const &layer = this->layers.get_layer(layer_id);
287    auto rect = layer.value().rect;
288    auto &s = this->controller->surfaces[surface_id];
289
290    int x = rect.x;
291    int y = rect.y;
292    int w = rect.w;
293    int h = rect.h;
294
295    // less-than-0 values refer to MAX + 1 - $VALUE
296    // e.g. MAX is either screen width or height
297    if (w < 0) {
298       w = this->controller->output_size.w + 1 + w;
299    }
300    if (h < 0) {
301       h = this->controller->output_size.h + 1 + h;
302    }
303
304    if (sub_surface_id) {
305       if (o_layer_id != this->layers.get_layer_id(*sub_surface_id)) {
306          logerror(
307             "surface_set_layout: layers of surfaces (%d and %d) don't match!",
308             surface_id, *sub_surface_id);
309          return;
310       }
311
312       int x_off = 0;
313       int y_off = 0;
314
315       // split along major axis
316       if (w > h) {
317          w /= 2;
318          x_off = w;
319       } else {
320          h /= 2;
321          y_off = h;
322       }
323
324       auto &ss = this->controller->surfaces[*sub_surface_id];
325
326       logdebug("surface_set_layout for sub surface %u on layer %u",
327                *sub_surface_id, layer_id);
328
329       // configure surface to wxh dimensions
330       ss->set_configuration(w, h);
331       // set source reactangle, even if we should not need to set it.
332       ss->set_source_rectangle(0, 0, w, h);
333       // set destination to the display rectangle
334       ss->set_destination_rectangle(x + x_off, y + y_off, w, h);
335    }
336
337    logdebug("surface_set_layout for surface %u on layer %u", surface_id,
338             layer_id);
339
340    // configure surface to wxh dimensions
341    s->set_configuration(w, h);
342    // set source reactangle, even if we should not need to set it.
343    s->set_source_rectangle(0, 0, w, h);
344    // set destination to the display rectangle
345    s->set_destination_rectangle(x, y, w, h);
346
347    // redraw_fix(this, s, x, y, w, h);
348    // redraw_fix(this, ss, x+x_off, y+y_off, w, h);
349
350    logdebug("Surface %u now on layer %u with rect { %d, %d, %d, %d }",
351             surface_id, layer_id, x, y, w, h);
352 }
353
354 void App::layout_commit() {
355    this->controller->commit_changes();
356    this->display->flush();
357 }
358
359 char const *App::api_activate_surface(char const *drawing_name) {
360    ST();
361    auto const &surface_id = this->lookup_id(drawing_name);
362
363    if (!surface_id) {
364       return "Surface does not exist";
365    }
366
367    if (!this->controller->surface_exists(*surface_id)) {
368       return "Surface does not exist in controller!";
369    }
370
371    auto layer_id = this->layers.get_layer_id(*surface_id);
372
373    if (!layer_id) {
374       return "Surface is not on any layer!";
375    }
376
377    auto o_state = *this->layers.get_layout_state(*surface_id);
378
379    if (o_state == nullptr) {
380       return "Could not find layer for surface";
381    }
382
383    struct LayoutState &state = *o_state;
384
385    // disable layers that are above our current layer
386    for (auto const &l : this->layers.mapping) {
387       if (l.second.layer_id <= *layer_id) {
388          continue;
389       }
390
391       bool flush = false;
392       if (l.second.state.main != -1) {
393          this->deactivate(l.second.state.main);
394          l.second.state.main = -1;
395          flush = true;
396       }
397
398       if (l.second.state.sub != -1) {
399          this->deactivate(l.second.state.sub);
400          l.second.state.sub = -1;
401          flush = true;
402       }
403
404       if (flush) {
405          this->layout_commit();
406       }
407    }
408
409    if (state.main == *surface_id || state.sub == *surface_id) {
410       return "Surface already active";
411    }
412
413
414    if (state.main == -1) {
415       this->try_layout(
416          state, LayoutState{*surface_id}, [&] (LayoutState const &nl) {
417             this->surface_set_layout(*surface_id);
418             // XXX do we need to activate after enddraw?
419             this->activate(*surface_id);
420             state = nl;
421             this->layout_commit();
422             this->emit_syncdraw(drawing_name);
423             this->enqueue_flushdraw(state.main);
424          });
425    } else {
426       bool can_split = this->can_split(state, *surface_id);
427
428          if (can_split) {
429             this->try_layout(
430                state,
431                LayoutState{state.main, *surface_id},
432                [&] (LayoutState const &nl) {
433                   std::string main =
434                      std::move(*this->lookup_name(state.main));
435
436                   this->surface_set_layout(state.main, surface_id);
437                   this->activate(*surface_id);
438                   if (state.sub != -1) {
439                      this->deactivate(state.sub);
440                   }
441                   state = nl;
442
443                   this->layout_commit();
444                   this->emit_syncdraw(drawing_name);
445                   this->emit_syncdraw(main.c_str());
446                   this->enqueue_flushdraw(state.main);
447                   this->enqueue_flushdraw(state.sub);
448                });
449          } else {
450             this->try_layout(
451                state, LayoutState{*surface_id}, [&] (LayoutState const &nl) {
452                   this->surface_set_layout(*surface_id);
453                   this->deactivate(state.main);
454                   this->activate(*surface_id);
455                   if (state.sub != -1) {
456                      this->deactivate(state.sub);
457                   }
458                   state = nl;
459
460                   this->layout_commit();
461                   this->emit_syncdraw(drawing_name);
462                   this->enqueue_flushdraw(state.main);
463                });
464          }
465    }
466
467    // no error
468    return nullptr;
469 }
470
471 char const *App::api_deactivate_surface(char const *drawing_name) {
472    ST();
473    auto const &surface_id = this->lookup_id(drawing_name);
474
475    if (!surface_id) {
476       return "Surface does not exist";
477    }
478
479    if (*surface_id == this->layers.main_surface) {
480       return "Cannot deactivate main_surface";
481    }
482
483    auto o_state = *this->layers.get_layout_state(*surface_id);
484
485    if (o_state == nullptr) {
486       return "Could not find layer for surface";
487    }
488
489    struct LayoutState &state = *o_state;
490
491    if (state.main == -1) {
492       return "No surface active";
493    }
494
495    // XXX: check against main_surface, main_surface_name is the configuration
496    // item.
497    if (*surface_id == this->layers.main_surface) {
498       logdebug("Refusing to deactivate main_surface %d", *surface_id);
499       return nullptr;
500    }
501
502    if (state.main == *surface_id) {
503       if (state.sub != -1) {
504          this->try_layout(
505             state, LayoutState{state.sub, -1}, [&] (LayoutState const &nl) {
506                std::string sub = std::move(*this->lookup_name(state.sub));
507
508                this->deactivate(*surface_id);
509                this->surface_set_layout(state.sub);
510                state = nl;
511
512                this->layout_commit();
513                this->emit_syncdraw(sub.c_str());
514                this->enqueue_flushdraw(state.sub);
515             });
516       } else {
517          this->try_layout(state, LayoutState{-1, -1}, [&] (LayoutState const &nl) {
518             this->deactivate(*surface_id);
519             state = nl;
520             this->layout_commit();
521          });
522       }
523    } else if (state.sub == *surface_id) {
524       this->try_layout(
525          state, LayoutState{state.main, -1}, [&] (LayoutState const &nl) {
526             std::string main = std::move(*this->lookup_name(state.main));
527
528             this->deactivate(*surface_id);
529             this->surface_set_layout(state.main);
530             state = nl;
531
532             this->layout_commit();
533             this->emit_syncdraw(main.c_str());
534             this->enqueue_flushdraw(state.main);
535          });
536    } else {
537       return "Surface is not active";
538    }
539
540    return nullptr;
541 }
542
543 void App::enqueue_flushdraw(int surface_id) {
544    this->check_flushdraw(surface_id);
545    logdebug("Enqueuing EndDraw for surface_id %d", surface_id);
546    this->pending_end_draw.push_back(surface_id);
547 }
548
549 void App::check_flushdraw(int surface_id) {
550    auto i = std::find(std::begin(this->pending_end_draw),
551                       std::end(this->pending_end_draw), surface_id);
552    if (i != std::end(this->pending_end_draw)) {
553       auto n = this->lookup_name(surface_id);
554       logerror("Application %s (%d) has pending EndDraw call(s)!",
555                n ? n->c_str() : "unknown-name", surface_id);
556       std::swap(this->pending_end_draw[std::distance(
557                    std::begin(this->pending_end_draw), i)],
558                 this->pending_end_draw.back());
559       this->pending_end_draw.resize(this->pending_end_draw.size() - 1);
560    }
561 }
562
563 char const *App::api_enddraw(char const *drawing_name) {
564    for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
565       auto n = this->lookup_name(this->pending_end_draw[i]);
566       if (n && *n == drawing_name) {
567          std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]);
568          this->pending_end_draw.resize(iend - 1);
569          // XXX: Please tell the compositor to thaw the surface...
570          this->emit_flushdraw(drawing_name);
571          return nullptr;
572       }
573    }
574    return "No EndDraw pending for surface";
575 }
576
577 void App::api_ping() { this->dispatch_pending_events(); }
578
579 //                      _          _   _____                 _
580 //  _ __  _ __ _____  _(_) ___  __| | | ____|_   _____ _ __ | |_ ___
581 // | '_ \| '__/ _ \ \/ / |/ _ \/ _` | |  _| \ \ / / _ \ '_ \| __/ __|
582 // | |_) | | | (_) >  <| |  __/ (_| | | |___ \ V /  __/ | | | |_\__ \
583 // | .__/|_|  \___/_/\_\_|\___|\__,_| |_____| \_/ \___|_| |_|\__|___/
584 // |_|
585 void App::surface_created(uint32_t surface_id) {
586    auto layer_id = this->layers.get_layer_id(surface_id);
587    if (!layer_id) {
588       logdebug("Newly created surfce %d is not associated with any layer!",
589                surface_id);
590       return;
591    }
592
593    logdebug("surface_id is %u, layer_id is %u", surface_id, *layer_id);
594
595    this->controller->layers[*layer_id]->add_surface(
596       this->controller->surfaces[surface_id].get());
597
598    // activate the main_surface right away
599    if (surface_id == static_cast<unsigned>(this->layers.main_surface)) {
600       logdebug("Activating main_surface (%d)", surface_id);
601
602       this->api_activate_surface(
603          this->lookup_name(surface_id).value_or("unknown-name").c_str());
604    }
605 }
606
607 void App::surface_removed(uint32_t surface_id) {
608    logdebug("surface_id is %u", surface_id);
609
610    // We cannot normally deactivate the main_surface, so be explicit
611    // about it:
612    if (int(surface_id) == this->layers.main_surface) {
613       this->deactivate_main_surface();
614    } else {
615       auto drawing_name = this->lookup_name(surface_id);
616       if (drawing_name) {
617          this->api_deactivate_surface(drawing_name->c_str());
618       }
619    }
620
621    this->id_alloc.remove_id(surface_id);
622    this->layers.remove_surface(surface_id);
623 }
624
625 void App::emit_activated(char const *label) {
626    this->api.send_event("active", label);
627 }
628
629 void App::emit_deactivated(char const *label) {
630    this->api.send_event("inactive", label);
631 }
632
633 void App::emit_syncdraw(char const *label) {
634    this->api.send_event("syncdraw", label);
635 }
636
637 void App::emit_flushdraw(char const *label) {
638    this->api.send_event("flushdraw", label);
639 }
640
641 void App::emit_visible(char const *label, bool is_visible) {
642    this->api.send_event(is_visible ? "visible" : "invisible", label);
643 }
644
645 void App::emit_invisible(char const *label) {
646    return emit_visible(label, false);
647 }
648
649 void App::emit_visible(char const *label) { return emit_visible(label, true); }
650
651 result<int> App::api_request_surface(char const *drawing_name) {
652    auto lid = this->layers.get_layer_id(std::string(drawing_name));
653    if (!lid) {
654       // XXX: to we need to put these applications on the App layer?
655       return Err<int>("Drawing name does not match any role");
656    }
657
658    auto rname = this->lookup_id(drawing_name);
659    if (!rname) {
660       // name does not exist yet, allocate surface id...
661       auto id = int(this->id_alloc.generate_id(drawing_name));
662       this->layers.add_surface(id, *lid);
663
664       // XXX: we set the main_surface[_name] here and now,
665       // not sure if we want this, but it worked so far.
666       if (!this->layers.main_surface_name.empty() &&
667           this->layers.main_surface_name == drawing_name) {
668          this->layers.main_surface = id;
669          logdebug("Set main_surface id to %u", id);
670       }
671
672       return Ok<int>(id);
673    }
674
675    // Check currently registered drawing names if it is already there.
676    return Err<int>("Surface already present");
677 }
678
679 void App::activate(int id) {
680    auto ip = this->controller->sprops.find(id);
681    if (ip != this->controller->sprops.end() && ip->second.visibility == 0) {
682       this->controller->surfaces[id]->set_visibility(1);
683       char const *label =
684          this->lookup_name(id).value_or("unknown-name").c_str();
685       this->emit_activated(label);
686       this->emit_visible(label);
687    }
688 }
689
690 void App::deactivate(int id) {
691    auto ip = this->controller->sprops.find(id);
692    if (ip != this->controller->sprops.end() && ip->second.visibility != 0) {
693       this->controller->surfaces[id]->set_visibility(0);
694       char const *label =
695          this->lookup_name(id).value_or("unknown-name").c_str();
696       this->emit_deactivated(label);
697       this->emit_invisible(label);
698    }
699 }
700
701 void App::deactivate_main_surface() {
702    this->layers.main_surface = -1;
703    this->api_deactivate_surface(this->layers.main_surface_name.c_str());
704 }
705
706 bool App::can_split(struct LayoutState const &state, int new_id) {
707    if (state.main != -1 && state.main != new_id) {
708       auto new_id_layer = this->layers.get_layer_id(new_id).value();
709       auto current_id_layer = this->layers.get_layer_id(state.main).value();
710
711       // surfaces are on separate layers, don't bother.
712       if (new_id_layer != current_id_layer) {
713          return false;
714       }
715
716       std::string const &new_id_str = this->lookup_name(new_id).value();
717       std::string const &cur_id_str = this->lookup_name(state.main).value();
718
719       auto const &layer = this->layers.get_layer(new_id_layer);
720
721       logdebug("layer info name: %s", layer->name.c_str());
722
723       if (layer->layouts.empty()) {
724          return false;
725       }
726
727       for (auto i = layer->layouts.cbegin(); i != layer->layouts.cend(); i++) {
728          logdebug("%d main_match '%s'", new_id_layer, i->main_match.c_str());
729          auto rem = std::regex(i->main_match);
730          if (std::regex_match(cur_id_str, rem)) {
731             // build the second one only if the first already matched
732             logdebug("%d sub_match '%s'", new_id_layer, i->sub_match.c_str());
733             auto res = std::regex(i->sub_match);
734             if (std::regex_match(new_id_str, res)) {
735                logdebug("layout matched!");
736                return true;
737             }
738          }
739       }
740    }
741
742    return false;
743 }
744
745 void App::try_layout(struct LayoutState & /*state*/,
746                      struct LayoutState const &new_layout,
747                      std::function<void(LayoutState const &nl)> apply) {
748    if (this->policy.layout_is_valid(new_layout)) {
749       apply(new_layout);
750    }
751 }
752
753 //                  _             _ _            _                 _
754 //   ___ ___  _ __ | |_ _ __ ___ | | | ___ _ __ | |__   ___   ___ | | _____
755 //  / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|
756 // | (_| (_) | | | | |_| | | (_) | | |  __/ |   | | | | (_) | (_) |   <\__ \
757 //  \___\___/|_| |_|\__|_|  \___/|_|_|\___|_|___|_| |_|\___/ \___/|_|\_\___/
758 //                                         |_____|
759 void controller_hooks::surface_created(uint32_t surface_id) {
760    this->app->surface_created(surface_id);
761 }
762
763 void controller_hooks::surface_removed(uint32_t surface_id) {
764    this->app->surface_removed(surface_id);
765 }
766
767 void controller_hooks::surface_visibility(uint32_t /*surface_id*/,
768                                           uint32_t /*v*/) {}
769
770 void controller_hooks::surface_destination_rectangle(uint32_t /*surface_id*/,
771                                                      uint32_t /*x*/,
772                                                      uint32_t /*y*/,
773                                                      uint32_t /*w*/,
774                                                      uint32_t /*h*/) {}
775
776 }  // namespace wm