Use scanner to generate screenshooter client code as well

dev
Kristian Høgsberg 14 years ago
parent c5dcb90d2a
commit 3dd66d66a3
  1. 10
      clients/Makefile
  2. 31
      clients/screenshot.c

@ -13,12 +13,20 @@ clean :
flower : flower.o window.o wayland-glib.o cairo-util.o
gears : gears.o window.o wayland-glib.o cairo-util.o
screenshot : screenshot.o wayland-glib.o cairo-util.o
screenshot : screenshot.o screenshooter-protocol.o wayland-glib.o cairo-util.o
terminal : terminal.o window.o wayland-glib.o cairo-util.o
image : image.o window.o wayland-glib.o cairo-util.o
view : view.o window.o wayland-glib.o cairo-util.o
dnd : dnd.o window.o wayland-glib.o cairo-util.o
screenshoot.c : screenshooter-client-protocol.h
screenshooter-protocol.c : ../compositor/screenshooter.xml
../wayland/scanner code < $< > $@
screenshooter-client-protocol.h : ../compositor/screenshooter.xml
../wayland/scanner client-header < $< > $@
terminal : LDLIBS += -lutil
view : CFLAGS += $(POPPLER_CFLAGS)
view : LDLIBS += $(POPPLER_LIBS)

@ -29,6 +29,7 @@
#include "wayland-client.h"
#include "wayland-glib.h"
#include "screenshooter-client-protocol.h"
/* The screenshooter is a good example of a custom object exposed by
* the compositor and serves as a test bed for implementing client
@ -36,36 +37,14 @@
static const char socket_name[] = "\0wayland";
#define SCREENSHOOTER_SHOOT 0
struct screenshooter;
static const struct wl_message screenshooter_requests[] = {
{ "shoot", "" },
};
static const struct wl_interface screenshooter_interface = {
"screenshooter", 1,
ARRAY_LENGTH(screenshooter_requests), screenshooter_requests,
0, NULL
};
static inline void
screenshooter_shoot(struct screenshooter *shooter)
{
wl_proxy_marshal((struct wl_proxy *) shooter, SCREENSHOOTER_SHOOT);
}
static void
handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
struct screenshooter **screenshooter = data;
struct wl_screenshooter **screenshooter = data;
if (strcmp(interface, "screenshooter") == 0)
*screenshooter = (struct screenshooter *)
wl_proxy_create_for_id(display,
&screenshooter_interface, id);
*screenshooter = wl_screenshooter_create(display, id);
}
int main(int argc, char *argv[])
@ -73,7 +52,7 @@ int main(int argc, char *argv[])
struct wl_display *display;
GMainLoop *loop;
GSource *source;
struct screenshooter *screenshooter;
struct wl_screenshooter *screenshooter;
display = wl_display_create(socket_name, sizeof socket_name);
if (display == NULL) {
@ -93,7 +72,7 @@ int main(int argc, char *argv[])
source = wl_glib_source_new(display);
g_source_attach(source, NULL);
screenshooter_shoot(screenshooter);
wl_screenshooter_shoot(screenshooter);
g_idle_add((GSourceFunc) g_main_loop_quit, loop);
g_main_loop_run(loop);

Loading…
Cancel
Save