Commit 42682624 authored by Jonas Ådahl's avatar Jonas Ådahl

clients/simple-dmabuf-intel: Port to xdg_shell unstable v6

Signed-off-by: Jonas Ådahl's avatarJonas Ådahl <jadahl@gmail.com>
Acked-by: default avatarBryce Harrington <bryce@osg.samsung.com>
Acked-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic's avatarQuentin Glidic <sardemff7+git@sardemff7.net>
parent a74eff92
......@@ -577,8 +577,8 @@ if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
demo_clients += weston-simple-dmabuf-intel
weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
nodist_weston_simple_dmabuf_intel_SOURCES = \
protocol/xdg-shell-unstable-v5-protocol.c \
protocol/xdg-shell-unstable-v5-client-protocol.h \
protocol/xdg-shell-unstable-v6-protocol.c \
protocol/xdg-shell-unstable-v6-client-protocol.h \
protocol/fullscreen-shell-unstable-v1-protocol.c \
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
......
......@@ -42,7 +42,7 @@
#include <wayland-client.h>
#include "shared/zalloc.h"
#include "xdg-shell-unstable-v5-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
......@@ -50,7 +50,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
struct xdg_shell *shell;
struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb8888_format_found;
......@@ -81,14 +81,20 @@ struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
struct xdg_surface *xdg_surface;
struct zxdg_surface_v6 *xdg_surface;
struct zxdg_toplevel_v6 *xdg_toplevel;
struct buffer buffers[NUM_BUFFERS];
struct buffer *prev_buffer;
struct wl_callback *callback;
bool initialized;
bool wait_for_configure;
};
static int running = 1;
static void
redraw(void *data, struct wl_callback *callback, uint32_t time);
static void
buffer_release(void *data, struct wl_buffer *buffer)
{
......@@ -290,21 +296,38 @@ error:
}
static void
handle_configure(void *data, struct xdg_surface *surface,
int32_t width, int32_t height,
struct wl_array *states, uint32_t serial)
xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *surface,
uint32_t serial)
{
struct window *window = data;
zxdg_surface_v6_ack_configure(surface, serial);
if (window->initialized && window->wait_for_configure)
redraw(window, NULL, 0);
window->wait_for_configure = false;
}
static const struct zxdg_surface_v6_listener xdg_surface_listener = {
xdg_surface_handle_configure,
};
static void
handle_delete(void *data, struct xdg_surface *xdg_surface)
xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
int32_t width, int32_t height,
struct wl_array *states)
{
}
static void
xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
{
running = 0;
}
static const struct xdg_surface_listener xdg_surface_listener = {
handle_configure,
handle_delete,
static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
xdg_toplevel_handle_configure,
xdg_toplevel_handle_close,
};
static struct window *
......@@ -326,15 +349,26 @@ create_window(struct display *display, int width, int height)
if (display->shell) {
window->xdg_surface =
xdg_shell_get_xdg_surface(display->shell,
window->surface);
zxdg_shell_v6_get_xdg_surface(display->shell,
window->surface);
assert(window->xdg_surface);
xdg_surface_add_listener(window->xdg_surface,
&xdg_surface_listener, window);
zxdg_surface_v6_add_listener(window->xdg_surface,
&xdg_surface_listener, window);
window->xdg_toplevel =
zxdg_surface_v6_get_toplevel(window->xdg_surface);
assert(window->xdg_toplevel);
xdg_surface_set_title(window->xdg_surface, "simple-dmabuf");
zxdg_toplevel_v6_add_listener(window->xdg_toplevel,
&xdg_toplevel_listener, window);
zxdg_toplevel_v6_set_title(window->xdg_toplevel, "simple-dmabuf");
window->wait_for_configure = true;
wl_surface_commit(window->surface);
} else if (display->fshell) {
zwp_fullscreen_shell_v1_present_surface(display->fshell,
window->surface,
......@@ -373,8 +407,10 @@ destroy_window(struct window *window)
drm_shutdown(&window->buffers[i]);
}
if (window->xdg_toplevel)
zxdg_toplevel_v6_destroy(window->xdg_toplevel);
if (window->xdg_surface)
xdg_surface_destroy(window->xdg_surface);
zxdg_surface_v6_destroy(window->xdg_surface);
wl_surface_destroy(window->surface);
free(window);
}
......@@ -439,21 +475,15 @@ static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {
};
static void
xdg_shell_ping(void *data, struct xdg_shell *shell, uint32_t serial)
xdg_shell_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial)
{
xdg_shell_pong(shell, serial);
zxdg_shell_v6_pong(shell, serial);
}
static const struct xdg_shell_listener xdg_shell_listener = {
static const struct zxdg_shell_v6_listener xdg_shell_listener = {
xdg_shell_ping,
};
#define XDG_VERSION 5 /* The version of xdg-shell that we implement */
#ifdef static_assert
static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT,
"Interface version doesn't match implementation version");
#endif
static void
registry_handle_global(void *data, struct wl_registry *registry,
uint32_t id, const char *interface, uint32_t version)
......@@ -464,11 +494,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
d->compositor =
wl_registry_bind(registry,
id, &wl_compositor_interface, 1);
} else if (strcmp(interface, "xdg_shell") == 0) {
} else if (strcmp(interface, "zxdg_shell_v6") == 0) {
d->shell = wl_registry_bind(registry,
id, &xdg_shell_interface, 1);
xdg_shell_use_unstable_version(d->shell, XDG_VERSION);
xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
id, &zxdg_shell_v6_interface, 1);
zxdg_shell_v6_add_listener(d->shell, &xdg_shell_listener, d);
} else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) {
d->fshell = wl_registry_bind(registry,
id, &zwp_fullscreen_shell_v1_interface, 1);
......@@ -532,7 +561,7 @@ destroy_display(struct display *display)
zwp_linux_dmabuf_v1_destroy(display->dmabuf);
if (display->shell)
xdg_shell_destroy(display->shell);
zxdg_shell_v6_destroy(display->shell);
if (display->fshell)
zwp_fullscreen_shell_v1_release(display->fshell);
......@@ -576,7 +605,10 @@ main(int argc, char **argv)
if (!running)
return 1;
redraw(window, NULL, 0);
window->initialized = true;
if (!window->wait_for_configure)
redraw(window, NULL, 0);
while (running && ret != -1)
ret = wl_display_dispatch(display->display);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment