Add visibility dst-rect controller hooks
[staging/windowmanager.git] / src / wayland.cpp
index 92e152d..05e155f 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <utility>
 
+#include "util.hpp"
 #include "wayland.hpp"
 
 //                                                                  _
@@ -43,6 +44,29 @@ void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
 
 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
 
+int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
+
+int display::read_events() {
+   ST();
+   // XXX: uhm, how?!
+   while (wl_display_prepare_read(this->d.get()) == -1) {
+      STN(pending_events_dispatch);
+      if (wl_display_dispatch_pending(this->d.get()) == -1) {
+         return -1;
+      }
+   }
+
+   if (wl_display_flush(this->d.get()) == -1) {
+      return -1;
+   }
+
+   if (wl_display_read_events(this->d.get()) == -1) {
+      wl_display_cancel_read(this->d.get());
+   }
+
+   return 0;
+}
+
 void display::flush() { wl_display_flush(this->d.get()); }
 
 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
@@ -546,7 +570,7 @@ constexpr struct ivi_controller_surface_listener surface_listener = {
 surface::surface(uint32_t i, struct controller *c)
    : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
                    [c, i](ivi_controller_surface *s) {
-                      logdebug("~surface surface %i @ %d", i, s);
+                      logdebug("~surface surface %i @ %p", i, s);
                       c->remove_proxy_to_id_mapping(s);
                       ivi_controller_surface_destroy(s, 1);
                    }),
@@ -600,6 +624,7 @@ void controller::surface_visibility(struct surface *s, int32_t visibility) {
    logdebug("genivi::surface %s @ %d v %i", __func__, s->id,
             visibility);
    this->sprops[s->id].visibility = visibility;
+   this->chooks->surface_visibility(s->id, visibility);
 }
 
 void controller::surface_opacity(struct surface *s, float opacity) {
@@ -622,6 +647,7 @@ void controller::surface_destination_rectangle(struct surface *s, int32_t x,
    logdebug("genivi::surface %s @ %d x %i y %i w %i h %i", __func__,
             s->id, x, y, width, height);
    this->sprops[s->id].dst_rect = rect{width, height, x, y};
+   this->chooks->surface_destination_rectangle(s->id, x, y, width, height);
 }
 
 void controller::surface_configuration(struct surface *s, int32_t width,
@@ -653,7 +679,7 @@ void controller::surface_stats(struct surface *s, uint32_t redraw_count,
                                uint32_t frame_count, uint32_t update_count,
                                uint32_t pid, const char *process_name) {
    logdebug("genivi::surface %s @ %d r %u f %u u %u pid %u p %s", __func__,
-            this->proxy.get(), redraw_count, frame_count, update_count, pid,
+            s->id, redraw_count, frame_count, update_count, pid,
             process_name);
 }