ivi-shell: rework remove_surface notification
The add_notification_remove_surface API accepts a simple
wl_listener instead of a ivi-shell specific notification
function. Therefore, the API is renamed to add_listener_remove_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_remove_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 b6716f3..b27f87b 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -128,6 +128,7 @@
struct wl_listener destroy_listener;
struct wl_listener surface_created;
+ struct wl_listener surface_removed;
struct wl_client *user_interface;
struct ui_setting ui_setting;
@@ -600,10 +601,12 @@
}
static void
-set_notification_remove_surface(struct ivi_layout_surface *ivisurf,
- void *userdata)
+set_notification_remove_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_removed);
+ (void)data;
switch_mode(hmi_ctrl, hmi_ctrl->layout_mode);
}
@@ -840,8 +843,9 @@
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);
+
+ hmi_ctrl->surface_removed.notify = set_notification_remove_surface;
+ ivi_layout_interface->add_listener_remove_surface(&hmi_ctrl->surface_removed);
ivi_layout_interface->add_notification_configure_surface(
set_notification_configure_surface, hmi_ctrl);