hooked up genivi::surface and layer
[staging/windowmanager.git] / src / wayland.hpp
index 5cafd1a..54d0bd5 100644 (file)
@@ -24,8 +24,8 @@ struct wayland_proxy {
    virtual ~wayland_proxy() {
       // If this is the nullptr, then it means it already was destroyed by a
       // custom wayland dtor
-      logdebug("%s %p @ %p", __func__, this, this->proxy);
-      if (proxy) {
+      if (this->proxy) {
+         logdebug("%s %p @ %p", __func__, this, this->proxy);
          wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy));
       }
    }
@@ -51,6 +51,7 @@ struct display {
    std::unique_ptr<registry> r;
 
    display();
+   bool ok() const;
    void roundtrip();
 };
 
@@ -113,7 +114,7 @@ struct output : wayland_proxy<wl_output> {
    static constexpr wl_output_listener listener = {s_geometry, s_mode, s_done,
                                                    s_scale};
 };
-};
+}
 
 //  _ __   __ _ _ __ ___   ___  ___ _ __   __ _  ___ ___
 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
@@ -140,7 +141,70 @@ struct surface : public wayland_proxy<ivi_controller_surface> {
    surface(uint32_t i, ivi_controller *c);
    ~surface() override;
 
-   static constexpr ivi_controller_surface_listener listener = {};
+   void event_visibility(int32_t visibility);
+   void event_opacity(wl_fixed_t opacity);
+   void event_source_rectangle(int32_t x, int32_t y, int32_t width,
+                               int32_t height);
+   void event_destination_rectangle(int32_t x, int32_t y, int32_t width,
+                                    int32_t height);
+   void event_configuration(int32_t width, int32_t height);
+   void event_orientation(int32_t orientation);
+   void event_pixelformat(int32_t pixelformat);
+   void event_layer(struct ivi_controller_layer *layer);
+   void event_stats(uint32_t redraw_count, uint32_t frame_count,
+                    uint32_t update_count, uint32_t pid,
+                    const char *process_name);
+   void event_destroyed();
+   void event_content(int32_t content_state);
+
+   static void s_visibility(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t visibility);
+   static void s_opacity(void *data,
+                         struct ivi_controller_surface *ivi_controller_surface,
+                         wl_fixed_t opacity);
+   static void s_source_rectangle(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t x, int32_t y, int32_t width, int32_t height);
+   static void s_destination_rectangle(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t x, int32_t y, int32_t width, int32_t height);
+   static void s_configuration(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t width, int32_t height);
+   static void s_orientation(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t orientation);
+   static void s_pixelformat(
+      void *data, struct ivi_controller_surface *ivi_controller_surface,
+      int32_t pixelformat);
+   static void s_layer(void *data,
+                       struct ivi_controller_surface *ivi_controller_surface,
+                       struct ivi_controller_layer *layer);
+   static void s_stats(void *data,
+                       struct ivi_controller_surface *ivi_controller_surface,
+                       uint32_t redraw_count, uint32_t frame_count,
+                       uint32_t update_count, uint32_t pid,
+                       const char *process_name);
+   static void s_destroyed(
+      void *data, struct ivi_controller_surface *ivi_controller_surface);
+   static void s_content(void *data,
+                         struct ivi_controller_surface *ivi_controller_surface,
+                         int32_t content_state);
+
+   static constexpr ivi_controller_surface_listener listener = {
+      s_visibility,
+      s_opacity,
+      s_source_rectangle,
+      s_destination_rectangle,
+      s_configuration,
+      s_orientation,
+      s_pixelformat,
+      s_layer,
+      s_stats,
+      s_destroyed,
+      s_content,
+   };
 };
 
 //  _
@@ -155,7 +219,47 @@ struct layer : public wayland_proxy<ivi_controller_layer> {
    layer(uint32_t i, ivi_controller *c);
    ~layer() override;
 
-   static constexpr ivi_controller_layer_listener listener = {};
+   void event_visibility(int32_t visibility);
+   void event_opacity(wl_fixed_t opacity);
+   void event_source_rectangle(int32_t x, int32_t y, int32_t width,
+                               int32_t height);
+   void event_destination_rectangle(int32_t x, int32_t y, int32_t width,
+                                    int32_t height);
+   void event_configuration(int32_t width, int32_t height);
+   void event_orientation(int32_t orientation);
+   void event_screen(struct wl_output *screen);
+   void event_destroyed();
+
+   static void s_visibility(void *data,
+                            struct ivi_controller_layer *ivi_controller_layer,
+                            int32_t visibility);
+   static void s_opacity(void *data,
+                         struct ivi_controller_layer *ivi_controller_layer,
+                         wl_fixed_t opacity);
+   static void s_source_rectangle(
+      void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x,
+      int32_t y, int32_t width, int32_t height);
+   static void s_destination_rectangle(
+      void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x,
+      int32_t y, int32_t width, int32_t height);
+   static void s_configuration(
+      void *data, struct ivi_controller_layer *ivi_controller_layer,
+      int32_t width, int32_t height);
+   static void s_orientation(void *data,
+                             struct ivi_controller_layer *ivi_controller_layer,
+                             int32_t orientation);
+   static void s_screen(void *data,
+                        struct ivi_controller_layer *ivi_controller_layer,
+                        struct wl_output *screen);
+   static void s_destroyed(void *data,
+                           struct ivi_controller_layer *ivi_controller_layer);
+
+   static constexpr ivi_controller_layer_listener listener = {
+      s_visibility,       s_opacity,
+      s_source_rectangle, s_destination_rectangle,
+      s_configuration,    s_orientation,
+      s_screen,           s_destroyed,
+   };
 };
 
 //