[PATCH weston v2 09/10] Define the screensaver inhibitor client interface

Bryce Harrington bryce at osg.samsung.com
Thu Mar 24 18:27:53 UTC 2016


Hook up the API defined in wayland-protocols to allow client screensaver
inhibition requests.

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>

v2: Update for protocol rename
Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
v2: Update for protocol rename from screensaver-inhibition to idle-inhibit                               
 Makefile.am          |  9 +++++++--
 clients/simple-shm.c | 28 ++++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index aa3aa1b..73affd1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -478,7 +478,10 @@ nodist_weston_simple_shm_SOURCES =		\
 	protocol/fullscreen-shell-unstable-v1-protocol.c	\
 	protocol/fullscreen-shell-unstable-v1-client-protocol.h	\
 	protocol/ivi-application-protocol.c		\
-	protocol/ivi-application-client-protocol.h
+	protocol/ivi-application-client-protocol.h	\
+	protocol/idle-inhibit-unstable-v1-protocol.c	\
+	protocol/idle-inhibit-unstable-v1-client-protocol.h
+
 weston_simple_shm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_CLIENT_CFLAGS)
 weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la
 
@@ -766,7 +769,9 @@ BUILT_SOURCES +=					\
 	protocol/ivi-hmi-controller-protocol.c		\
 	protocol/ivi-hmi-controller-client-protocol.h	\
 	protocol/ivi-application-protocol.c		\
-	protocol/ivi-application-client-protocol.h
+	protocol/ivi-application-client-protocol.h	\
+	protocol/idle-inhibit-unstable-v1-protocol.c \
+	protocol/idle-inhibit-unstable-v1-client-protocol.h
 
 westondatadir = $(datadir)/weston
 dist_westondata_DATA =				\
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index e6f0bd0..1dc609c 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -42,12 +42,15 @@
 #include "ivi-application-client-protocol.h"
 #define IVI_SURFACE_ID 9000
 
+#include "idle-inhibit-unstable-v1-client-protocol.h"
+
 struct display {
 	struct wl_display *display;
 	struct wl_registry *registry;
 	struct wl_compositor *compositor;
 	struct xdg_shell *shell;
 	struct zwp_fullscreen_shell_v1 *fshell;
+	struct zwp_idle_inhibit_manager_v1 *inhibit;
 	struct wl_shm *shm;
 	uint32_t formats;
 	struct ivi_application *ivi_application;
@@ -68,6 +71,7 @@ struct window {
 	struct buffer buffers[2];
 	struct buffer *prev_buffer;
 	struct wl_callback *callback;
+	struct zwp_idle_inhibitor_v1 *inhibitor;
 };
 
 static int running = 1;
@@ -201,6 +205,12 @@ create_window(struct display *display, int width, int height)
 		assert(0);
 	}
 
+	/* Request the screensaver be inhibited for duration of our surface */
+	if (display->inhibit) {
+		window->inhibitor = zwp_idle_inhibit_manager_v1_create_inhibitor(display->inhibit,
+										 window->surface);
+	}
+
 	return window;
 }
 
@@ -217,6 +227,10 @@ destroy_window(struct window *window)
 
 	if (window->xdg_surface)
 		xdg_surface_destroy(window->xdg_surface);
+
+	if (window->inhibitor)
+		zwp_idle_inhibitor_v1_destroy(window->inhibitor);
+
 	wl_surface_destroy(window->surface);
 	free(window);
 }
@@ -381,12 +395,15 @@ registry_handle_global(void *data, struct wl_registry *registry,
 		d->shm = wl_registry_bind(registry,
 					  id, &wl_shm_interface, 1);
 		wl_shm_add_listener(d->shm, &shm_listener, d);
-	}
-	else if (strcmp(interface, "ivi_application") == 0) {
+	} else if (strcmp(interface, "ivi_application") == 0) {
 		d->ivi_application =
-			wl_registry_bind(registry, id,
-					 &ivi_application_interface, 1);
+			wl_registry_bind(registry,
+					 id, &ivi_application_interface, 1);
+	} else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) {
+		d->inhibit = wl_registry_bind(registry,
+					      id, &zwp_idle_inhibit_manager_v1_interface, 1);
 	}
+
 }
 
 static void
@@ -476,6 +493,9 @@ create_display(void)
 static void
 destroy_display(struct display *display)
 {
+	if (display->inhibit)
+		zwp_idle_inhibit_manager_v1_destroy(display->inhibit);
+
 	if (display->shm)
 		wl_shm_destroy(display->shm);
 
-- 
1.9.1



More information about the wayland-devel mailing list