From 926bbe2c0b8e4158cb051edf6f8746fafa9872bf Mon Sep 17 00:00:00 2001 From: Emre Ucan Date: Fri, 26 Feb 2016 14:56:59 +0100 Subject: ivi-controller: simplify get_surface function Signed-off-by: Emre Ucan --- weston-ivi-shell/src/ivi-controller-impl.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c index 235aacd..88768cb 100644 --- a/weston-ivi-shell/src/ivi-controller-impl.c +++ b/weston-ivi-shell/src/ivi-controller-impl.c @@ -111,14 +111,12 @@ unbind_resource_controller(struct wl_resource *resource) } static struct ivisurface* -get_surface(struct wl_list *list_surf, uint32_t id_surface) +get_surface(struct wl_list *list_surf, struct ivi_layout_surface *layout_surface) { struct ivisurface *ivisurf = NULL; - uint32_t ivisurf_id = 0; wl_list_for_each(ivisurf, list_surf, link) { - ivisurf_id = ivi_extension_get_id_of_surface(ivisurf->shell, ivisurf->layout_surface); - if (ivisurf_id == id_surface) { + if (layout_surface == ivisurf->layout_surface) { return ivisurf; } } @@ -1052,9 +1050,15 @@ controller_surface_create(struct wl_client *client, struct ivicontroller *ctrl = wl_resource_get_user_data(resource); struct ivishell *shell = ctrl->shell; const struct ivi_layout_surface_properties *prop; + struct ivi_layout_surface *layout_surface = NULL; struct ivisurface *ivisurf = NULL; - ivisurf = get_surface(&shell->list_surface, id_surface); + layout_surface = ivi_extension_get_surface_from_id(shell, id_surface); + if (layout_surface == NULL) { + return; + } + + ivisurf = get_surface(&shell->list_surface, layout_surface); if (ivisurf == NULL) { return; } @@ -1228,12 +1232,6 @@ create_surface(struct ivishell *shell, struct ivisurface *ivisurf = NULL; struct ivicontroller *controller = NULL; - ivisurf = get_surface(&shell->list_surface, id_surface); - if (ivisurf != NULL) { - weston_log("id_surface is already created\n"); - return NULL; - } - ivisurf = calloc(1, sizeof *ivisurf); if (ivisurf == NULL) { weston_log("no memory to allocate client surface\n"); @@ -1328,11 +1326,8 @@ surface_event_remove(struct ivi_layout_surface *layout_surface, struct wl_resource *resource; struct ivishell *shell = userdata; struct ivisurface *ivisurf = NULL; - uint32_t id_surface = 0; - - id_surface = ivi_extension_get_id_of_surface(shell, layout_surface); - ivisurf = get_surface(&shell->list_surface, id_surface); + ivisurf = get_surface(&shell->list_surface, layout_surface); if (ivisurf == NULL) { weston_log("id_surface is not created yet\n"); return; @@ -1355,11 +1350,8 @@ surface_event_configure(struct ivi_layout_surface *layout_surface, struct ivishell *shell = userdata; struct ivisurface *ivisurf = NULL; const struct ivi_layout_surface_properties *prop; - uint32_t id_surface = 0; - - id_surface = ivi_extension_get_id_of_surface(shell, layout_surface); - ivisurf = get_surface(&shell->list_surface, id_surface); + ivisurf = get_surface(&shell->list_surface, layout_surface); if (ivisurf == NULL) { weston_log("id_surface is not created yet\n"); return; -- cgit v1.2.1