Use typesafe server-side stubs
diff --git a/src/compositor.c b/src/compositor.c
index 0c99a5f..63d09cc 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -965,7 +965,7 @@
 	output->repaint_needed = 0;
 
 	wl_list_for_each_safe(cb, cnext, &output->frame_callback_list, link) {
-		wl_resource_post_event(&cb->resource, WL_CALLBACK_DONE, msecs);
+		wl_callback_send_done(&cb->resource, msecs);
 		wl_resource_destroy(&cb->resource, 0);
 	}
 
@@ -1765,10 +1765,9 @@
 		}
 
 		if (wd->touch_focus_resource && wd->touch_focus)
-			wl_resource_post_event(wd->touch_focus_resource,
-					       touch_type, time,
-					       wd->touch_focus,
-					       touch_id, sx, sy);
+			wl_input_device_send_touch_down(wd->touch_focus_resource,
+							time, &wd->touch_focus->resource,
+							touch_id, sx, sy);
 		break;
 	case WL_INPUT_DEVICE_TOUCH_MOTION:
 		es = (struct weston_surface *) wd->touch_focus;
@@ -1777,17 +1776,16 @@
 
 		weston_surface_from_global(es, x, y, &sx, &sy);
 		if (wd->touch_focus_resource)
-			wl_resource_post_event(wd->touch_focus_resource,
-					       touch_type, time,
-					       touch_id, sx, sy);
+			wl_input_device_send_touch_motion(wd->touch_focus_resource,
+							  time, touch_id, sx, sy);
 		break;
 	case WL_INPUT_DEVICE_TOUCH_UP:
 		weston_compositor_idle_release(ec);
 		wd->num_tp--;
 
 		if (wd->touch_focus_resource)
-			wl_resource_post_event(wd->touch_focus_resource,
-					       touch_type, time, touch_id);
+			wl_input_device_send_touch_up(wd->touch_focus_resource,
+						      time, touch_id);
 		if (wd->num_tp == 0)
 			touch_set_focus(wd, NULL, time);
 		break;
@@ -2004,22 +2002,20 @@
 	resource = wl_client_add_object(client,
 					&wl_output_interface, NULL, id, data);
 
-	wl_resource_post_event(resource,
-			       WL_OUTPUT_GEOMETRY,
-			       output->x,
-			       output->y,
-			       output->mm_width,
-			       output->mm_height,
-			       output->subpixel,
-			       output->make, output->model);
+	wl_output_send_geometry(resource,
+				output->x,
+				output->y,
+				output->mm_width,
+				output->mm_height,
+				output->subpixel,
+				output->make, output->model);
 
 	wl_list_for_each (mode, &output->mode_list, link) {
-		wl_resource_post_event(resource,
-				       WL_OUTPUT_MODE,
-				       mode->flags,
-				       mode->width,
-				       mode->height,
-				       mode->refresh);
+		wl_output_send_mode(resource,
+				    mode->flags,
+				    mode->width,
+				    mode->height,
+				    mode->refresh);
 	}
 }
 
diff --git a/src/shell.c b/src/shell.c
index 4725335..ac7301a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -292,9 +292,8 @@
 		height = resize->height;
 	}
 
-	wl_resource_post_event(&resize->shsurf->resource,
-			       WL_SHELL_SURFACE_CONFIGURE, time, resize->edges,
-			       width, height);
+	wl_shell_surface_send_configure(&resize->shsurf->resource,
+					time, resize->edges, width, height);
 }
 
 static void
@@ -513,11 +512,11 @@
 	wlshell = shell_surface_get_shell(shsurf);
 	panel_height = get_output_panel_height(wlshell, es->output);
 	edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT;
-	wl_resource_post_event(&shsurf->resource,
-			       WL_SHELL_SURFACE_CONFIGURE,
-			       weston_compositor_get_time(), edges,
-			       es->output->current->width,
-			       es->output->current->height - panel_height);
+
+	wl_shell_surface_send_configure(&shsurf->resource,
+					weston_compositor_get_time(), edges,
+					es->output->current->width,
+					es->output->current->height - panel_height);
 
 	shsurf->type = SHELL_SURFACE_MAXIMIZED;
 }
@@ -641,11 +640,10 @@
 	if (es->output)
 		shsurf->surface->force_configure = 1;
 
-	wl_resource_post_event(resource,
-			       WL_SHELL_SURFACE_CONFIGURE,
-			       weston_compositor_get_time(), 0,
-			       shsurf->output->current->width,
-			       shsurf->output->current->height);
+	wl_shell_surface_send_configure(&shsurf->resource,
+					weston_compositor_get_time(), 0,
+					shsurf->output->current->width,
+					shsurf->output->current->height);
 }
 
 static void
@@ -674,8 +672,7 @@
 
 	resource = grab->input_device->pointer_focus_resource;
 	if (resource)
-		wl_resource_post_event(resource, WL_INPUT_DEVICE_MOTION,
-				       time, sx, sy);
+		wl_input_device_send_motion(resource, time, sx, sy);
 }
 
 static void
@@ -688,13 +685,11 @@
 
 	resource = grab->input_device->pointer_focus_resource;
 	if (resource) {
-		wl_resource_post_event(resource, WL_INPUT_DEVICE_BUTTON,
-				       time, button, state);
+		wl_input_device_send_button(resource, time, button, state);
 	} else if (state == 0 &&
 		   (shsurf->popup.initial_up ||
 		    time - shsurf->popup.time > 500)) {
-		wl_resource_post_event(&shsurf->resource,
-				       WL_SHELL_SURFACE_POPUP_DONE);
+		wl_shell_surface_send_popup_done(&shsurf->resource);
 		wl_input_device_end_pointer_grab(grab->input_device, time);
 		shsurf->popup.grab.input_device = NULL;
 	}
