wayland: header order fixed, comment on controller member order
[staging/windowmanager.git] / src / wayland.hpp
index 2321fff..c47e218 100644 (file)
@@ -6,8 +6,8 @@
 #include "util.h"
 
 #include <functional>
-#include <memory>
 #include <unordered_map>
+#include <memory>
 #include <vector>
 
 //                      _                 _
@@ -19,6 +19,8 @@
 template <typename ProxyT>
 struct wayland_proxy {
    std::unique_ptr<ProxyT, std::function<void(ProxyT *)>> proxy;
+   wayland_proxy(wayland_proxy const &) = delete;
+   wayland_proxy &operator=(wayland_proxy const &) = delete;
    wayland_proxy(void *p)
       : wayland_proxy(p, [](ProxyT *p) {
            wl_proxy_destroy(reinterpret_cast<struct wl_proxy *>(p));
@@ -45,6 +47,8 @@ struct registry : public wayland_proxy<struct wl_registry> {
    typedef std::function<void(struct wl_registry *, uint32_t, uint32_t)> binder;
    std::unordered_map<std::string, binder> bindings;
 
+   registry(registry const &) = delete;
+   registry &operator=(registry const &) = delete;
    registry(struct wl_display *d);
 
    void add_global_handler(char const *iface, binder bind);
@@ -64,6 +68,8 @@ struct display {
    std::unique_ptr<struct wl_display, void (*)(struct wl_display *)> d;
    struct registry r;
 
+   display(display const &) = delete;
+   display &operator=(display const &) = delete;
    display();
    bool ok() const;
    void roundtrip();
@@ -83,6 +89,8 @@ struct output : wayland_proxy<struct wl_output> {
    int height{};
    int refresh{};
 
+   output(output const &) = delete;
+   output &operator=(output const &) = delete;
    output(struct wl_registry *r, uint32_t name, uint32_t v);
 
    // Events
@@ -122,6 +130,8 @@ struct controller_child {
    struct controller *parent;
    uint32_t id;
 
+   controller_child(controller_child const &) = delete;
+   controller_child &operator=(controller_child const &) = delete;
    controller_child(struct controller *c, uint32_t i) : parent(c), id(i) {}
    virtual ~controller_child() {}
 };
@@ -141,6 +151,8 @@ struct surface : public wayland_proxy<struct ivi_controller_surface>,
    int32_t visibility;
    float opacity;
 
+   surface(surface const &) = delete;
+   surface &operator=(surface const &) = delete;
    surface(uint32_t i, struct controller *c);
 
    // Requests
@@ -172,6 +184,8 @@ struct layer : public wayland_proxy<struct ivi_controller_layer>,
    int32_t visibility;
    float opacity;
 
+   layer(layer const &) = delete;
+   layer &operator=(layer const &) = delete;
    layer(uint32_t i, struct controller *c);
    layer(uint32_t i, int32_t w, int32_t h, struct controller *c);
 
@@ -199,6 +213,8 @@ struct layer : public wayland_proxy<struct ivi_controller_layer>,
 //
 struct screen : public wayland_proxy<struct ivi_controller_screen>,
                 controller_child {
+   screen(screen const &) = delete;
+   screen &operator=(screen const &) = delete;
    screen(uint32_t i, struct controller *c, struct ivi_controller_screen *p);
    void clear();
    void add_layer(layer *l);
@@ -212,6 +228,13 @@ struct screen : public wayland_proxy<struct ivi_controller_screen>,
 //  \___\___/|_| |_|\__|_|  \___/|_|_|\___|_|
 //
 struct controller : public wayland_proxy<struct ivi_controller> {
+   // HACK:
+   // The order of these member is mandatory, as when objects are destroyed
+   // they will call their parent (that's us right here!) and remove their
+   // proxy-to-id mapping. I.e. the *_proxy_to_id members need to be valid
+   // when the surfaces/layers/screens maps are destroyed. This sucks, but
+   // I cannot see a better solution w/o globals or some other horrible
+   // call-our-parent construct.
    std::unordered_map<uintptr_t, uint32_t> surface_proxy_to_id;
    std::unordered_map<uintptr_t, uint32_t> layer_proxy_to_id;
    std::unordered_map<uintptr_t, uint32_t> screen_proxy_to_id;