app/wayland: move late-tasks to App
[staging/windowmanager.git] / src / app.hpp
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 //
18 // Created by mfritzsc on 7/11/17.
19 //
20
21 #ifndef TMCAGLWM_APP_HPP
22 #define TMCAGLWM_APP_HPP
23
24 #include <json-c/json.h>
25 #include <memory>
26
27 #include "afb_binding_api.hpp"
28 #include "controller_hooks.hpp"
29 #include "layers.hpp"
30 #include "layout.hpp"
31 #include "result.hpp"
32 #include "wayland.hpp"
33 #include "config.hpp"
34
35 namespace wl {
36 struct display;
37 }
38
39 namespace genivi {
40 struct controller;
41 }
42
43 namespace wm {
44
45 struct App {
46    struct binding_api api;
47    struct controller_hooks chooks;
48
49    // This is the one thing, we do not own.
50    struct wl::display *display;
51
52    std::unique_ptr<struct genivi::controller> controller;
53    std::vector<std::unique_ptr<struct wl::output>> outputs;
54
55    struct config config;
56
57    layouts_type layouts;
58    layer_map layers;
59
60    typedef std::pair<char const *, std::function<void()>> name_task_pair;
61    std::vector<name_task_pair> pending;
62
63    App(wl::display *d);
64    ~App();
65
66    App(App const &) = delete;
67    App &operator=(App const &) = delete;
68
69    int init();
70    int dispatch_events();
71    int init_layout();
72    void surface_set_layout(uint32_t surface_id);
73
74    void add_task(char const *name, std::function<void()> &&f);
75    void execute_pending();
76
77    void surface_created(uint32_t surface_id);
78    void surface_removed(uint32_t surface_id);
79 };
80
81 }  // namespace wm
82
83 #endif  // TMCAGLWM_APP_HPP