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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
dev
Jonas Ådahl 8 years ago
parent 42682624a0
commit 6ccd286662
  1. 6
      Makefile.am
  2. 88
      clients/simple-dmabuf-v4l.c

@ -592,8 +592,8 @@ if BUILD_SIMPLE_DMABUF_V4L_CLIENT
demo_clients += weston-simple-dmabuf-v4l demo_clients += weston-simple-dmabuf-v4l
weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c
nodist_weston_simple_dmabuf_v4l_SOURCES = \ nodist_weston_simple_dmabuf_v4l_SOURCES = \
protocol/xdg-shell-unstable-v5-protocol.c \ protocol/xdg-shell-unstable-v6-protocol.c \
protocol/xdg-shell-unstable-v5-client-protocol.h \ protocol/xdg-shell-unstable-v6-client-protocol.h \
protocol/fullscreen-shell-unstable-v1-protocol.c \ protocol/fullscreen-shell-unstable-v1-protocol.c \
protocol/fullscreen-shell-unstable-v1-client-protocol.h \ protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \ protocol/linux-dmabuf-unstable-v1-protocol.c \
@ -834,8 +834,6 @@ BUILT_SOURCES += \
protocol/presentation-time-client-protocol.h \ protocol/presentation-time-client-protocol.h \
protocol/fullscreen-shell-unstable-v1-protocol.c \ protocol/fullscreen-shell-unstable-v1-protocol.c \
protocol/fullscreen-shell-unstable-v1-client-protocol.h \ protocol/fullscreen-shell-unstable-v1-client-protocol.h \
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-protocol.c \
protocol/xdg-shell-unstable-v6-client-protocol.h \ protocol/xdg-shell-unstable-v6-client-protocol.h \
protocol/ivi-hmi-controller-protocol.c \ protocol/ivi-hmi-controller-protocol.c \

@ -44,12 +44,15 @@
#include <wayland-client.h> #include <wayland-client.h>
#include "shared/zalloc.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 "fullscreen-shell-unstable-v1-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h"
#define CLEAR(x) memset(&(x), 0, sizeof(x)) #define CLEAR(x) memset(&(x), 0, sizeof(x))
static void
redraw(void *data, struct wl_callback *callback, uint32_t time);
static int static int
xioctl(int fh, int request, void *arg) xioctl(int fh, int request, void *arg)
{ {
@ -94,7 +97,7 @@ struct display {
struct wl_compositor *compositor; struct wl_compositor *compositor;
struct wl_seat *seat; struct wl_seat *seat;
struct wl_keyboard *keyboard; struct wl_keyboard *keyboard;
struct xdg_shell *shell; struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell; struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf; struct zwp_linux_dmabuf_v1 *dmabuf;
bool requested_format_found; bool requested_format_found;
@ -119,9 +122,12 @@ struct buffer {
struct window { struct window {
struct display *display; struct display *display;
struct wl_surface *surface; 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 buffers[NUM_BUFFERS];
struct wl_callback *callback; struct wl_callback *callback;
bool wait_for_configure;
bool initialized;
}; };
static bool running = true; static bool running = true;
@ -524,21 +530,38 @@ start_capture(struct display *display)
} }
static void static void
handle_configure(void *data, struct xdg_surface *surface, 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
xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
int32_t width, int32_t height, int32_t width, int32_t height,
struct wl_array *states, uint32_t serial) struct wl_array *states)
{ {
} }
static void static void
handle_delete(void *data, struct xdg_surface *xdg_surface) xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
{ {
running = false; running = 0;
} }
static const struct xdg_surface_listener xdg_surface_listener = { static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
handle_configure, xdg_toplevel_handle_configure,
handle_delete, xdg_toplevel_handle_close,
}; };
static struct window * static struct window *
@ -556,15 +579,26 @@ create_window(struct display *display)
if (display->shell) { if (display->shell) {
window->xdg_surface = window->xdg_surface =
xdg_shell_get_xdg_surface(display->shell, zxdg_shell_v6_get_xdg_surface(display->shell,
window->surface); window->surface);
assert(window->xdg_surface); assert(window->xdg_surface);
xdg_surface_add_listener(window->xdg_surface, zxdg_surface_v6_add_listener(window->xdg_surface,
&xdg_surface_listener, window); &xdg_surface_listener, window);
xdg_surface_set_title(window->xdg_surface, "simple-dmabuf-v4l"); window->xdg_toplevel =
zxdg_surface_v6_get_toplevel(window->xdg_surface);
assert(window->xdg_toplevel);
zxdg_toplevel_v6_add_listener(window->xdg_toplevel,
&xdg_toplevel_listener, window);
zxdg_toplevel_v6_set_title(window->xdg_toplevel, "simple-dmabuf-v4l");
window->wait_for_configure = true;
wl_surface_commit(window->surface);
} else if (display->fshell) { } else if (display->fshell) {
zwp_fullscreen_shell_v1_present_surface(display->fshell, zwp_fullscreen_shell_v1_present_surface(display->fshell,
window->surface, window->surface,
@ -586,8 +620,10 @@ destroy_window(struct window *window)
if (window->callback) if (window->callback)
wl_callback_destroy(window->callback); wl_callback_destroy(window->callback);
if (window->xdg_toplevel)
zxdg_toplevel_v6_destroy(window->xdg_toplevel);
if (window->xdg_surface) if (window->xdg_surface)
xdg_surface_destroy(window->xdg_surface); zxdg_surface_v6_destroy(window->xdg_surface);
wl_surface_destroy(window->surface); wl_surface_destroy(window->surface);
for (i = 0; i < NUM_BUFFERS; i++) { for (i = 0; i < NUM_BUFFERS; i++) {
@ -738,21 +774,15 @@ static const struct wl_seat_listener seat_listener = {
}; };
static void 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, 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 static void
registry_handle_global(void *data, struct wl_registry *registry, registry_handle_global(void *data, struct wl_registry *registry,
uint32_t id, const char *interface, uint32_t version) uint32_t id, const char *interface, uint32_t version)
@ -767,11 +797,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
d->seat = wl_registry_bind(registry, d->seat = wl_registry_bind(registry,
id, &wl_seat_interface, 1); id, &wl_seat_interface, 1);
wl_seat_add_listener(d->seat, &seat_listener, d); wl_seat_add_listener(d->seat, &seat_listener, d);
} else if (strcmp(interface, "xdg_shell") == 0) { } else if (strcmp(interface, "zxdg_shell_v6") == 0) {
d->shell = wl_registry_bind(registry, d->shell = wl_registry_bind(registry,
id, &xdg_shell_interface, 1); id, &zxdg_shell_v6_interface, 1);
xdg_shell_use_unstable_version(d->shell, XDG_VERSION); zxdg_shell_v6_add_listener(d->shell, &xdg_shell_listener, d);
xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
} else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) { } else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) {
d->fshell = wl_registry_bind(registry, d->fshell = wl_registry_bind(registry,
id, &zwp_fullscreen_shell_v1_interface, id, &zwp_fullscreen_shell_v1_interface,
@ -840,7 +869,7 @@ destroy_display(struct display *display)
zwp_linux_dmabuf_v1_destroy(display->dmabuf); zwp_linux_dmabuf_v1_destroy(display->dmabuf);
if (display->shell) if (display->shell)
xdg_shell_destroy(display->shell); zxdg_shell_v6_destroy(display->shell);
if (display->fshell) if (display->fshell)
zwp_fullscreen_shell_v1_release(display->fshell); zwp_fullscreen_shell_v1_release(display->fshell);
@ -933,6 +962,9 @@ main(int argc, char **argv)
if (!start_capture(display)) if (!start_capture(display))
return 1; return 1;
window->initialized = true;
if (!window->wait_for_configure)
redraw(window, NULL, 0); redraw(window, NULL, 0);
while (running && ret != -1) while (running && ret != -1)

Loading…
Cancel
Save