[PATCH weston v6 4/6] libweston-desktop: Add listener and API to drop the idle inhibitor

Bryce Harrington bryce at osg.samsung.com
Fri Sep 9 02:31:42 UTC 2016


Listen for the drop_idle_inhibitor signal from libweston, and propagate
the call to a corresponding libweston-desktop API.

Shells aren't required to implement handling for destruction of the idle
inhibitor, if they have no additional behaviors (e.g. fade-out
animations) beyond letting the output be idled off.

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 libweston-desktop/internal.h          |  3 +++
 libweston-desktop/libweston-desktop.c |  9 +++++++++
 libweston-desktop/libweston-desktop.h |  2 ++
 libweston-desktop/surface.c           | 17 +++++++++++++++++
 4 files changed, 31 insertions(+)

diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
index a9c974b..c9f51b6 100644
--- a/libweston-desktop/internal.h
+++ b/libweston-desktop/internal.h
@@ -47,6 +47,9 @@ void
 weston_desktop_api_surface_removed(struct weston_desktop *desktop,
 				   struct weston_desktop_surface *surface);
 void
+weston_desktop_api_drop_idle_inhibitor(struct weston_desktop *desktop,
+				       struct weston_desktop_surface *surface);
+void
 weston_desktop_api_committed(struct weston_desktop *desktop,
 			     struct weston_desktop_surface *surface,
 			     int32_t sx, int32_t sy);
diff --git a/libweston-desktop/libweston-desktop.c b/libweston-desktop/libweston-desktop.c
index 0ee1139..2418242 100644
--- a/libweston-desktop/libweston-desktop.c
+++ b/libweston-desktop/libweston-desktop.c
@@ -61,6 +61,7 @@ weston_desktop_create(struct weston_compositor *compositor,
 
 	assert(api->surface_added);
 	assert(api->surface_removed);
+	/* assert(api->surface_drop_idle_inhibitor); -- optional, for now */
 
 	desktop = zalloc(sizeof(struct weston_desktop));
 	desktop->compositor = compositor;
@@ -166,6 +167,14 @@ weston_desktop_api_surface_removed(struct weston_desktop *desktop,
 }
 
 void
+weston_desktop_api_drop_idle_inhibitor(struct weston_desktop *desktop,
+				       struct weston_desktop_surface *surface)
+{
+	if (desktop->api.drop_idle_inhibitor)
+		desktop->api.drop_idle_inhibitor(surface, desktop->user_data);
+}
+
+void
 weston_desktop_api_committed(struct weston_desktop *desktop,
 			     struct weston_desktop_surface *surface,
 			     int32_t sx, int32_t sy)
diff --git a/libweston-desktop/libweston-desktop.h b/libweston-desktop/libweston-desktop.h
index f77ab55..962e46c 100644
--- a/libweston-desktop/libweston-desktop.h
+++ b/libweston-desktop/libweston-desktop.h
@@ -59,6 +59,8 @@ struct weston_desktop_api {
 			      void *user_data);
 	void (*surface_removed)(struct weston_desktop_surface *surface,
 				void *user_data);
+	void (*drop_idle_inhibitor)(struct weston_desktop_surface *surface,
+				    void *user_data);
 	void (*committed)(struct weston_desktop_surface *surface,
 			  int32_t sx, int32_t sy, void *user_data);
 	void (*show_window_menu)(struct weston_desktop_surface *surface,
diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
index 2205107..feb3e1b 100644
--- a/libweston-desktop/surface.c
+++ b/libweston-desktop/surface.c
@@ -54,6 +54,7 @@ struct weston_desktop_surface {
 	struct weston_position buffer_move;
 	struct wl_listener surface_commit_listener;
 	struct wl_listener surface_destroy_listener;
+	struct wl_listener drop_idle_inhibitor_listener;
 	struct wl_listener client_destroy_listener;
 	struct wl_list children_list;
 
@@ -130,6 +131,7 @@ weston_desktop_surface_destroy(struct weston_desktop_surface *surface)
 
 	wl_list_remove(&surface->surface_commit_listener.link);
 	wl_list_remove(&surface->surface_destroy_listener.link);
+	wl_list_remove(&surface->drop_idle_inhibitor_listener.link);
 	wl_list_remove(&surface->client_destroy_listener.link);
 
 	if (!wl_list_empty(&surface->resource_list)) {
@@ -218,6 +220,17 @@ weston_desktop_surface_resource_destroy(struct wl_resource *resource)
 }
 
 static void
+weston_desktop_drop_idle_inhibitor(struct wl_listener *listener,
+				   void *data)
+{
+	struct weston_desktop_surface *surface =
+		wl_container_of(listener, surface, drop_idle_inhibitor_listener);
+	struct weston_desktop *desktop = surface->desktop;
+
+	weston_desktop_api_drop_idle_inhibitor(desktop, surface);
+}
+
+static void
 weston_desktop_surface_committed(struct weston_surface *wsurface,
 				 int32_t sx, int32_t sy)
 {
@@ -277,6 +290,10 @@ weston_desktop_surface_create(struct weston_desktop *desktop,
 		weston_desktop_surface_surface_destroyed;
 	wl_signal_add(&surface->surface->destroy_signal,
 		      &surface->surface_destroy_listener);
+	surface->drop_idle_inhibitor_listener.notify =
+		weston_desktop_drop_idle_inhibitor;
+	wl_signal_add(&surface->surface->drop_idle_inhibitor_signal,
+		      &surface->drop_idle_inhibitor_listener);
 
 	wl_list_init(&surface->client_link);
 	wl_list_init(&surface->resource_list);
-- 
1.9.1



More information about the wayland-devel mailing list