X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwayland.hpp;h=2321fffa9c078ae0262c3a81387a499f0e625392;hb=2d220fc2257d24c4be7ca7b60ba526b654395220;hp=9a5541d7242d47751aa0a9fbaa189582ef9fb242;hpb=ac5350e948b0ac44fd8055f5c88d8e4dc85435bb;p=staging%2Fwindowmanager.git diff --git a/src/wayland.hpp b/src/wayland.hpp index 9a5541d..2321fff 100644 --- a/src/wayland.hpp +++ b/src/wayland.hpp @@ -6,8 +6,8 @@ #include "util.h" #include -#include #include +#include #include // _ _ @@ -18,18 +18,14 @@ // |___/ |_____|_| |___/ template struct wayland_proxy { - ProxyT *proxy; - - wayland_proxy(void *p) : proxy(static_cast(p)) {} - - virtual ~wayland_proxy() { - // If this is the nullptr, then it means it already was destroyed by a - // custom wayland dtor - if (this->proxy) { - logdebug("%s %p @ %p", __func__, this, this->proxy); - wl_proxy_destroy(reinterpret_cast(this->proxy)); - } - } + std::unique_ptr> proxy; + wayland_proxy(void *p) + : wayland_proxy(p, [](ProxyT *p) { + wl_proxy_destroy(reinterpret_cast(p)); + }) {} + wayland_proxy(void *p, std::function p_del) + : proxy(std::unique_ptr>( + static_cast(p), p_del)) {} }; // _ @@ -50,7 +46,6 @@ struct registry : public wayland_proxy { std::unordered_map bindings; registry(struct wl_display *d); - ~registry(); void add_global_handler(char const *iface, binder bind); @@ -70,7 +65,6 @@ struct display { struct registry r; display(); - ~display(); bool ok() const; void roundtrip(); int dispatch(); @@ -148,15 +142,14 @@ struct surface : public wayland_proxy, float opacity; surface(uint32_t i, struct controller *c); - ~surface() override; // Requests void set_visibility(uint32_t visibility); void set_opacity(wl_fixed_t opacity); void set_source_rectangle(int32_t x, int32_t y, int32_t width, - int32_t height); + int32_t height); void set_destination_rectangle(int32_t x, int32_t y, int32_t width, - int32_t height); + int32_t height); void set_configuration(int32_t width, int32_t height); void set_orientation(int32_t orientation); void screenshot(const char *filename); @@ -181,7 +174,6 @@ struct layer : public wayland_proxy, layer(uint32_t i, struct controller *c); layer(uint32_t i, int32_t w, int32_t h, struct controller *c); - ~layer() override; // Requests void set_visibility(uint32_t visibility); @@ -208,19 +200,9 @@ struct layer : public wayland_proxy, struct screen : public wayland_proxy, controller_child { screen(uint32_t i, struct controller *c, struct ivi_controller_screen *p); - - void clear() { ivi_controller_screen_clear(this->proxy); } - void add_layer(layer *l) { - ivi_controller_screen_add_layer(this->proxy, l->proxy); - } - void set_render_order(std::vector const &ro) { - struct wl_array wlro { - .size = ro.size() * sizeof(ro[0]), - .alloc = ro.capacity() * sizeof(ro[0]), - .data = const_cast(static_cast(ro.data())) - }; - ivi_controller_screen_set_render_order(this->proxy, &wlro); - } + void clear(); + void add_layer(layer *l); + void set_render_order(std::vector const &ro); }; // _ _ _ @@ -231,10 +213,11 @@ struct screen : public wayland_proxy, // struct controller : public wayland_proxy { std::unordered_map surface_proxy_to_id; - std::unordered_map> surfaces; std::unordered_map layer_proxy_to_id; - std::unordered_map> layers; std::unordered_map screen_proxy_to_id; + + std::unordered_map> surfaces; + std::unordered_map> layers; std::unordered_map> screens; typedef std::pair> @@ -250,14 +233,16 @@ struct controller : public wayland_proxy { void add_proxy_to_id_mapping(struct wl_output *p, uint32_t id); void remove_proxy_to_id_mapping(struct wl_output *p); - void add_task(char const *name, std::function &&f); + void add_task(char const *name, + std::function &&f); void execute_pending(); controller(struct wl_registry *r, uint32_t name, uint32_t version); - ~controller() override; // Requests - void commit_changes() const { ivi_controller_commit_changes(this->proxy); } + void commit_changes() const { + ivi_controller_commit_changes(this->proxy.get()); + } void layer_create(uint32_t id, int32_t w, int32_t h); void surface_create(uint32_t id);