Add client side demarshalling for events.

This also consolidates the marshalling code in connection.c and
uses the same functions in the server and client for marshalling.
diff --git a/wayland-system-compositor.c b/wayland-system-compositor.c
index 77c6bfe..09daebf 100644
--- a/wayland-system-compositor.c
+++ b/wayland-system-compositor.c
@@ -702,7 +702,9 @@
 
 	memset(device, 0, sizeof *device);
 	device->base.interface = &wl_input_device_interface;
+	device->base.implementation = NULL;
 	wl_display_add_object(ec->wl_display, &device->base);
+	wl_display_add_global(ec->wl_display, &device->base, NULL);
 	device->x = 100;
 	device->y = 100;
 	device->pointer_surface =