Fix crashed application can re-launch
[apps/agl-service-windowmanager-2017.git] / src / wayland_ivi_wm.cpp
index 5cc16b2..522295d 100644 (file)
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-#include <utility>
-
-#include "util.hpp"
 #include "wayland_ivi_wm.hpp"
 #include "hmi-debug.h"
 
@@ -219,31 +216,31 @@ void surface_visibility_changed(
     void *data, struct ivi_wm * /*ivi_wm*/,
     uint32_t surface_id, int32_t visibility)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_visibility_changed(s, visibility);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_visibility_changed(surface_id, visibility);
 }
 
 void surface_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
                              uint32_t surface_id, wl_fixed_t opacity)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_opacity_changed(s, float(wl_fixed_to_double(opacity)));
+    auto c = static_cast<struct controller *>(data);
+    c->surface_opacity_changed(surface_id, float(wl_fixed_to_double(opacity)));
 }
 
 void surface_source_rectangle_changed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
     int32_t x, int32_t y, int32_t width, int32_t height)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_source_rectangle_changed(s, x, y, width, height);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_source_rectangle_changed(surface_id, x, y, width, height);
 }
 
 void surface_destination_rectangle_changed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
     int32_t x, int32_t y, int32_t width, int32_t height)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_destination_rectangle_changed(s, x, y, width, height);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_destination_rectangle_changed(surface_id, x, y, width, height);
 }
 
 void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
@@ -255,8 +252,8 @@ void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
 void surface_destroyed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_destroyed(s, surface_id);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_destroyed(surface_id);
 }
 
 void surface_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
@@ -270,52 +267,52 @@ void surface_size_changed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
     int32_t width, int32_t height)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_size_changed(s, width, height);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_size_changed(surface_id, width, height);
 }
 
 void surface_stats_received(void *data, struct ivi_wm * /*ivi_wm*/,
                             uint32_t surface_id, uint32_t frame_count, uint32_t pid)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_stats_received(s, surface_id, frame_count, pid);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_stats_received(surface_id, frame_count, pid);
 }
 
 void surface_added_to_layer(void *data, struct ivi_wm * /*ivi_wm*/,
                             uint32_t layer_id, uint32_t surface_id)
 {
-    auto s = static_cast<struct surface *>(data);
-    s->parent->surface_added_to_layer(s, layer_id, surface_id);
+    auto c = static_cast<struct controller *>(data);
+    c->surface_added_to_layer(layer_id, surface_id);
 }
 
 void layer_visibility_changed(void *data, struct ivi_wm * /*ivi_wm*/,
                               uint32_t layer_id, int32_t visibility)
 {
-    auto l = static_cast<struct layer *>(data);
-    l->parent->layer_visibility_changed(l, layer_id, visibility);
+    auto c = static_cast<struct controller *>(data);
+    c->layer_visibility_changed(layer_id, visibility);
 }
 
 void layer_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
                            uint32_t layer_id, wl_fixed_t opacity)
 {
-    auto l = static_cast<struct layer *>(data);
-    l->parent->layer_opacity_changed(l, layer_id, float(wl_fixed_to_double(opacity)));
+    auto c = static_cast<struct controller *>(data);
+    c->layer_opacity_changed(layer_id, float(wl_fixed_to_double(opacity)));
 }
 
 void layer_source_rectangle_changed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
     int32_t x, int32_t y, int32_t width, int32_t height)
 {
-    auto l = static_cast<struct layer *>(data);
-    l->parent->layer_source_rectangle_changed(l, layer_id, x, y, width, height);
+    auto c = static_cast<struct controller *>(data);
+    c->layer_source_rectangle_changed(layer_id, x, y, width, height);
 }
 
 void layer_destination_rectangle_changed(
     void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
     int32_t x, int32_t y, int32_t width, int32_t height)
 {
-    auto l = static_cast<struct layer *>(data);
-    l->parent->layer_destination_rectangle_changed(l, layer_id, x, y, width, height);
+    auto c = static_cast<struct controller *>(data);
+    c->layer_destination_rectangle_changed(layer_id, x, y, width, height);
 }
 
 void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
