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