summaryrefslogtreecommitdiff
path: root/ivi-shell
diff options
context:
space:
mode:
authorUcan, Emre (ADITG/SW1) <eucan@de.adit-jv.com>2016-04-04 08:05:09 +0000
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2016-04-05 11:53:48 +0300
commit970f831588cf7248430cd10cd1d1774586d202ef (patch)
tree449e949613049423b18c3b7187697ea0aced0f52 /ivi-shell
parent3750d1b270135cf5b1482034aff2bed9999848c6 (diff)
downloadweston-970f831588cf7248430cd10cd1d1774586d202ef.tar.gz
ivi-shell: rework create_surface notification
The add_notification_create_surface API accepts a simple wl_listener instead of a ivi-shell specific notification function. Therefore, the API is renamed to add_listener_create_surface. This change has several advantages: 1. Code cleanup 2. No dynamic memory allocation. Listeners are allocated by controller plugins 3. Remove API is not needed. Controller plugins can easily remove the listener link. The remove API is removed too: - ivi_layout_remove_notification_create_surface Signed-off-by: Emre Ucan <eucan@de.adit-jv.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'ivi-shell')
-rw-r--r--ivi-shell/hmi-controller.c14
-rw-r--r--ivi-shell/ivi-layout-export.h19
-rw-r--r--ivi-shell/ivi-layout.c49
3 files changed, 22 insertions, 60 deletions
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 1ef008dd..b6716f3f 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -127,6 +127,8 @@ struct hmi_controller {
struct weston_compositor *compositor;
struct wl_listener destroy_listener;
+ struct wl_listener surface_created;
+
struct wl_client *user_interface;
struct ui_setting ui_setting;
@@ -576,10 +578,12 @@ create_layer(struct weston_output *output,
* Internal set notification
*/
static void
-set_notification_create_surface(struct ivi_layout_surface *ivisurf,
- void *userdata)
+set_notification_create_surface(struct wl_listener *listener, void *data)
{
- struct hmi_controller *hmi_ctrl = userdata;
+ struct hmi_controller *hmi_ctrl =
+ wl_container_of(listener, hmi_ctrl,
+ surface_created);
+ struct ivi_layout_surface *ivisurf = data;
struct hmi_controller_layer *layer_link =
wl_container_of(hmi_ctrl->application_layer_list.prev,
layer_link,
@@ -834,8 +838,8 @@ hmi_controller_create(struct weston_compositor *ec)
wl_list_insert(&hmi_ctrl->workspace_fade.layer_list,
&tmp_link_layer->link);
- ivi_layout_interface->add_notification_create_surface(
- set_notification_create_surface, hmi_ctrl);
+ hmi_ctrl->surface_created.notify = set_notification_create_surface;
+ ivi_layout_interface->add_listener_create_surface(&hmi_ctrl->surface_created);
ivi_layout_interface->add_notification_remove_surface(
set_notification_remove_surface, hmi_ctrl);
ivi_layout_interface->add_notification_configure_surface(
diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index d7a880ca..2ea43bb5 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -146,10 +146,6 @@ typedef void (*layer_remove_notification_func)(
struct ivi_layout_layer *ivilayer,
void *userdata);
-typedef void (*surface_create_notification_func)(
- struct ivi_layout_surface *ivisurf,
- void *userdata);
-
typedef void (*surface_remove_notification_func)(
struct ivi_layout_surface *ivisurf,
void *userdata);
@@ -174,15 +170,14 @@ struct ivi_layout_interface {
*/
/**
- * \brief register/unregister for notification when ivi_surface is created
+ * \brief add a listener for notification when ivi_surface is created
+ *
+ * When an ivi_surface is created, a signal is emitted
+ * to the listening controller plugins.
+ * The pointer of the created ivi_surface is sent as the void *data argument
+ * to the wl_listener::notify callback function of the listener.
*/
- int32_t (*add_notification_create_surface)(
- surface_create_notification_func callback,
- void *userdata);
-
- void (*remove_notification_create_surface)(
- surface_create_notification_func callback,
- void *userdata);
+ int32_t (*add_listener_create_surface)(struct wl_listener *listener);
/**
* \brief register/unregister for notification when ivi_surface is removed
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 75350a39..b6c41e4e 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -965,23 +965,6 @@ layer_removed(struct wl_listener *listener, void *data)
}
static void
-surface_created(struct wl_listener *listener, void *data)
-{
- struct ivi_layout_surface *ivisurface = data;
-
- struct listener_layout_notification *notification =
- container_of(listener,
- struct listener_layout_notification,
- listener);
-
- struct ivi_layout_notification_callback *created_callback =
- notification->userdata;
-
- ((surface_create_notification_func)created_callback->callback)
- (ivisurface, created_callback->data);
-}
-
-static void
surface_removed(struct wl_listener *listener, void *data)
{
struct ivi_layout_surface *ivisurface = data;
@@ -1137,37 +1120,18 @@ ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callb
}
static int32_t
-ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
- void *userdata)
+ivi_layout_add_listener_create_surface(struct wl_listener *listener)
{
struct ivi_layout *layout = get_instance();
- struct ivi_layout_notification_callback *created_callback = NULL;
- if (callback == NULL) {
- weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
+ if (listener == NULL) {
+ weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
return IVI_FAILED;
}
- created_callback = malloc(sizeof *created_callback);
- if (created_callback == NULL) {
- weston_log("fails to allocate memory\n");
- return IVI_FAILED;
- }
-
- created_callback->callback = callback;
- created_callback->data = userdata;
+ wl_signal_add(&layout->surface_notification.created, listener);
- return add_notification(&layout->surface_notification.created,
- surface_created,
- created_callback);
-}
-
-static void
-ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
- void *userdata)
-{
- struct ivi_layout *layout = get_instance();
- remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
+ return IVI_SUCCEEDED;
}
static int32_t
@@ -2229,8 +2193,7 @@ static struct ivi_layout_interface ivi_layout_interface = {
/**
* surface controller interfaces
*/
- .add_notification_create_surface = ivi_layout_add_notification_create_surface,
- .remove_notification_create_surface = ivi_layout_remove_notification_create_surface,
+ .add_listener_create_surface = ivi_layout_add_listener_create_surface,
.add_notification_remove_surface = ivi_layout_add_notification_remove_surface,
.remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface,
.add_notification_configure_surface = ivi_layout_add_notification_configure_surface,