simple-shm: Add wl_fullscreen_shell support
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.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 0296028..2087a0e 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -35,12 +35,14 @@
#include <wayland-client.h>
#include "../shared/os-compatibility.h"
#include "xdg-shell-client-protocol.h"
+#include "fullscreen-shell-client-protocol.h"
struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
struct xdg_shell *shell;
+ struct _wl_fullscreen_shell *fshell;
struct wl_shm *shm;
uint32_t formats;
};
@@ -165,14 +167,26 @@
window->width = width;
window->height = height;
window->surface = wl_compositor_create_surface(display->compositor);
- window->xdg_surface = xdg_shell_get_xdg_surface(display->shell,
- window->surface);
- if (window->xdg_surface)
+ if (display->shell) {
+ window->xdg_surface =
+ xdg_shell_get_xdg_surface(display->shell,
+ window->surface);
+
+ assert(window->xdg_surface);
+
xdg_surface_add_listener(window->xdg_surface,
&xdg_surface_listener, window);
- xdg_surface_set_title(window->xdg_surface, "simple-shm");
+ xdg_surface_set_title(window->xdg_surface, "simple-shm");
+ } else if (display->fshell) {
+ _wl_fullscreen_shell_present_surface(display->fshell,
+ window->surface,
+ _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT,
+ NULL);
+ } else {
+ assert(0);
+ }
return window;
}
@@ -188,7 +202,8 @@
if (window->buffers[1].buffer)
wl_buffer_destroy(window->buffers[1].buffer);
- xdg_surface_destroy(window->xdg_surface);
+ if (window->xdg_surface)
+ xdg_surface_destroy(window->xdg_surface);
wl_surface_destroy(window->surface);
free(window);
}
@@ -346,6 +361,9 @@
id, &xdg_shell_interface, 1);
xdg_shell_use_unstable_version(d->shell, XDG_VERSION);
xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
+ } 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);
@@ -408,6 +426,9 @@
if (display->shell)
xdg_shell_destroy(display->shell);
+ if (display->fshell)
+ _wl_fullscreen_shell_release(display->fshell);
+
if (display->compositor)
wl_compositor_destroy(display->compositor);