wayland: remove surfaces that got destroyed
[staging/windowmanager.git] / src / wayland.cpp
index c19b0dc..38092e3 100644 (file)
@@ -32,6 +32,10 @@ void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
 
 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
 
+void display::flush() { wl_display_flush(this->d.get()); }
+
+int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
+
 //                 _     _
 //  _ __ ___  __ _(_)___| |_ _ __ _   _
 // | '__/ _ \/ _` | / __| __| '__| | | |
@@ -53,8 +57,9 @@ constexpr struct wl_registry_listener registry_listener = {
 }
 
 registry::registry(struct wl_display *d)
-   : wayland_proxy(wl_display_get_registry(d)) {
-   wl_registry_add_listener(this->proxy, &registry_listener, this);
+   : wayland_proxy(!d ? nullptr : wl_display_get_registry(d)) {
+   if (this->proxy)
+      wl_registry_add_listener(this->proxy, &registry_listener, this);
 }
 
 registry::~registry() {
@@ -502,6 +507,10 @@ void controller::surface_destroyed(uint32_t id) {
 void controller::surface_content(uint32_t id, int32_t content_state) {
    logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy,
             content_state);
+
+   if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
+      this->surfaces.erase(id);
+   }
 }
 
 //