Use scanner to generate screenshooter client code as well
authorKristian Høgsberg <krh@bitplanet.net>
Tue, 14 Sep 2010 20:23:24 +0000 (16:23 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 14 Sep 2010 20:23:24 +0000 (16:23 -0400)
clients/Makefile
clients/screenshot.c

index 222a7ae..c85b250 100644 (file)
@@ -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)
index 4891fd7..e9fa5aa 100644 (file)
@@ -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
 
 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);