4 #include "ivi-controller-client-protocol.h"
13 // __ ____ _ _ _| | __ _ _ __ __| | _ __ _ __ _____ ___ _
14 // \ \ /\ / / _` | | | | |/ _` | '_ \ / _` | | '_ \| '__/ _ \ \/ / | | |
15 // \ V V / (_| | |_| | | (_| | | | | (_| | | |_) | | | (_) > <| |_| |
16 // \_/\_/ \__,_|\__, |_|\__,_|_| |_|\__,_|____| .__/|_| \___/_/\_\\__, |
17 // |___/ |_____|_| |___/
18 template <typename ProxyT>
19 struct wayland_proxy {
22 wayland_proxy(void *p) : proxy(static_cast<ProxyT *>(p)) {}
24 virtual ~wayland_proxy() {
25 // If this is the nullptr, then it means it already was destroyed by a
26 // custom wayland dtor
28 logdebug("%s %p @ %p", __func__, this, this->proxy);
29 wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy));
35 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
36 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
37 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
38 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
44 // __| (_)___ _ __ | | __ _ _ _
45 // / _` | / __| '_ \| |/ _` | | | |
46 // | (_| | \__ \ |_) | | (_| | |_| |
47 // \__,_|_|___/ .__/|_|\__,_|\__, |
50 std::unique_ptr<wl_display, void (*)(wl_display *)> d;
51 std::unique_ptr<registry> r;
60 // _ __ ___ __ _(_)___| |_ _ __ _ _
61 // | '__/ _ \/ _` | / __| __| '__| | | |
62 // | | | __/ (_| | \__ \ |_| | | |_| |
63 // |_| \___|\__, |_|___/\__|_| \__, |
65 struct registry : public wayland_proxy<wl_registry> {
66 typedef std::function<void(wl_registry *, uint32_t, uint32_t)> binder;
67 std::map<std::string, binder> bindings;
69 registry(wl_display *d);
72 void add_global_handler(char const *iface, binder bind);
75 void global(uint32_t name, char const *iface, uint32_t v);
76 void global_remove(uint32_t name);
80 // ___ _ _| |_ _ __ _ _| |_
81 // / _ \| | | | __| '_ \| | | | __|
82 // | (_) | |_| | |_| |_) | |_| | |_
83 // \___/ \__,_|\__| .__/ \__,_|\__|
85 struct output : wayland_proxy<wl_output> {
86 output(wl_registry *registry, uint32_t name, uint32_t version);
89 void geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, int32_t subpel,
90 char const *make, char const *model, int32_t tx);
91 void mode(uint32_t flags, int32_t w, int32_t h, int32_t r);
93 void scale(int32_t factor);
97 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
98 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
99 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
100 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
103 // __ _ ___ _ __ (_)_ _(_)
104 // / _` |/ _ \ '_ \| \ \ / / |
105 // | (_| | __/ | | | |\ V /| |
106 // \__, |\___|_| |_|_| \_/ |_|
111 // ___ _ _ _ __ / _| __ _ ___ ___
112 // / __| | | | '__| |_ / _` |/ __/ _ \
113 // \__ \ |_| | | | _| (_| | (_| __/
114 // |___/\__,_|_| |_| \__,_|\___\___|
116 struct surface : public wayland_proxy<ivi_controller_surface> {
119 surface(uint32_t i, ivi_controller *c);
123 void visibility(int32_t visibility);
124 void opacity(wl_fixed_t opacity);
125 void source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
126 void destination_rectangle(int32_t x, int32_t y, int32_t width,
128 void configuration(int32_t width, int32_t height);
129 void orientation(int32_t orientation);
130 void pixelformat(int32_t pixelformat);
131 void layer(struct ivi_controller_layer *layer);
132 void stats(uint32_t redraw_count, uint32_t frame_count,
133 uint32_t update_count, uint32_t pid, const char *process_name);
135 void content(int32_t content_state);
139 // | | __ _ _ _ ___ _ __
140 // | |/ _` | | | |/ _ \ '__|
141 // | | (_| | |_| | __/ |
142 // |_|\__,_|\__, |\___|_|
144 struct layer : public wayland_proxy<ivi_controller_layer> {
147 layer(uint32_t i, ivi_controller *c);
151 void visibility(int32_t visibility);
152 void opacity(wl_fixed_t opacity);
153 void source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
154 void destination_rectangle(int32_t x, int32_t y, int32_t width,
156 void configuration(int32_t width, int32_t height);
157 void orientation(int32_t orientation);
158 void screen(struct wl_output *screen);
163 // ___ ___ _ __ ___ ___ _ __
164 /// __|/ __| '__/ _ \/ _ \ '_ \
165 //\__ \ (__| | | __/ __/ | | |
166 //|___/\___|_| \___|\___|_| |_|
168 struct screen : public wayland_proxy<ivi_controller_screen> {
171 screen(uint32_t i, ivi_controller_screen *p);
175 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
176 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
177 // | (_| (_) | | | | |_| | | (_) | | | __/ |
178 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
180 struct controller : public wayland_proxy<ivi_controller> {
181 std::map<uint32_t, std::unique_ptr<surface>> surfaces;
182 std::map<uint32_t, std::unique_ptr<layer>> layers;
183 std::map<uint32_t, std::unique_ptr<screen>> screens;
185 controller(wl_registry *r, uint32_t name, uint32_t version);
186 ~controller() override;
189 void screen(uint32_t id, ivi_controller_screen *screen);
190 void layer(uint32_t id);
191 void surface(uint32_t id);
192 void error(int32_t oid, int32_t otype, int32_t code, char const *text);
196 #endif // !WM_WAYLAND_HPP