@@ -962,11 +957,11 @@
 	weston_surface_set_position(surface, shsurf->output->x,
 				    shsurf->output->y);
 
-	wl_resource_post_event(resource,
-			       DESKTOP_SHELL_CONFIGURE,
-			       weston_compositor_get_time(), 0, surface_resource,
-			       shsurf->output->current->width,
-			       shsurf->output->current->height);
+	desktop_shell_send_configure(resource,
+				     weston_compositor_get_time(), 0,
+				     surface_resource,
+				     shsurf->output->current->width,
+				     shsurf->output->current->height);
 }
 
 static void
@@ -1000,11 +995,11 @@
 	weston_surface_set_position(surface, shsurf->output->x,
 				    shsurf->output->y);
 
-	wl_resource_post_event(resource,
-			       DESKTOP_SHELL_CONFIGURE,
-			       weston_compositor_get_time(), 0, surface_resource,
-			       shsurf->output->current->width,
-			       shsurf->output->current->height);
+	desktop_shell_send_configure(resource,
+				     weston_compositor_get_time(), 0,
+				     surface_resource,
+				     shsurf->output->current->width,
+				     shsurf->output->current->height);
 }
 
 static void
@@ -1505,8 +1500,7 @@
 	if (shell->prepare_event_sent)
 		return;
 
-	wl_resource_post_event(shell->child.desktop_shell,
-			       DESKTOP_SHELL_PREPARE_LOCK_SURFACE);
+	desktop_shell_send_prepare_lock_surface(shell->child.desktop_shell);
 	shell->prepare_event_sent = true;
 }
 
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 2c325db..cf7da65 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -120,8 +120,7 @@
 		if (shell->state == STATE_STARTING) {
 			tablet_shell_set_state(shell, STATE_LOCKED);
 			shell->previous_state = STATE_HOME;
-			wl_resource_post_event(&shell->resource,
-					       TABLET_SHELL_SHOW_LOCKSCREEN);
+			tablet_shell_send_show_lockscreen(&shell->resource);
 		}
 	} else if (shell->current_client &&
 		   shell->current_client->surface != surface &&
@@ -373,12 +372,10 @@
 {
 	switch (shell->state) {
 	case STATE_SWITCHER:
-		wl_resource_post_event(&shell->resource,
-				     TABLET_SHELL_HIDE_SWITCHER);
+		tablet_shell_send_hide_switcher(&shell->resource);
 		break;
 	default:
-		wl_resource_post_event(&shell->resource,
-				       TABLET_SHELL_SHOW_SWITCHER);
+		tablet_shell_send_show_switcher(&shell->resource);
 		tablet_shell_set_state(shell, STATE_SWITCHER);
 		break;
 	}
@@ -393,12 +390,9 @@
 	if (shell->state == STATE_LOCKED)
 		return;
 	if (shell->state == STATE_SWITCHER)
-		wl_resource_post_event(&shell->resource,
-				       TABLET_SHELL_HIDE_SWITCHER);
+		tablet_shell_send_hide_switcher(&shell->resource);
 
-	wl_resource_post_event(&shell->resource,
-			       TABLET_SHELL_SHOW_LOCKSCREEN);
-	
+	tablet_shell_send_show_lockscreen(&shell->resource);
 	tablet_shell_set_state(shell, STATE_LOCKED);
 }
 
@@ -418,8 +412,7 @@
 		(struct weston_input_device *) shell->compositor->input_device;
 
 	if (shell->state == STATE_SWITCHER)
-		wl_resource_post_event(&shell->resource,
-				       TABLET_SHELL_HIDE_SWITCHER);
+		tablet_shell_send_hide_switcher(&shell->resource);
 
 	weston_surface_activate(shell->home_surface, device,
 			      weston_compositor_get_time());
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index b85b813..7fc79d8 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -856,8 +856,8 @@
 						   weston_wm_read_data_source,
 						   wm);
 
-	wl_resource_post_event(&device->selection_data_source->resource,
-			       WL_DATA_SOURCE_SEND, mime_type, p[1]);
+	wl_data_source_send_send(&device->selection_data_source->resource,
+				 mime_type, p[1]);
 	close(p[1]);
 }
 
@@ -1277,7 +1277,7 @@
 		return NULL;
 	}
 
-	wl_resource_post_event(wxs->resource, XSERVER_CLIENT, sv[1]);
+	xserver_send_client(wxs->resource, sv[1]);
 	wl_client_flush(wxs->resource->client);
 	close(sv[1]);
 	
@@ -1556,11 +1556,8 @@
 		fprintf(stderr, "failed to create wm\n");
 	}
 
-	wl_resource_post_event(wxs->resource,
-			       XSERVER_LISTEN_SOCKET, wxs->abstract_fd);
-
-	wl_resource_post_event(wxs->resource,
-			       XSERVER_LISTEN_SOCKET, wxs->unix_fd);
+	xserver_send_listen_socket(wxs->resource, wxs->abstract_fd);
+	xserver_send_listen_socket(wxs->resource, wxs->unix_fd);
 }
 
 static int