input: Move surface picking into the pointer grab focus callback

Currently the core input code does surface picking before calling into
the focus callback of the current grab.  Not all grabs need to pick a
surface however, so we're doing work we don't have to in those cases.

For example, the shell move and resize grabs don't need to pick and the
default grab in implicit grab mode doesn't either.

With this change, the pointer grab mechanism is now very simple:
the focus callback is called whenever the pointer may have a new focus,
the motion callback is called whenever the pointer moves and
the button callback whenever a button is pressed or released.
diff --git a/src/data-device.c b/src/data-device.c
index 03e774d..0decbb9 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -212,11 +212,10 @@
 }
 
 static void
-drag_grab_focus(struct weston_pointer_grab *grab,
-		struct weston_surface *surface, wl_fixed_t x, wl_fixed_t y)
+weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
+		      wl_fixed_t sx, wl_fixed_t sy)
 {
-	struct weston_drag *drag =
-		container_of(grab, struct weston_drag, grab);
+	struct weston_pointer *pointer = drag->grab.pointer;
 	struct wl_resource *resource, *offer = NULL;
 	struct wl_display *display;
 	uint32_t serial;
@@ -234,7 +233,7 @@
 	if (!drag->data_source && surface->resource.client != drag->client)
 		return;
 
-	resource = find_resource(&drag->grab.pointer->seat->drag_resource_list,
+	resource = find_resource(&pointer->seat->drag_resource_list,
 				 surface->resource.client);
 	if (!resource)
 		return;
@@ -246,7 +245,7 @@
 		offer = wl_data_source_send_offer(drag->data_source, resource);
 
 	wl_data_device_send_enter(resource, serial, &surface->resource,
-				  x, y, offer);
+				  sx, sy, offer);
 
 	drag->focus = surface;
 	drag->focus_listener.notify = destroy_drag_focus;
@@ -255,6 +254,22 @@
 }
 
 static void
+drag_grab_focus(struct weston_pointer_grab *grab)
+{
+	struct weston_drag *drag =
+		container_of(grab, struct weston_drag, grab);
+	struct weston_pointer *pointer = grab->pointer;
+	struct weston_surface *surface;
+	wl_fixed_t sx, sy;
+
+	surface = weston_compositor_pick_surface(pointer->seat->compositor,
+						 pointer->x, pointer->y,
+						 &sx, &sy);
+	if (drag->focus != surface)
+		weston_drag_set_focus(drag, surface, sx, sy);
+}
+
+static void
 drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
 {
 	struct weston_drag *drag =
@@ -291,8 +306,7 @@
 		wl_list_remove(&drag->icon_destroy_listener.link);
 	}
 
-	drag_grab_focus(&drag->grab, NULL,
-	                wl_fixed_from_int(0), wl_fixed_from_int(0));
+	weston_drag_set_focus(drag, NULL, 0, 0);
 
 	weston_pointer_end_grab(drag->grab.pointer);