--- clients/Makefile.am | 4 +++- clients/simple-shm.c | 50 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/clients/Makefile.am b/clients/Makefile.am index 91174bf..10f0d2a 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -37,7 +37,9 @@ simple_clients_programs = \ weston_simple_shm_SOURCES = simple-shm.c \ ../shared/os-compatibility.c \ - ../shared/os-compatibility.h + ../shared/os-compatibility.h \ + xdg-shell-client-protocol.h \ + xdg-shell-protocol.c weston_simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) diff --git a/clients/simple-shm.c b/clients/simple-shm.c index 81bb54e..d95b272 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -34,12 +34,13 @@ #include <wayland-client.h> #include "../shared/os-compatibility.h" +#include "xdg-shell-client-protocol.h" struct display { struct wl_display *display; struct wl_registry *registry; struct wl_compositor *compositor; - struct wl_shell *shell; + struct xdg_shell *xdg_shell; struct wl_shm *shm; uint32_t formats; }; @@ -54,7 +55,8 @@ struct window { struct display *display; int width, height; struct wl_surface *surface; - struct wl_shell_surface *shell_surface; + struct xdg_surface *shell_surface; + // struct wl_shell_surface *shell_surface; struct buffer buffers[2]; struct buffer *prev_buffer; struct wl_callback *callback; @@ -111,24 +113,24 @@ create_shm_buffer(struct display *display, struct buffer *buffer, } static void -handle_ping(void *data, struct wl_shell_surface *shell_surface, - uint32_t serial) +handle_ping(void *data, struct xdg_surface *shell_surface, + uint32_t serial) { - wl_shell_surface_pong(shell_surface, serial); + xdg_surface_pong(shell_surface, serial); } static void -handle_configure(void *data, struct wl_shell_surface *shell_surface, +handle_configure(void *data, struct xdg_surface *shell_surface, uint32_t edges, int32_t width, int32_t height) { } static void -handle_popup_done(void *data, struct wl_shell_surface *shell_surface) +handle_popup_done(void *data, struct xdg_surface *shell_surface) { } -static const struct wl_shell_surface_listener shell_surface_listener = { +static const struct xdg_surface_listener shell_surface_listener = { handle_ping, handle_configure, handle_popup_done @@ -148,16 +150,16 @@ 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); + window->shell_surface = xdg_shell_get_xdg_surface(display->xdg_shell, + window->surface); if (window->shell_surface) - wl_shell_surface_add_listener(window->shell_surface, - &shell_surface_listener, window); + xdg_surface_add_listener(window->shell_surface, + &shell_surface_listener, window); - wl_shell_surface_set_title(window->shell_surface, "simple-shm"); + // wl_shell_surface_set_title(window->shell_surface, "simple-shm"); - wl_shell_surface_set_toplevel(window->shell_surface); + // wl_shell_surface_set_toplevel(window->shell_surface); return window; } @@ -173,7 +175,7 @@ destroy_window(struct window *window) if (window->buffers[1].buffer) wl_buffer_destroy(window->buffers[1].buffer); - wl_shell_surface_destroy(window->shell_surface); + // wl_shell_surface_destroy(window->shell_surface); wl_surface_destroy(window->surface); free(window); } @@ -310,9 +312,12 @@ registry_handle_global(void *data, struct wl_registry *registry, d->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); - } else if (strcmp(interface, "wl_shell") == 0) { - d->shell = wl_registry_bind(registry, - id, &wl_shell_interface, 1); + // } else if (strcmp(interface, "wl_shell") == 0) { + // d->shell = wl_registry_bind(registry, + // id, &wl_shell_interface, 1); + } else if (strcmp(interface, "xdg_shell") == 0) { + d->xdg_shell = wl_registry_bind(registry, + id, &xdg_shell_interface, 1); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); @@ -356,6 +361,11 @@ create_display(void) wl_display_roundtrip(display->display); + if (display->xdg_shell == NULL) { + fprintf(stderr, "No xdg_shell global\n"); + exit (1); + } + if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) { fprintf(stderr, "WL_SHM_FORMAT_XRGB32 not available\n"); exit(1); @@ -372,8 +382,8 @@ destroy_display(struct display *display) if (display->shm) wl_shm_destroy(display->shm); - if (display->shell) - wl_shell_destroy(display->shell); + if (display->xdg_shell) + xdg_shell_destroy(display->xdg_shell); if (display->compositor) wl_compositor_destroy(display->compositor); -- 1.8.3.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel