[RFC 5/5] simple-shm: Add fullscreen shell support

Jason Ekstrand jason at jlekstrand.net
Wed Oct 23 03:48:29 CEST 2013


This makes simple-shm act like a very simple fullscreen shell client.  This
is the kind of interaction one would expect out of a boot splash screen or
similar.
---
 clients/.gitignore   |  2 ++
 clients/Makefile.am  |  4 ++++
 clients/simple-shm.c | 32 +++++++++++++++++++++++++-------
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/clients/.gitignore b/clients/.gitignore
index 23959cc..4f7d9d4 100644
--- a/clients/.gitignore
+++ b/clients/.gitignore
@@ -21,6 +21,8 @@ weston-view
 
 desktop-shell-client-protocol.h
 desktop-shell-protocol.c
+fullscreen-shell-protocol.c
+fullscreen-shell-client-protocol.h
 input-method-protocol.c
 input-method-client-protocol.h
 weston-keyboard
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f9dc48..a65d83e 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -36,6 +36,8 @@ simple_clients_programs =			\
 	weston-multi-resource
 
 weston_simple_shm_SOURCES = simple-shm.c 	\
+	fullscreen-shell-client-protocol.h	\
+	fullscreen-shell-protocol.c		\
 	../shared/os-compatibility.c		\
 	../shared/os-compatibility.h
 weston_simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
@@ -225,6 +227,8 @@ BUILT_SOURCES =					\
 	input-method-client-protocol.h		\
 	desktop-shell-client-protocol.h		\
 	desktop-shell-protocol.c		\
+	fullscreen-shell-client-protocol.h	\
+	fullscreen-shell-protocol.c		\
 	tablet-shell-client-protocol.h		\
 	tablet-shell-protocol.c			\
 	subsurface-client-protocol.h		\
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 81bb54e..b55f13a 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -34,12 +34,14 @@
 
 #include <wayland-client.h>
 #include "../shared/os-compatibility.h"
+#include "fullscreen-shell-client-protocol.h"
 
 struct display {
 	struct wl_display *display;
 	struct wl_registry *registry;
 	struct wl_compositor *compositor;
 	struct wl_shell *shell;
+	struct wl_fullscreen_shell *fshell;
 	struct wl_shm *shm;
 	uint32_t formats;
 };
@@ -148,16 +150,25 @@ create_window(struct display *display, int width, int height)
 	window->width = width;
 	window->height = height;
 	window->surface = wl_compositor_create_surface(display->compositor);
-	window->shell_surface = wl_shell_get_shell_surface(display->shell,
-							   window->surface);
 
-	if (window->shell_surface)
+	if (display->shell) {
+		window->shell_surface =
+			wl_shell_get_shell_surface(display->shell,
+						   window->surface);
+		assert(window->shell_surface);
 		wl_shell_surface_add_listener(window->shell_surface,
 					      &shell_surface_listener, window);
 
-	wl_shell_surface_set_title(window->shell_surface, "simple-shm");
-
-	wl_shell_surface_set_toplevel(window->shell_surface);
+		wl_shell_surface_set_title(window->shell_surface, "simple-shm");
+		wl_shell_surface_set_toplevel(window->shell_surface);
+	} else if (display->fshell) {
+		wl_fullscreen_shell_present_surface(display->fshell,
+						    window->surface,
+						    WL_FULLSCREEN_SHELL_FULLSCREEN_METHOD_DEFAULT,
+						    0, NULL);
+	} else {
+		assert(0);
+	}
 
 	return window;
 }
@@ -173,7 +184,8 @@ destroy_window(struct window *window)
 	if (window->buffers[1].buffer)
 		wl_buffer_destroy(window->buffers[1].buffer);
 
-	wl_shell_surface_destroy(window->shell_surface);
+	if (window->shell_surface)
+		wl_shell_surface_destroy(window->shell_surface);
 	wl_surface_destroy(window->surface);
 	free(window);
 }
@@ -313,6 +325,9 @@ registry_handle_global(void *data, struct wl_registry *registry,
 	} else if (strcmp(interface, "wl_shell") == 0) {
 		d->shell = wl_registry_bind(registry,
 					    id, &wl_shell_interface, 1);
+	} else if (strcmp(interface, "wl_fullscreen_shell") == 0) {
+		d->fshell = wl_registry_bind(registry,
+					     id, &wl_fullscreen_shell_interface, 1);
 	} else if (strcmp(interface, "wl_shm") == 0) {
 		d->shm = wl_registry_bind(registry,
 					  id, &wl_shm_interface, 1);
@@ -375,6 +390,9 @@ destroy_display(struct display *display)
 	if (display->shell)
 		wl_shell_destroy(display->shell);
 
+	if (display->fshell)
+		wl_fullscreen_shell_destroy(display->fshell);
+
 	if (display->compositor)
 		wl_compositor_destroy(display->compositor);
 
-- 
1.8.3.1



More information about the wayland-devel mailing list