summaryrefslogtreecommitdiff
path: root/weston-ivi-shell
diff options
context:
space:
mode:
authorEmre Ucan <eucan@de.adit-jv.com>2015-08-27 11:09:33 +0200
committerNobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp>2015-09-22 13:15:55 +0900
commit5364ac649ae6190210b7a1fba6ee50e0f140f511 (patch)
treec14c102a840570e7693188fa66c604df697a8799 /weston-ivi-shell
parent6b0a64bf9bf33775054cc2214f83329b83e3ff1c (diff)
downloadwayland-ivi-extension-5364ac649ae6190210b7a1fba6ee50e0f140f511.tar.gz
ivi-controller: remove struct ivicontroller_surface
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Diffstat (limited to 'weston-ivi-shell')
-rw-r--r--weston-ivi-shell/src/ivi-controller-impl.c156
-rw-r--r--weston-ivi-shell/src/ivi-extension.h1
2 files changed, 30 insertions, 127 deletions
diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c
index 969ad34..30c0b14 100644
--- a/weston-ivi-shell/src/ivi-controller-impl.c
+++ b/weston-ivi-shell/src/ivi-controller-impl.c
@@ -40,14 +40,12 @@ struct iviscreen;
struct ivisurface {
struct wl_list link;
- struct wl_client *client;
struct ivishell *shell;
uint32_t update_count;
struct ivi_layout_surface *layout_surface;
struct wl_listener surface_destroy_listener;
struct ivilayer *on_layer;
- uint32_t controller_surface_count;
- int can_be_removed;
+ struct wl_list resource_list;
};
struct ivilayer {
@@ -66,16 +64,6 @@ struct iviscreen {
struct weston_output *output;
};
-struct ivicontroller_surface {
- struct wl_resource *resource;
- uint32_t id;
- uint32_t id_surface;
- struct wl_client *client;
- struct wl_list link;
- struct ivishell *shell;
- int implementation_set;
-};
-
struct ivicontroller_layer {
struct wl_resource *resource;
uint32_t id;
@@ -115,32 +103,7 @@ static void surface_event_remove(struct ivi_layout_surface *, void *);
static void
destroy_ivicontroller_surface(struct wl_resource *resource)
{
- struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
- struct ivishell *shell = ivisurf->shell;
- struct ivicontroller_surface *ctrlsurf = NULL;
- struct ivicontroller_surface *next = NULL;
- int is_removed = 0;
-
- wl_list_for_each_safe(ctrlsurf, next,
- &shell->list_controller_surface, link) {
-
- if (resource != ctrlsurf->resource) {
- continue;
- }
-
- wl_list_remove(&ctrlsurf->link);
- is_removed = 1;
- free(ctrlsurf);
- ctrlsurf = NULL;
- --ivisurf->controller_surface_count;
- break;
- }
-
- if ((is_removed) && (ivisurf->controller_surface_count == 0)) {
- if (ivisurf->can_be_removed) {
- free(ivisurf);
- }
- }
+ wl_list_remove(wl_resource_get_link(resource));
}
static void
@@ -456,17 +419,10 @@ send_surface_prop(struct ivi_layout_surface *layout_surface,
void *userdata)
{
struct ivisurface *ivisurf = userdata;
- struct ivishell *shell = ivisurf->shell;
- struct ivicontroller_surface *ctrlsurf = NULL;
- uint32_t id_surface = 0;
-
- id_surface = ivi_extension_get_id_of_surface(shell, layout_surface);
+ struct wl_resource *resource;
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
- }
- send_surface_event(ctrlsurf->resource, ivisurf, prop, mask);
+ wl_resource_for_each(resource, &ivisurf->resource_list) {
+ send_surface_event(resource, ivisurf, prop, mask);
}
update_surface_prop(ivisurf, mask);
@@ -1216,63 +1172,33 @@ controller_surface_create(struct wl_client *client,
uint32_t id_surface,
uint32_t id)
{
+ struct wl_resource *surf_resource;
struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
struct ivishell *shell = ctrl->shell;
- struct ivicontroller_surface *ctrlsurf = NULL;
const struct ivi_layout_surface_properties *prop;
struct ivisurface *ivisurf = NULL;
- struct ivicontroller_surface *ctrl_link = NULL;
ivisurf = get_surface(&shell->list_surface, id_surface);
if (ivisurf == NULL) {
return;
}
- ctrlsurf = calloc(1, sizeof *ctrlsurf);
- if (!ctrlsurf) {
- weston_log("no memory to allocate controller surface\n");
- return;
- }
-
- ctrlsurf->shell = shell;
- ctrlsurf->client = client;
- ctrlsurf->id = id;
- ctrlsurf->id_surface = id_surface;
- wl_list_insert(&shell->list_controller_surface, &ctrlsurf->link);
-
- ctrlsurf->resource = wl_resource_create(client,
+ surf_resource = wl_resource_create(client,
&ivi_controller_surface_interface, 1, id);
- if (ctrlsurf->resource == NULL) {
+ if (surf_resource == NULL) {
weston_log("couldn't surface object");
return;
}
- wl_list_for_each(ctrl_link, &shell->list_controller_surface, link) {
- if ((ctrl_link->implementation_set == 0) &&
- (ctrl_link->id_surface == id_surface) &&
- (ctrl_link->shell == shell) &&
- (ctrl_link->client != client)) {
- ++ivisurf->controller_surface_count;
- wl_resource_set_implementation(ctrl_link->resource,
- &controller_surface_implementation,
- ivisurf, destroy_ivicontroller_surface);
- ctrl_link->implementation_set = 1;
- }
- }
-
- ++ivisurf->controller_surface_count;
-
- wl_resource_set_implementation(ctrlsurf->resource,
+ wl_list_insert(&ivisurf->resource_list, wl_resource_get_link(surf_resource));
+ wl_resource_set_implementation(surf_resource,
&controller_surface_implementation,
ivisurf, destroy_ivicontroller_surface);
- ctrlsurf->implementation_set = 1;
-
prop = ivi_extension_get_properties_of_surface(shell, ivisurf->layout_surface);
ivi_extension_surface_set_content_observer(shell, ivisurf->layout_surface, surface_event_content, shell);
- send_surface_event(ctrlsurf->resource, ivisurf,
- prop, IVI_NOTIFICATION_ALL);
+ send_surface_event(surf_resource, ivisurf, prop, IVI_NOTIFICATION_ALL);
}
static const struct ivi_controller_interface controller_implementation = {
@@ -1432,6 +1358,7 @@ create_surface(struct ivishell *shell,
ivisurf->shell = shell;
ivisurf->layout_surface = layout_surface;
wl_list_insert(&shell->list_surface, &ivisurf->link);
+ wl_list_init(&ivisurf->resource_list);
wl_list_for_each(controller, &shell->list_controller, link) {
ivi_controller_send_surface(controller->resource,
@@ -1502,10 +1429,10 @@ static void
surface_event_create(struct ivi_layout_surface *layout_surface,
void *userdata)
{
+ struct wl_resource *resource;
struct ivishell *shell = userdata;
struct ivisurface *ivisurf = NULL;
uint32_t id_surface = 0;
- struct ivicontroller_surface *ctrlsurf = NULL;
id_surface = ivi_extension_get_id_of_surface(shell, layout_surface);
@@ -1515,11 +1442,8 @@ surface_event_create(struct ivi_layout_surface *layout_surface,
return;
}
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
- }
- ivi_controller_surface_send_content(ctrlsurf->resource, IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_AVAILABLE);
+ wl_resource_for_each(resource, &ivisurf->resource_list) {
+ ivi_controller_surface_send_content(resource, IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_AVAILABLE);
}
}
@@ -1527,51 +1451,35 @@ static void
surface_event_remove(struct ivi_layout_surface *layout_surface,
void *userdata)
{
+ struct wl_resource *resource;
struct ivishell *shell = userdata;
- struct ivicontroller_surface *ctrlsurf = NULL;
struct ivisurface *ivisurf = NULL;
- struct ivisurface *next = NULL;
uint32_t id_surface = 0;
- int is_removed = 0;
-
- wl_list_for_each_safe(ivisurf, next, &shell->list_surface, link) {
- if (layout_surface != ivisurf->layout_surface) {
- continue;
- }
-
- wl_list_remove(&ivisurf->link);
- is_removed = 1;
- if (ivisurf->controller_surface_count == 0) {
- free(ivisurf);
- }
- else {
- ivisurf->can_be_removed = 1;
- }
+ id_surface = ivi_extension_get_id_of_surface(shell, layout_surface);
- break;
+ ivisurf = get_surface(&shell->list_surface, id_surface);
+ if (ivisurf == NULL) {
+ weston_log("id_surface is not created yet\n");
+ return;
}
- if (is_removed) {
- id_surface = ivi_extension_get_id_of_surface(shell, layout_surface);
-
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
- }
- ivi_controller_surface_send_content(ctrlsurf->resource, IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED);
- ivi_controller_surface_send_destroyed(ctrlsurf->resource);
- }
+ wl_resource_for_each(resource, &ivisurf->resource_list) {
+ ivi_controller_surface_send_content(resource, IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED);
+ ivi_controller_surface_send_destroyed(resource);
}
+
+ wl_list_remove(&ivisurf->link);
+ free(ivisurf);
}
static void
surface_event_configure(struct ivi_layout_surface *layout_surface,
void *userdata)
{
+ struct wl_resource *resource;
struct ivishell *shell = userdata;
struct ivisurface *ivisurf = NULL;
- struct ivicontroller_surface *ctrlsurf = NULL;
const struct ivi_layout_surface_properties *prop;
uint32_t id_surface = 0;
@@ -1585,11 +1493,8 @@ surface_event_configure(struct ivi_layout_surface *layout_surface,
prop = ivi_extension_get_properties_of_surface(shell, layout_surface);
- wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) {
- if (id_surface != ctrlsurf->id_surface) {
- continue;
- }
- send_surface_event(ctrlsurf->resource, ivisurf,
+ wl_resource_for_each(resource, &ivisurf->resource_list) {
+ send_surface_event(resource, ivisurf,
prop, IVI_NOTIFICATION_CONFIGURE);
}
}
@@ -1680,7 +1585,6 @@ init_ivi_shell(struct weston_compositor *ec, struct ivishell *shell)
wl_list_init(&shell->list_controller);
wl_list_init(&shell->list_controller_screen);
wl_list_init(&shell->list_controller_layer);
- wl_list_init(&shell->list_controller_surface);
shell->event_restriction = 0;
wl_list_for_each(output, &ec->output_list, link) {
diff --git a/weston-ivi-shell/src/ivi-extension.h b/weston-ivi-shell/src/ivi-extension.h
index 540ee94..69133c0 100644
--- a/weston-ivi-shell/src/ivi-extension.h
+++ b/weston-ivi-shell/src/ivi-extension.h
@@ -45,7 +45,6 @@ struct ivishell {
struct wl_list list_weston_surface;
struct wl_list list_controller;
- struct wl_list list_controller_surface;
struct wl_list list_controller_layer;
struct wl_list list_controller_screen;