X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwayland.hpp;h=2321fffa9c078ae0262c3a81387a499f0e625392;hb=112a585f5d172592e5b1da895d3fd85b9b852e08;hp=60a045bc3b91a81078d924b63d10ce3c20372df7;hpb=88666c08dd76d09596aa9906f39d466c45d5979e;p=staging%2Fwindowmanager.git diff --git a/src/wayland.hpp b/src/wayland.hpp index 60a045b..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); @@ -241,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);