@@ -326,8 +323,8 @@ void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
 
 void layer_destroyed(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id)
 {
-    auto l = static_cast<struct layer *>(data);
-    l->parent->layer_destroyed(l, layer_id);
+    auto c = static_cast<struct controller *>(data);
+    c->layer_destroyed(layer_id);
 }
 
 void layer_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
@@ -438,6 +435,11 @@ void layer::set_visibility(uint32_t visibility)
     ivi_wm_set_layer_visibility(this->parent->proxy.get(), this->id, visibility);
 }
 
+void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height)
+{
+    ivi_wm_set_layer_source_rectangle(this->parent->proxy.get(), this->id, x, y, width, height);
+}
+
 void layer::set_destination_rectangle(int32_t x, int32_t y,
                                       int32_t width, int32_t height)
 {
@@ -554,56 +556,55 @@ void controller::layer_error_detected(uint32_t object_id,
               this->proxy.get(), object_id, error_code, error_text);
 }
 
-void controller::surface_visibility_changed(struct surface *s, int32_t visibility)
+void controller::surface_visibility_changed(uint32_t id, int32_t visibility)
 {
-    HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, s->id,
+    HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, id,
               visibility);
-    this->sprops[s->id].visibility = visibility;
-    this->chooks->surface_visibility(s->id, visibility);
+    this->sprops[id].visibility = visibility;
+    this->chooks->surface_visibility(id, visibility);
 }
 
-void controller::surface_opacity_changed(struct surface *s, float opacity)
+void controller::surface_opacity_changed(uint32_t id, float opacity)
 {
-    HMI_DEBUG("wm", "compositor::surface %s @ %d o %f", __func__, s->id,
-              opacity);
-    this->sprops[s->id].opacity = opacity;
+    HMI_DEBUG("wm", "compositor::surface %s @ %d o %f",
+                __func__, id, opacity);
+    this->sprops[id].opacity = opacity;
 }
 
-void controller::surface_source_rectangle_changed(struct surface *s, int32_t x,
+void controller::surface_source_rectangle_changed(uint32_t id, int32_t x,
                                                   int32_t y, int32_t width,
                                                   int32_t height)
 {
     HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
-              s->id, x, y, width, height);
-    this->sprops[s->id].src_rect = rect{width, height, x, y};
+              id, x, y, width, height);
+    this->sprops[id].src_rect = rect{width, height, x, y};
 }
 
-void controller::surface_destination_rectangle_changed(struct surface *s, int32_t x,
+void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x,
                                                        int32_t y, int32_t width,
                                                        int32_t height)
 {
     HMI_DEBUG("wm", "compositor::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);
+              id, x, y, width, height);
+    this->sprops[id].dst_rect = rect{width, height, x, y};
+    this->chooks->surface_destination_rectangle(id, x, y, width, height);
 }
 
-void controller::surface_size_changed(struct surface *s, int32_t width,
+void controller::surface_size_changed(uint32_t id, int32_t width,
                                       int32_t height)
 {
-    HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, s->id,
+    HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, id,
               width, height);
-    this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
+    this->sprops[id].size = size{uint32_t(width), uint32_t(height)};
 }
 
-void controller::surface_added_to_layer(struct surface *s,
-                                        uint32_t layer_id, uint32_t surface_id)
+void controller::surface_added_to_layer(uint32_t layer_id, uint32_t surface_id)
 {
     HMI_DEBUG("wm", "compositor::surface %s @ %d l %u",
               __func__, layer_id, surface_id);
 }
 
