wayland: introduce reverse mappings of proxy-ptr to id
[staging/windowmanager.git] / src / wayland.hpp
index fbb9704..699763e 100644 (file)
@@ -295,8 +295,11 @@ struct screen : public wayland_proxy<struct ivi_controller_screen>,
 //  \___\___/|_| |_|\__|_|  \___/|_|_|\___|_|
 //
 struct controller : public wayland_proxy<struct ivi_controller> {
+   std::unordered_map<uintptr_t, uint32_t> surface_proxy_to_id;
    std::unordered_map<uint32_t, std::unique_ptr<struct surface>> surfaces;
+   std::unordered_map<uintptr_t, uint32_t> layer_proxy_to_id;
    std::unordered_map<uint32_t, std::unique_ptr<struct layer>> layers;
+   std::unordered_map<uintptr_t, uint32_t> screen_proxy_to_id;
    std::unordered_map<uint32_t, std::unique_ptr<struct screen>> screens;
 
    typedef std::pair<char const *, std::function<void(struct controller *)>>
@@ -305,6 +308,36 @@ struct controller : public wayland_proxy<struct ivi_controller> {
 
    size output_size;
 
+   void add_proxy_to_id_mapping(struct ivi_controller_surface *p, uint32_t id) {
+      this->surface_proxy_to_id[uintptr_t(p)] = id;
+      logdebug("Add surface proxy mapping for %p (%u)", p, id);
+   }
+
+   void remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
+      logdebug("Remove surface proxy mapping for %p", p);
+      this->surface_proxy_to_id.erase(uintptr_t(p));
+   }
+
+   void add_proxy_to_id_mapping(struct ivi_controller_layer *p, uint32_t id) {
+      logdebug("Add layer proxy mapping for %p (%u)", p, id);
+      this->layer_proxy_to_id[uintptr_t(p)] = id;
+   }
+
+   void remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
+      logdebug("Remove layer proxy mapping for %p", p);
+      this->layer_proxy_to_id.erase(uintptr_t(p));
+   }
+
+   void add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
+      logdebug("Add screen proxy mapping for %p (%u)", p, id);
+      this->screen_proxy_to_id[uintptr_t(p)] = id;
+   }
+
+   void remove_proxy_to_id_mapping(struct wl_output *p) {
+      logdebug("Remove screen proxy mapping for %p", p);
+      this->screen_proxy_to_id.erase(uintptr_t(p));
+   }
+
    void add_task(char const *name,
                  std::function<void(struct controller *)> &&f) {
       this->pending.emplace_back(std::make_pair(name, f));