Update to new fd and wl_registry APIs

This commit updates the clients and the wayland compositor backend to
use the new wl_registry mechanism and the thread safe fd API.
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index f62e54e..fc05bb4 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -35,11 +35,11 @@
 
 struct display {
 	struct wl_display *display;
+	struct wl_registry *registry;
 	struct wl_compositor *compositor;
 	struct wl_shell *shell;
 	struct wl_shm *shm;
 	uint32_t formats;
-	uint32_t mask;
 };
 
 struct window {
@@ -242,31 +242,28 @@
 };
 
 static void
-display_handle_global(struct wl_display *display, uint32_t id,
-		      const char *interface, uint32_t version, void *data)
+registry_handle_global(void *data, struct wl_registry *registry,
+		       uint32_t id, const char *interface, uint32_t version)
 {
 	struct display *d = data;
 
 	if (strcmp(interface, "wl_compositor") == 0) {
 		d->compositor =
-			wl_display_bind(display, id, &wl_compositor_interface);
+			wl_registry_bind(registry,
+					 id, &wl_compositor_interface, 1);
 	} else if (strcmp(interface, "wl_shell") == 0) {
-		d->shell = wl_display_bind(display, id, &wl_shell_interface);
+		d->shell = wl_registry_bind(registry,
+					    id, &wl_shell_interface, 1);
 	} else if (strcmp(interface, "wl_shm") == 0) {
-		d->shm = wl_display_bind(display, id, &wl_shm_interface);
+		d->shm = wl_registry_bind(registry,
+					  id, &wl_shm_interface, 1);
 		wl_shm_add_listener(d->shm, &shm_listenter, d);
 	}
 }
 
-static int
-event_mask_update(uint32_t mask, void *data)
-{
-	struct display *d = data;
-
-	d->mask = mask;
-
-	return 0;
-}
+static const struct wl_registry_listener registry_listener = {
+	registry_handle_global
+};
 
 static struct display *
 create_display(void)
@@ -278,9 +275,15 @@
 	assert(display->display);
 
 	display->formats = 0;
-	wl_display_add_global_listener(display->display,
-				       display_handle_global, display);
-	wl_display_iterate(display->display, WL_DISPLAY_READABLE);
+	display->registry = wl_display_get_registry(display->display);
+	wl_registry_add_listener(display->registry,
+				 &registry_listener, display);
+	wl_display_roundtrip(display->display);
+	if (display->shm == NULL) {
+		fprintf(stderr, "No wl_shm global\n");
+		exit(1);
+	}
+
 	wl_display_roundtrip(display->display);
 
 	if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
@@ -288,7 +291,7 @@
 		exit(1);
 	}
 
-	wl_display_get_fd(display->display, event_mask_update, display);
+	wl_display_get_fd(display->display);
 	
 	return display;
 }
@@ -341,7 +344,7 @@
 	redraw(window, NULL, 0);
 
 	while (running)
-		wl_display_iterate(display->display, display->mask);
+		wl_display_dispatch(display->display);
 
 	fprintf(stderr, "simple-shm exiting\n");
 	destroy_window(window);