summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmre Ucan <eucan@de.adit-jv.com>2016-06-23 15:23:40 +0200
committerWataru Natsume <wataru_natsume@xddp.denso.co.jp>2016-06-28 15:22:40 +0900
commitbf0317d747b8116c7796d5bfd7479e10221e7a40 (patch)
tree33d90e70e4f713fb0ba44764b7e6074c4ac7714f
parenta85437766c81b135ef074225cd607eff9c3645d3 (diff)
downloadwayland-ivi-extension-bf0317d747b8116c7796d5bfd7479e10221e7a40.tar.gz
ivi-controller: modify to use v1.11 ivi_layout_interface
1. Use ivi_layout_interface directly without ivi-extension APIs 2. Use weston_output for IVI Screen APIs. 3. Remove content_observer because IVI Layout API is removed 4. Use new listener APIs instead of notification APIs Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
-rw-r--r--weston-ivi-shell/src/ivi-controller-impl.c268
1 files changed, 156 insertions, 112 deletions
diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c
index 9ef2982..871fc05 100644
--- a/weston-ivi-shell/src/ivi-controller-impl.c
+++ b/weston-ivi-shell/src/ivi-controller-impl.c
@@ -46,6 +46,8 @@ struct ivisurface {
struct ivishell *shell;
uint32_t update_count;
struct ivi_layout_surface *layout_surface;
+ const struct ivi_layout_surface_properties *prop;
+ struct wl_listener property_changed;
struct wl_listener surface_destroy_listener;
struct wl_list resource_list;
};
@@ -54,13 +56,15 @@ struct ivilayer {
struct wl_list link;
struct ivishell *shell;
struct ivi_layout_layer *layout_layer;
+ const struct ivi_layout_layer_properties *prop;
+ struct wl_listener property_changed;
struct wl_list resource_list;
};
struct iviscreen {
struct wl_list link;
struct ivishell *shell;
- struct ivi_layout_screen *layout_screen;
+ uint32_t id_screen;
struct weston_output *output;
struct wl_list resource_list;
};
@@ -82,6 +86,13 @@ struct ivishell {
struct wl_list list_screen;
struct wl_list list_controller;
+
+ struct wl_listener surface_created;
+ struct wl_listener surface_removed;
+ struct wl_listener surface_configured;
+
+ struct wl_listener layer_created;
+ struct wl_listener layer_removed;
};
struct screenshot_frame_listener {
@@ -89,8 +100,6 @@ struct screenshot_frame_listener {
char *filename;
};
-static void surface_event_remove(struct ivi_layout_surface *, void *);
-
static void
destroy_ivicontroller_surface(struct wl_resource *resource)
{
@@ -160,10 +169,11 @@ send_surface_add_event(struct ivisurface *ivisurf,
int i = 0;
struct ivilayer *ivilayer = NULL;
struct ivishell *shell = ivisurf->shell;
+ const struct ivi_layout_interface *lyt = shell->interface;
struct wl_client *client = wl_resource_get_client(resource);
- ans = ivi_extension_get_layers_under_surface(shell, ivisurf->layout_surface,
- &length, &pArray);
+ ans = lyt->get_layers_under_surface(ivisurf->layout_surface,
+ &length, &pArray);
if (0 != ans) {
weston_log("failed to get layers at send_surface_add_event\n");
return;
@@ -205,12 +215,12 @@ send_surface_configure_event(struct ivisurface *ivisurf,
{
struct weston_surface *surface;
struct ivi_layout_surface* layout_surface;
- struct ivishell* shell;
+ struct ivishell *shell = ivisurf->shell;
+ const struct ivi_layout_interface *lyt = shell->interface;
layout_surface = ivisurf->layout_surface;
- shell = ivisurf->shell;
- surface = ivi_extension_surface_get_weston_surface(shell, layout_surface);
+ surface = lyt->surface_get_weston_surface(layout_surface);
if (!surface)
return;
@@ -263,16 +273,19 @@ send_surface_event(struct wl_resource *resource,
}
static void
-send_surface_prop(struct ivi_layout_surface *layout_surface,
- const struct ivi_layout_surface_properties *prop,
- enum ivi_layout_notification_mask mask,
- void *userdata)
+send_surface_prop(struct wl_listener *listener, void *data)
{
- struct ivisurface *ivisurf = userdata;
+ struct ivisurface *ivisurf =
+ wl_container_of(listener, ivisurf,
+ property_changed);
+ (void)data;
+ enum ivi_layout_notification_mask mask;
struct wl_resource *resource;
+ mask = ivisurf->prop->event_mask;
+
wl_resource_for_each(resource, &ivisurf->resource_list) {
- send_surface_event(resource, ivisurf, prop, mask);
+ send_surface_event(resource, ivisurf, ivisurf->prop, mask);
}
}
@@ -281,17 +294,18 @@ send_layer_add_event(struct ivilayer *ivilayer,
struct wl_resource *resource,
enum ivi_layout_notification_mask mask)
{
- struct ivi_layout_screen **pArray = NULL;
+ struct weston_output **pArray = NULL;
int32_t length = 0;
int32_t ans = 0;
int i = 0;
struct iviscreen *iviscrn = NULL;
struct ivishell *shell = ivilayer->shell;
+ const struct ivi_layout_interface *lyt = shell->interface;
struct wl_client *client = wl_resource_get_client(resource);
struct wl_resource *resource_output = NULL;
- ans = ivi_extension_get_screens_under_layer(shell, ivilayer->layout_layer,
- &length, &pArray);
+ ans = lyt->get_screens_under_layer(ivilayer->layout_layer,
+ &length, &pArray);
if (0 != ans) {
weston_log("failed to get screens at send_layer_add_event\n");
return;
@@ -309,7 +323,7 @@ send_layer_add_event(struct ivilayer *ivilayer,
}
wl_list_for_each(iviscrn, &shell->list_screen, link) {
- if (iviscrn->layout_screen == pArray[i]) {
+ if (iviscrn->output == pArray[i]) {
resource_output =
wl_resource_find_for_client(&iviscrn->output->resource_list,
client);
@@ -368,16 +382,18 @@ send_layer_event(struct wl_resource *resource,
}
static void
-send_layer_prop(struct ivi_layout_layer *layer,
- const struct ivi_layout_layer_properties *prop,
- enum ivi_layout_notification_mask mask,
- void *userdata)
+send_layer_prop(struct wl_listener *listener, void *data)
{
- struct ivilayer *ivilayer = userdata;
+ struct ivilayer *ivilayer =
+ wl_container_of(listener, ivilayer, property_changed);
+ (void)data;
+ enum ivi_layout_notification_mask mask;
struct wl_resource *resource;
+ mask = ivilayer->prop->event_mask;
+
wl_resource_for_each(resource, &ivilayer->resource_list) {
- send_layer_event(resource, ivilayer, prop, mask);
+ send_layer_event(resource, ivilayer, ivilayer->prop, mask);
}
}
@@ -387,8 +403,9 @@ controller_surface_set_opacity(struct wl_client *client,
wl_fixed_t opacity)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
(void)client;
- ivi_extension_surface_set_opacity(ivisurf->shell, ivisurf->layout_surface, opacity);
+ lyt->surface_set_opacity(ivisurf->layout_surface, opacity);
}
static void
@@ -400,8 +417,9 @@ controller_surface_set_source_rectangle(struct wl_client *client,
int32_t height)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
(void)client;
- ivi_extension_surface_set_source_rectangle(ivisurf->shell, ivisurf->layout_surface,
+ lyt->surface_set_source_rectangle(ivisurf->layout_surface,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
@@ -414,14 +432,15 @@ controller_surface_set_destination_rectangle(struct wl_client *client,
int32_t height)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
(void)client;
// TODO: create set transition type protocol
- ivi_extension_surface_set_transition(ivisurf->shell, ivisurf->layout_surface,
+ lyt->surface_set_transition(ivisurf->layout_surface,
IVI_LAYOUT_TRANSITION_NONE,
300); // ms
- ivi_extension_surface_set_destination_rectangle(ivisurf->shell, ivisurf->layout_surface,
+ lyt->surface_set_destination_rectangle(ivisurf->layout_surface,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
@@ -431,8 +450,9 @@ controller_surface_set_visibility(struct wl_client *client,
uint32_t visibility)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
(void)client;
- ivi_extension_surface_set_visibility(ivisurf->shell, ivisurf->layout_surface, visibility);
+ lyt->surface_set_visibility(ivisurf->layout_surface, visibility);
}
static void
@@ -453,8 +473,9 @@ controller_surface_set_orientation(struct wl_client *client,
int32_t orientation)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
(void)client;
- ivi_extension_surface_set_orientation(ivisurf->shell, ivisurf->layout_surface, (uint32_t)orientation);
+ lyt->surface_set_orientation(ivisurf->layout_surface, (uint32_t)orientation);
}
static void
@@ -469,7 +490,7 @@ controller_surface_screenshot(struct wl_client *client,
int32_t height = 0;
int32_t stride = 0;
int32_t size = 0;
- struct ivishell *shell = ivisurf->shell;
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
char *buffer = NULL;
int32_t image_stride = 0;
int32_t image_size = 0;
@@ -479,8 +500,8 @@ controller_surface_screenshot(struct wl_client *client,
int32_t offset = 0;
int32_t image_offset = 0;
- result = ivi_extension_surface_get_size(
- shell, ivisurf->layout_surface, &width, &height, &stride);
+ result = lyt->surface_get_size(ivisurf->layout_surface, &width,
+ &height, &stride);
if (result != IVI_SUCCEEDED) {
weston_log("failed to get surface size\n");
return;
@@ -499,11 +520,10 @@ controller_surface_screenshot(struct wl_client *client,
return;
}
- weston_surface = ivi_extension_surface_get_weston_surface(
- shell, ivisurf->layout_surface);
+ weston_surface = lyt->surface_get_weston_surface(ivisurf->layout_surface);
- result = ivi_extension_surface_dump(shell, weston_surface,
- buffer, size, 0, 0, width, height);
+ result = lyt->surface_dump(weston_surface, buffer, size, 0, 0,
+ width, height);
if (result != IVI_SUCCEEDED) {
free(image_buffer);
@@ -539,6 +559,7 @@ controller_surface_send_stats(struct wl_client *client,
struct wl_resource *resource)
{
struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivisurf->shell->interface;
struct weston_surface *surface;
struct wl_client* target_client;
pid_t pid;
@@ -546,8 +567,7 @@ controller_surface_send_stats(struct wl_client *client,
gid_t gid;
/* Get pid that creates surface */
- surface = ivi_extension_surface_get_weston_surface(ivisurf->shell,
- ivisurf->layout_surface);
+ surface = lyt->surface_get_weston_surface(ivisurf->layout_surface);
target_client = wl_resource_get_client(surface->resource);
wl_client_get_credentials(target_client, &pid, &uid, &gid);
@@ -594,8 +614,9 @@ controller_layer_set_source_rectangle(struct wl_client *client,
int32_t height)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_source_rectangle(ivilayer->shell, ivilayer->layout_layer,
+ lyt->layer_set_source_rectangle(ivilayer->layout_layer,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
@@ -608,8 +629,9 @@ controller_layer_set_destination_rectangle(struct wl_client *client,
int32_t height)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_destination_rectangle(ivilayer->shell, ivilayer->layout_layer,
+ lyt->layer_set_destination_rectangle(ivilayer->layout_layer,
(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height);
}
@@ -619,8 +641,9 @@ controller_layer_set_visibility(struct wl_client *client,
uint32_t visibility)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_visibility(ivilayer->shell, ivilayer->layout_layer, visibility);
+ lyt->layer_set_visibility(ivilayer->layout_layer, visibility);
}
static void
@@ -629,8 +652,9 @@ controller_layer_set_opacity(struct wl_client *client,
wl_fixed_t opacity)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_opacity(ivilayer->shell, ivilayer->layout_layer, opacity);
+ lyt->layer_set_opacity(ivilayer->layout_layer, opacity);
}
static void
@@ -652,8 +676,9 @@ controller_layer_set_orientation(struct wl_client *client,
int32_t orientation)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_orientation(ivilayer->shell, ivilayer->layout_layer, (uint32_t)orientation);
+ lyt->layer_set_orientation(ivilayer->layout_layer, (uint32_t)orientation);
}
static void
@@ -661,8 +686,9 @@ controller_layer_clear_surfaces(struct wl_client *client,
struct wl_resource *resource)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_set_render_order(ivilayer->shell, ivilayer->layout_layer, NULL, 0);
+ lyt->layer_set_render_order(ivilayer->layout_layer, NULL, 0);
}
static void
@@ -672,8 +698,9 @@ controller_layer_add_surface(struct wl_client *client,
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
struct ivisurface *ivisurf = wl_resource_get_user_data(surface);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_add_surface(ivilayer->shell, ivilayer->layout_layer, ivisurf->layout_surface);
+ lyt->layer_add_surface(ivilayer->layout_layer, ivisurf->layout_surface);
}
static void
@@ -683,8 +710,9 @@ controller_layer_remove_surface(struct wl_client *client,
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
struct ivisurface *ivisurf = wl_resource_get_user_data(surface);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
- ivi_extension_layer_remove_surface(ivilayer->shell, ivilayer->layout_layer, ivisurf->layout_surface);
+ lyt->layer_remove_surface(ivilayer->layout_layer, ivisurf->layout_surface);
}
static void
@@ -703,20 +731,20 @@ controller_layer_set_render_order(struct wl_client *client,
struct wl_array *id_surfaces)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
struct ivi_layout_surface **layoutsurf_array = NULL;
struct ivisurface *ivisurf = NULL;
uint32_t *id_surface = NULL;
uint32_t id_layout_surface = 0;
int i = 0;
(void)client;
- struct ivishell *shell = ivilayer->shell;
layoutsurf_array = (struct ivi_layout_surface**)calloc(
id_surfaces->size, sizeof(void*));
wl_array_for_each(id_surface, id_surfaces) {
wl_list_for_each(ivisurf, &ivilayer->shell->list_surface, link) {
- id_layout_surface = ivi_extension_get_id_of_surface(shell, ivisurf->layout_surface);
+ id_layout_surface = lyt->get_id_of_surface(ivisurf->layout_surface);
if (*id_surface == id_layout_surface) {
layoutsurf_array[i] = ivisurf->layout_surface;
i++;
@@ -725,7 +753,7 @@ controller_layer_set_render_order(struct wl_client *client,
}
}
- ivi_extension_layer_set_render_order(shell, ivilayer->layout_layer,
+ lyt->layer_set_render_order(ivilayer->layout_layer,
layoutsurf_array, i);
free(layoutsurf_array);
}
@@ -736,11 +764,12 @@ controller_layer_destroy(struct wl_client *client,
int32_t destroy_scene_object)
{
struct ivilayer *ivilayer = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = ivilayer->shell->interface;
(void)client;
if (destroy_scene_object) {
if (ivilayer->layout_layer != NULL) {
- ivi_extension_layer_remove(ivilayer->shell, ivilayer->layout_layer);
+ lyt->layer_destroy(ivilayer->layout_layer);
ivilayer->layout_layer = NULL;
}
@@ -784,8 +813,9 @@ controller_screen_clear(struct wl_client *client,
struct wl_resource *resource)
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = iviscrn->shell->interface;
(void)client;
- ivi_extension_screen_set_render_order(iviscrn->shell, iviscrn->layout_screen, NULL, 0);
+ lyt->screen_set_render_order(iviscrn->output, NULL, 0);
}
static void
@@ -794,9 +824,10 @@ controller_screen_add_layer(struct wl_client *client,
struct wl_resource *layer)
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = iviscrn->shell->interface;
struct ivilayer *ivilayer = wl_resource_get_user_data(layer);
(void)client;
- ivi_extension_screen_add_layer(iviscrn->shell, iviscrn->layout_screen, ivilayer->layout_layer);
+ lyt->screen_add_layer(iviscrn->output, ivilayer->layout_layer);
}
static void
@@ -852,7 +883,6 @@ controller_screen_screenshot(struct wl_client *client,
struct screenshot_frame_listener *l;
(void)client;
- struct weston_output *output = NULL;
l = malloc(sizeof *l);
if(l == NULL) {
fprintf(stderr, "fails to allocate memory\n");
@@ -866,11 +896,10 @@ controller_screen_screenshot(struct wl_client *client,
return;
}
- output = ivi_extension_screen_get_output(iviscrn->shell, iviscrn->layout_screen);
l->listener.notify = controller_screenshot_notify;
- wl_signal_add(&output->frame_signal, &l->listener);
- output->disable_planes++;
- weston_output_schedule_repaint(output);
+ wl_signal_add(&iviscrn->output->frame_signal, &l->listener);
+ iviscrn->output->disable_planes++;
+ weston_output_schedule_repaint(iviscrn->output);
return;
}
@@ -880,20 +909,20 @@ controller_screen_set_render_order(struct wl_client *client,
struct wl_array *id_layers)
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
+ const struct ivi_layout_interface *lyt = iviscrn->shell->interface;
struct ivi_layout_layer **layoutlayer_array = NULL;
struct ivilayer *ivilayer = NULL;
uint32_t *id_layer = NULL;
uint32_t id_layout_layer = 0;
int i = 0;
(void)client;
- struct ivishell *shell = iviscrn->shell;
layoutlayer_array = (struct ivi_layout_layer**)calloc(
id_layers->size, sizeof(void*));
wl_array_for_each(id_layer, id_layers) {
wl_list_for_each(ivilayer, &iviscrn->shell->list_layer, link) {
- id_layout_layer = ivi_extension_get_id_of_layer(shell, ivilayer->layout_layer);
+ id_layout_layer = lyt->get_id_of_layer(ivilayer->layout_layer);
if (*id_layer == id_layout_layer) {
layoutlayer_array[i] = ivilayer->layout_layer;
i++;
@@ -902,7 +931,7 @@ controller_screen_set_render_order(struct wl_client *client,
}
}
- ivi_extension_screen_set_render_order(shell, iviscrn->layout_screen,
+ lyt->screen_set_render_order(iviscrn->output,
layoutlayer_array, i);
free(layoutlayer_array);
}
@@ -924,7 +953,7 @@ controller_commit_changes(struct wl_client *client,
(void)client;
struct ivicontroller *controller = wl_resource_get_user_data(resource);
- ans = ivi_extension_commit_changes(controller->shell);
+ ans = controller->shell->interface->commit_changes();
if (ans < 0) {
weston_log("Failed to commit changes at controller_commit_changes\n");
}
@@ -941,13 +970,14 @@ controller_layer_create(struct wl_client *client,
struct wl_resource *layer_resource;
struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
struct ivishell *shell = ctrl->shell;
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivi_layout_layer *layout_layer = NULL;
struct ivilayer *ivilayer = NULL;
const struct ivi_layout_layer_properties *prop;
- layout_layer = ivi_extension_get_layer_from_id(shell, id_layer);
+ layout_layer = lyt->get_layer_from_id(id_layer);
if (layout_layer == NULL) {
- layout_layer = ivi_extension_layer_create_with_dimension(shell, id_layer,
+ layout_layer = lyt->layer_create_with_dimension(id_layer,
(uint32_t)width, (uint32_t)height);
if (layout_layer == NULL) {
weston_log("id_layer is already created\n");
@@ -974,20 +1004,12 @@ controller_layer_create(struct wl_client *client,
&controller_layer_implementation,
ivilayer, destroy_ivicontroller_layer);
- prop = ivi_extension_get_properties_of_layer(shell, ivilayer->layout_layer);
+ prop = lyt->get_properties_of_layer(ivilayer->layout_layer);
send_layer_event(layer_resource, ivilayer,
prop, IVI_NOTIFICATION_ALL);
}
static void
-surface_event_content(struct ivi_layout_surface *layout_surface, int32_t content, void *userdata)
-{
- if (content == 0) {
- surface_event_remove(layout_surface, userdata);
- }
-}
-
-static void
controller_surface_create(struct wl_client *client,
struct wl_resource *resource,
uint32_t id_surface,
@@ -996,11 +1018,12 @@ controller_surface_create(struct wl_client *client,
struct wl_resource *surf_resource;
struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
struct ivishell *shell = ctrl->shell;
+ const struct ivi_layout_interface *lyt = shell->interface;
const struct ivi_layout_surface_properties *prop;
struct ivi_layout_surface *layout_surface = NULL;
struct ivisurface *ivisurf = NULL;
- layout_surface = ivi_extension_get_surface_from_id(shell, id_surface);
+ layout_surface = lyt->get_surface_from_id(id_surface);
if (layout_surface == NULL) {
return;
}
@@ -1022,8 +1045,7 @@ controller_surface_create(struct wl_client *client,
&controller_surface_implementation,
ivisurf, destroy_ivicontroller_surface);
- 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);
+ prop = lyt->get_properties_of_surface(ivisurf->layout_surface);
send_surface_event(surf_resource, ivisurf, prop, IVI_NOTIFICATION_ALL);
}
@@ -1039,6 +1061,7 @@ add_client_to_resources(struct ivishell *shell,
struct wl_client *client,
struct ivicontroller *controller)
{
+ const struct ivi_layout_interface *lyt = shell->interface;
struct wl_resource *screen_resource;
struct ivisurface* ivisurf = NULL;
struct ivilayer* ivilayer = NULL;
@@ -1071,15 +1094,13 @@ add_client_to_resources(struct ivishell *shell,
screen_resource);
}
wl_list_for_each_reverse(ivilayer, &shell->list_layer, link) {
- id_layout_layer =
- ivi_extension_get_id_of_layer(shell, ivilayer->layout_layer);
+ id_layout_layer = lyt->get_id_of_layer(ivilayer->layout_layer);
ivi_controller_send_layer(controller->resource,
id_layout_layer);
}
wl_list_for_each_reverse(ivisurf, &shell->list_surface, link) {
- id_layout_surface =
- ivi_extension_get_id_of_surface(shell, ivisurf->layout_surface);
+ id_layout_surface = lyt->get_id_of_surface(ivisurf->layout_surface);
ivi_controller_send_surface(controller->resource,
id_layout_surface);
@@ -1119,7 +1140,6 @@ static struct iviscreen*
create_screen(struct ivishell *shell, struct weston_output *output)
{
struct iviscreen *iviscrn;
- static int id_counter = 0;
iviscrn = calloc(1, sizeof *iviscrn);
if (iviscrn == NULL) {
weston_log("no memory to allocate client screen\n");
@@ -1129,7 +1149,7 @@ create_screen(struct ivishell *shell, struct weston_output *output)
iviscrn->shell = shell;
iviscrn->output = output;
- iviscrn->layout_screen = ivi_extension_get_screen_from_id(shell, id_counter++);
+ iviscrn->id_screen = output->id;
wl_list_init(&iviscrn->link);
wl_list_init(&iviscrn->resource_list);
@@ -1142,6 +1162,7 @@ create_layer(struct ivishell *shell,
struct ivi_layout_layer *layout_layer,
uint32_t id_layer)
{
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivilayer *ivilayer = NULL;
struct ivicontroller *controller = NULL;
@@ -1155,8 +1176,10 @@ create_layer(struct ivishell *shell,
wl_list_insert(&shell->list_layer, &ivilayer->link);
wl_list_init(&ivilayer->resource_list);
ivilayer->layout_layer = layout_layer;
+ ivilayer->prop = lyt->get_properties_of_layer(layout_layer);
- ivi_extension_layer_add_notification(shell, layout_layer, send_layer_prop, ivilayer);
+ ivilayer->property_changed.notify = send_layer_prop;
+ lyt->layer_add_listener(layout_layer, &ivilayer->property_changed);
wl_list_for_each(controller, &shell->list_controller, link) {
ivi_controller_send_layer(controller->resource, id_layer);
@@ -1170,6 +1193,7 @@ create_surface(struct ivishell *shell,
struct ivi_layout_surface *layout_surface,
uint32_t id_surface)
{
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivisurface *ivisurf = NULL;
struct ivicontroller *controller = NULL;
@@ -1181,6 +1205,7 @@ create_surface(struct ivishell *shell,
ivisurf->shell = shell;
ivisurf->layout_surface = layout_surface;
+ ivisurf->prop = lyt->get_properties_of_surface(layout_surface);
wl_list_insert(&shell->list_surface, &ivisurf->link);
wl_list_init(&ivisurf->resource_list);
@@ -1189,21 +1214,23 @@ create_surface(struct ivishell *shell,
id_surface);
}
- ivi_extension_surface_add_notification(shell, layout_surface,
- send_surface_prop, ivisurf);
+ ivisurf->property_changed.notify = send_surface_prop;
+ lyt->surface_add_listener(layout_surface, &ivisurf->property_changed);
return ivisurf;
}
static void
-layer_event_create(struct ivi_layout_layer *layout_layer,
- void *userdata)
+layer_event_create(struct wl_listener *listener, void *data)
{
- struct ivishell *shell = userdata;
+ struct ivishell *shell = wl_container_of(listener, shell, layer_created);
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivilayer *ivilayer = NULL;
+ struct ivi_layout_layer *layout_layer =
+ (struct ivi_layout_layer *) data;
uint32_t id_layer = 0;
- id_layer = ivi_extension_get_id_of_layer(shell, layout_layer);
+ id_layer = lyt->get_id_of_layer(layout_layer);
ivilayer = create_layer(shell, layout_layer, id_layer);
if (ivilayer == NULL) {
@@ -1213,12 +1240,13 @@ layer_event_create(struct ivi_layout_layer *layout_layer,
}
static void
-layer_event_remove(struct ivi_layout_layer *layout_layer,
- void *userdata)
+layer_event_remove(struct wl_listener *listener, void *data)
{
struct wl_resource *resource;
- struct ivishell *shell = userdata;
+ struct ivishell *shell = wl_container_of(listener, shell, layer_removed);
struct ivilayer *ivilayer = NULL;
+ struct ivi_layout_layer *layout_layer =
+ (struct ivi_layout_layer *) data;
ivilayer = get_layer(&shell->list_layer, layout_layer);
if (ivilayer == NULL) {
@@ -1231,6 +1259,7 @@ layer_event_remove(struct ivi_layout_layer *layout_layer,
* their proxies. */
if (wl_list_empty(&ivilayer->resource_list)) {
wl_list_remove(&ivilayer->link);
+ wl_list_remove(&ivilayer->property_changed.link);
free(ivilayer);
} else {
wl_resource_for_each(resource, &ivilayer->resource_list) {
@@ -1241,15 +1270,17 @@ layer_event_remove(struct ivi_layout_layer *layout_layer,
static void
-surface_event_create(struct ivi_layout_surface *layout_surface,
- void *userdata)
+surface_event_create(struct wl_listener *listener, void *data)
{
struct wl_resource *resource;
- struct ivishell *shell = userdata;
+ struct ivishell *shell = wl_container_of(listener, shell, surface_created);
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivisurface *ivisurf = NULL;
+ struct ivi_layout_surface *layout_surface =
+ (struct ivi_layout_surface *) data;
uint32_t id_surface = 0;
- id_surface = ivi_extension_get_id_of_surface(shell, layout_surface);
+ id_surface = lyt->get_id_of_surface(layout_surface);
ivisurf = create_surface(shell, layout_surface, id_surface);
if (ivisurf == NULL) {
@@ -1263,12 +1294,13 @@ surface_event_create(struct ivi_layout_surface *layout_surface,
}
static void
-surface_event_remove(struct ivi_layout_surface *layout_surface,
- void *userdata)
+surface_event_remove(struct wl_listener *listener, void *data)
{
struct wl_resource *resource;
- struct ivishell *shell = userdata;
+ struct ivishell *shell = wl_container_of(listener, shell, surface_removed);
struct ivisurface *ivisurf = NULL;
+ struct ivi_layout_surface *layout_surface =
+ (struct ivi_layout_surface *) data;
ivisurf = get_surface(&shell->list_surface, layout_surface);
if (ivisurf == NULL) {
@@ -1281,6 +1313,7 @@ surface_event_remove(struct ivi_layout_surface *layout_surface,
* their proxies. */
if (wl_list_empty(&ivisurf->resource_list)) {
wl_list_remove(&ivisurf->link);
+ wl_list_remove(&ivisurf->property_changed.link);
free(ivisurf);
} else {
wl_resource_for_each(resource, &ivisurf->resource_list) {
@@ -1290,12 +1323,14 @@ surface_event_remove(struct ivi_layout_surface *layout_surface,
}
static void
-surface_event_configure(struct ivi_layout_surface *layout_surface,
- void *userdata)
+surface_event_configure(struct wl_listener *listener, void *data)
{
struct wl_resource *resource;
- struct ivishell *shell = userdata;
+ struct ivishell *shell = wl_container_of(listener, shell, surface_configured);
+ const struct ivi_layout_interface *lyt = shell->interface;
struct ivisurface *ivisurf = NULL;
+ struct ivi_layout_surface *layout_surface =
+ (struct ivi_layout_surface *) data;
const struct ivi_layout_surface_properties *prop;
ivisurf = get_surface(&shell->list_surface, layout_surface);
@@ -1304,7 +1339,7 @@ surface_event_configure(struct ivi_layout_surface *layout_surface,
return;
}
- prop = ivi_extension_get_properties_of_surface(shell, layout_surface);
+ prop = lyt->get_properties_of_surface(layout_surface);
wl_resource_for_each(resource, &ivisurf->resource_list) {
send_surface_event(resource, ivisurf,
@@ -1317,12 +1352,13 @@ check_layout_layers(struct ivishell *shell)
{
struct ivi_layout_layer **pArray = NULL;
struct ivilayer *ivilayer = NULL;
+ const struct ivi_layout_interface *lyt = shell->interface;
uint32_t id_layer = 0;
int32_t length = 0;
uint32_t i = 0;
int32_t ret = 0;
- ret = ivi_extension_get_layers(shell, &length, &pArray);
+ ret = lyt->get_layers(&length, &pArray);
if(ret != 0) {
weston_log("failed to get layers at check_layout_layers\n");
return -1;
@@ -1334,7 +1370,7 @@ check_layout_layers(struct ivishell *shell)
}
for (i = 0; i < length; i++) {
- id_layer = ivi_extension_get_id_of_layer(shell, pArray[i]);
+ id_layer = lyt->get_id_of_layer(pArray[i]);
ivilayer = create_layer(shell, pArray[i], id_layer);
if (ivilayer == NULL) {
weston_log("failed to create layer");
@@ -1352,12 +1388,13 @@ check_layout_surfaces(struct ivishell *shell)
{
struct ivi_layout_surface **pArray = NULL;
struct ivisurface *ivisurf = NULL;
+ const struct ivi_layout_interface *lyt = shell->interface;
uint32_t id_surface = 0;
int32_t length = 0;
uint32_t i = 0;
int32_t ret = 0;
- ret = ivi_extension_get_surfaces(shell, &length, &pArray);
+ ret = lyt->get_surfaces(&length, &pArray);
if(ret != 0) {
weston_log("failed to get surfaces at check_layout_surfaces\n");
return -1;
@@ -1369,7 +1406,7 @@ check_layout_surfaces(struct ivishell *shell)
}
for (i = 0; i < length; i++) {
- id_surface = ivi_extension_get_id_of_surface(shell, pArray[i]);
+ id_surface = lyt->get_id_of_surface(pArray[i]);
ivisurf = create_surface(shell, pArray[i], id_surface);
if (ivisurf == NULL) {
weston_log("failed to create surface");
@@ -1385,6 +1422,7 @@ check_layout_surfaces(struct ivishell *shell)
void
init_ivi_shell(struct weston_compositor *ec, struct ivishell *shell)
{
+ const struct ivi_layout_interface *lyt = shell->interface;
struct weston_output *output = NULL;
struct iviscreen *iviscrn = NULL;
int32_t ret = 0;
@@ -1413,13 +1451,19 @@ init_ivi_shell(struct weston_compositor *ec, struct ivishell *shell)
weston_log("failed to check_layout_surfaces");
}
- ivi_extension_add_notification_create_layer(shell, layer_event_create, shell);
- ivi_extension_add_notification_remove_layer(shell, layer_event_remove, shell);
+ shell->layer_created.notify = layer_event_create;
+ shell->layer_removed.notify = layer_event_remove;
+
+ lyt->add_listener_create_layer(&shell->layer_created);
+ lyt->add_listener_remove_layer(&shell->layer_removed);
- ivi_extension_add_notification_create_surface(shell, surface_event_create, shell);
- ivi_extension_add_notification_remove_surface(shell, surface_event_remove, shell);
+ shell->surface_created.notify = surface_event_create;
+ shell->surface_removed.notify = surface_event_remove;
+ shell->surface_configured.notify = surface_event_configure;
- ivi_extension_add_notification_configure_surface(shell, surface_event_configure, shell);
+ lyt->add_listener_create_surface(&shell->surface_created);
+ lyt->add_listener_remove_surface(&shell->surface_removed);
+ lyt->add_listener_configure_surface(&shell->surface_configured);
}
int