[PATCH 09/10] Define the screensaver inhibition client interface
Bryce Harrington
bryce at osg.samsung.com
Sat Mar 5 00:18:46 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>
---
Makefile.am | 9 +++++++--
clients/simple-shm.c | 29 +++++++++++++++++++++++++----
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 1057ed6..07160b7 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/screensaver-inhibit-unstable-v1-protocol.c \
+ protocol/screensaver-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/screensaver-inhibit-unstable-v1-protocol.c \
+ protocol/screensaver-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..16dd4dd 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 "screensaver-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_screensaver_inhibition_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_screensaver_inhibition_inhibit_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_screensaver_inhibition_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_screensaver_inhibition_inhibit_v1_destroy(window->inhibitor);
+
wl_surface_destroy(window->surface);
free(window);
}
@@ -381,12 +395,16 @@ 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_screensaver_inhibition_v1") == 0) {
+ printf("Handling global for screensaver inhibition\n");
+ d->inhibit = wl_registry_bind(registry,
+ id, &zwp_screensaver_inhibition_v1_interface, 1);
}
+
}
static void
@@ -476,6 +494,9 @@ create_display(void)
static void
destroy_display(struct display *display)
{
+ if (display->inhibit)
+ zwp_screensaver_inhibition_v1_destroy(display->inhibit);
+
if (display->shm)
wl_shm_destroy(display->shm);
--
1.9.1
More information about the wayland-devel
mailing list