-void controller::surface_stats_received(struct surface *s, uint32_t surface_id,
+void controller::surface_stats_received(uint32_t surface_id,
                                         uint32_t frame_count, uint32_t pid)
 {
     HMI_DEBUG("wm", "compositor::surface %s @ %d f %u pid %u",
@@ -619,23 +620,16 @@ void controller::surface_created(uint32_t id)
         this->surfaces[id] = std::make_unique<struct surface>(id, this);
         this->chooks->surface_created(id);
 
-        // TODO: If Clipping is necessary, this process should be modified.
-        {
-            // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
-            // for resizing wayland surface when switching from split to full surface.
-            ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
-
-            // Set source reactangle even if we should not need to set it
-            // for enable setting for destination region.
-            this->surfaces[id]->set_source_rectangle(0, 0, this->output_size.w, this->output_size.h);
+        // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
+        // for resizing wayland surface when switching from split to full surface.
+        ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
 
-            // Flush display
-            this->display->flush();
-        }
+        // Flush display
+        this->display->flush();
     }
 }
 
-void controller::surface_destroyed(struct surface *s, uint32_t surface_id)
+void controller::surface_destroyed(uint32_t surface_id)
 {
     HMI_DEBUG("wm", "compositor::surface %s @ %d", __func__, surface_id);
     this->chooks->surface_removed(surface_id);
@@ -650,19 +644,19 @@ void controller::surface_error_detected(uint32_t object_id,
               this->proxy.get(), object_id, error_code, error_text);
 }
 
-void controller::layer_visibility_changed(struct layer *l, uint32_t layer_id, int32_t visibility)
+void controller::layer_visibility_changed(uint32_t layer_id, int32_t visibility)
 {
     HMI_DEBUG("wm", "compositor::layer %s @ %d v %i", __func__, layer_id, visibility);
     this->lprops[layer_id].visibility = visibility;
 }
 
-void controller::layer_opacity_changed(struct layer *l, uint32_t layer_id, float opacity)
+void controller::layer_opacity_changed(uint32_t layer_id, float opacity)
 {
     HMI_DEBUG("wm", "compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
     this->lprops[layer_id].opacity = opacity;
 }
 
-void controller::layer_source_rectangle_changed(struct layer *l, uint32_t layer_id,
+void controller::layer_source_rectangle_changed(uint32_t layer_id,
                                                 int32_t x, int32_t y,
                                                 int32_t width, int32_t height)
 {
@@ -671,7 +665,7 @@ void controller::layer_source_rectangle_changed(struct layer *l, uint32_t layer_
     this->lprops[layer_id].src_rect = rect{width, height, x, y};
 }
 
-void controller::layer_destination_rectangle_changed(struct layer *l, uint32_t layer_id,
+void controller::layer_destination_rectangle_changed(uint32_t layer_id,
                                                      int32_t x, int32_t y,
                                                      int32_t width, int32_t height)
 {
@@ -680,27 +674,7 @@ void controller::layer_destination_rectangle_changed(struct layer *l, uint32_t l
     this->lprops[layer_id].dst_rect = rect{width, height, x, y};
 }
 
-void controller::layer_configuration(struct layer *l, int32_t width,
-                                     int32_t height)
-{
-    HMI_DEBUG("wm", "compositor::layer %s @ %d w %i h %i", __func__, l->id,
-              width, height);
-    this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
-}
-
-void controller::layer_orientation(struct layer *l, int32_t orientation)
-{
-    HMI_DEBUG("wm", "compositor::layer %s @ %d o %i", __func__, l->id,
-              orientation);
-    this->lprops[l->id].orientation = orientation;
-}
-
-void controller::layer_screen(struct layer *l, struct wl_output *screen)
-{
-    HMI_DEBUG("wm", "compositor::layer %s @ %d s %p", __func__, l->id, screen);
-}
-
-void controller::layer_destroyed(struct layer *l, uint32_t layer_id)
+void controller::layer_destroyed(uint32_t layer_id)
 {
     HMI_DEBUG("wm", "compositor::layer %s @ %d", __func__, layer_id);
     this->lprops.erase(layer_id);