summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmre Ucan <eucan@de.adit-jv.com>2016-02-26 14:56:59 +0100
committerEugen Friedrich <efriedrich@de.adit-jv.com>2016-03-04 09:59:51 +0100
commit926bbe2c0b8e4158cb051edf6f8746fafa9872bf (patch)
tree999a0113582005af90b6b93019deadc711c39d83
parent6ddeb16f5a92100bae32cbcaed8fad2a27afdc8c (diff)
downloadwayland-ivi-extension-926bbe2c0b8e4158cb051edf6f8746fafa9872bf.tar.gz
ivi-controller: simplify get_surface function
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
-rw-r--r--weston-ivi-shell/src/ivi-controller-impl.c30
1 files 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;