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>
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 1ef008d..b6716f3 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -127,6 +127,8 @@
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 @@
* 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 @@
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(