Skip to content
Snippets Groups Projects

simple-touch: Exit on xdg_toplevel::close

Merged Link Mauve requested to merge linkmauve/weston:simple-touch-small-fixes into main
1 file
+ 7
2
Compare changes
  • Side-by-side
  • Inline
+ 9
5
@@ -34,7 +34,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include <signal.h>
#include <wayland-client.h>
#include "shared/helpers.h"
@@ -64,9 +63,10 @@ struct touch {
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct buffer *buffer;
bool has_argb;
int width, height;
bool running;
bool wait_for_configure;
bool has_argb;
};
static struct buffer *
@@ -137,7 +137,7 @@ shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
struct touch *touch = data;
if (format == WL_SHM_FORMAT_ARGB8888)
touch->has_argb = 1;
touch->has_argb = true;
}
struct wl_shm_listener shm_listener = {
@@ -350,6 +350,8 @@ handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
static void
handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
{
struct touch *touch = data;
touch->running = false;
}
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
@@ -370,7 +372,7 @@ touch_create(int width, int height)
touch->display = wl_display_connect(NULL);
assert(touch->display);
touch->has_argb = 0;
touch->has_argb = false;
touch->registry = wl_display_get_registry(touch->display);
wl_registry_add_listener(touch->registry, &registry_listener, touch);
wl_display_dispatch(touch->display);
@@ -405,6 +407,8 @@ touch_create(int width, int height)
touch->wait_for_configure = true;
wl_surface_commit(touch->surface);
touch->running = true;
return touch;
}
@@ -439,7 +443,7 @@ main(int argc, char **argv)
touch = touch_create(600, 500);
while (ret != -1)
while (ret != -1 && touch->running)
ret = wl_display_dispatch(touch->display);
destroy_touch(touch);
Loading