interactive-wayland: Port to xdg-shell v6 Mutter only implements v6 now, and Weston also implements that. Port interactive-wayland to this so people can keep on using it. Signed-off-by: Daniel Stone <daniels@collabora.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
diff --git a/.gitignore b/.gitignore
index 4f48cd2..bc6cce9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -82,5 +82,5 @@ cscope.out
test-suite.log
test-driver
build-aux/
-/xdg-shell-unstable-v5-client-protocol.h
-/xdg-shell-unstable-v5-protocol.c
+/xdg-shell-unstable-v6-client-protocol.h
+/xdg-shell-unstable-v6-protocol.c
diff --git a/Makefile.am b/Makefile.am
index 1f8e219..8a12b43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -277,8 +277,8 @@ endef
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
INTERACTIVE_WL_XDG_SHELL_SRCS = \
- xdg-shell-unstable-v5-protocol.c \
- xdg-shell-unstable-v5-client-protocol.h
+ xdg-shell-unstable-v6-protocol.c \
+ xdg-shell-unstable-v6-client-protocol.h
test_interactive_wayland_SOURCES = \
test/interactive-wayland.c \
diff --git a/configure.ac b/configure.ac
index 725915b..a87ad0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,7 +181,7 @@ You can disable X11 support with --disable-x11.])])
], [enable_x11=no])
AM_CONDITIONAL([ENABLE_X11], [test "x$enable_x11" = xyes])
-WAYLAND_PKGS="wayland-client >= 1.2.0 wayland-protocols >= 1.0 wayland-scanner"
+WAYLAND_PKGS="wayland-client >= 1.2.0 wayland-protocols >= 1.7 wayland-scanner"
AC_ARG_ENABLE([wayland],
[AS_HELP_STRING([--disable-wayland],
[Disable support for Wayland utility programs (default: auto)])],
diff --git a/test/interactive-wayland.c b/test/interactive-wayland.c
index 94c60c8..7686854 100644
--- a/test/interactive-wayland.c
+++ b/test/interactive-wayland.c
@@ -34,20 +34,21 @@
#include "test.h"
#include <wayland-client.h>
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
#include <wayland-util.h>
struct interactive_dpy {
struct wl_display *dpy;
struct wl_compositor *compositor;
- struct xdg_shell *shell;
+ struct zxdg_shell_v6 *shell;
struct wl_shm *shm;
uint32_t shm_format;
struct xkb_context *ctx;
struct wl_surface *wl_surf;
- struct xdg_surface *xdg_surf;
+ struct zxdg_surface_v6 *xdg_surf;
+ struct zxdg_toplevel_v6 *xdg_top;
struct wl_list seats;
};
@@ -255,56 +256,65 @@ buffer_create(struct interactive_dpy *inter, uint32_t width, uint32_t height)
}
static void
-surface_configure(void *data, struct xdg_surface *surface,
- int32_t width, int32_t height, struct wl_array *states,
+surface_configure(void *data, struct zxdg_surface_v6 *surface,
uint32_t serial)
{
struct interactive_dpy *inter = data;
- if (width == 0 || height == 0) {
- xdg_surface_ack_configure(inter->xdg_surf, serial);
- return;
- }
+ zxdg_surface_v6_ack_configure(inter->xdg_surf, serial);
+ wl_surface_commit(inter->wl_surf);
+}
+
+static const struct zxdg_surface_v6_listener surface_listener = {
+ surface_configure,
+};
+
+static void
+toplevel_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height, struct wl_array *states)
+{
+ struct interactive_dpy *inter = data;
+
+ if (width == 0)
+ width = 200;
+ if (height == 0)
+ height = 200;
buffer_create(inter, width, height);
- xdg_surface_ack_configure(inter->xdg_surf, serial);
- wl_surface_commit(inter->wl_surf);
}
static void
-surface_close(void *data, struct xdg_surface *surface)
+toplevel_close(void *data, struct zxdg_toplevel_v6 *toplevel)
{
terminate = true;
}
-static const struct xdg_surface_listener surface_listener = {
- surface_configure,
- surface_close
+static const struct zxdg_toplevel_v6_listener toplevel_listener = {
+ toplevel_configure,
+ toplevel_close
};
static void surface_create(struct interactive_dpy *inter)
{
- int width = 200, height = 200;
-
inter->wl_surf = wl_compositor_create_surface(inter->compositor);
- inter->xdg_surf = xdg_shell_get_xdg_surface(inter->shell,
- inter->wl_surf);
- xdg_surface_add_listener(inter->xdg_surf, &surface_listener, inter);
- xdg_surface_set_title(inter->xdg_surf, "xkbcommon event tester");
- xdg_surface_set_app_id(inter->xdg_surf,
- "org.xkbcommon.test.interactive-wayland");
-
- buffer_create(inter, width, height);
+ inter->xdg_surf = zxdg_shell_v6_get_xdg_surface(inter->shell,
+ inter->wl_surf);
+ zxdg_surface_v6_add_listener(inter->xdg_surf, &surface_listener, inter);
+ inter->xdg_top = zxdg_surface_v6_get_toplevel(inter->xdg_surf);
+ zxdg_toplevel_v6_add_listener(inter->xdg_top, &toplevel_listener, inter);
+ zxdg_toplevel_v6_set_title(inter->xdg_top, "xkbcommon event tester");
+ zxdg_toplevel_v6_set_app_id(inter->xdg_top,
+ "org.xkbcommon.test.interactive-wayland");
wl_surface_commit(inter->wl_surf);
}
static void
-shell_ping(void *data, struct xdg_shell *shell, uint32_t serial)
+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 shell_listener = {
+static const struct zxdg_shell_v6_listener shell_listener = {
shell_ping
};
@@ -418,7 +428,7 @@ pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
{
struct interactive_seat *seat = data;
- xdg_surface_move(seat->inter->xdg_surf, seat->wl_seat, serial);
+ zxdg_toplevel_v6_move(seat->inter->xdg_top, seat->wl_seat, serial);
}
static void
@@ -569,12 +579,11 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name,
if (strcmp(interface, "wl_seat") == 0) {
seat_create(inter, registry, name, version);
}
- else if (strcmp(interface, "xdg_shell") == 0) {
+ else if (strcmp(interface, "zxdg_shell_v6") == 0) {
inter->shell = wl_registry_bind(registry, name,
- &xdg_shell_interface,
+ &zxdg_shell_v6_interface,
MAX(version, 1));
- xdg_shell_add_listener(inter->shell, &shell_listener, inter);
- xdg_shell_use_unstable_version(inter->shell, 5);
+ zxdg_shell_v6_add_listener(inter->shell, &shell_listener, inter);
}
else if (strcmp(interface, "wl_compositor") == 0) {
inter->compositor = wl_registry_bind(registry, name,
@@ -615,11 +624,13 @@ dpy_disconnect(struct interactive_dpy *inter)
seat_destroy(seat);
if (inter->xdg_surf)
- xdg_surface_destroy(inter->xdg_surf);
+ zxdg_surface_v6_destroy(inter->xdg_surf);
+ if (inter->xdg_top)
+ zxdg_toplevel_v6_destroy(inter->xdg_top);
if (inter->wl_surf)
wl_surface_destroy(inter->wl_surf);
if (inter->shell)
- xdg_shell_destroy(inter->shell);
+ zxdg_shell_v6_destroy(inter->shell);
if (inter->compositor)
wl_compositor_destroy(inter->compositor);
if (inter->shm)