input: Don't test keyboard/pointer/touch pointers

Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.

This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 3d5d0c3..109f8e3 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -525,14 +525,16 @@
 exposay_set_inactive(struct desktop_shell *shell)
 {
 	struct weston_seat *seat = shell->exposay.seat;
+	struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
+	struct weston_pointer *pointer = weston_seat_get_pointer(seat);
 
-	if (seat->pointer_device_count)
-		weston_pointer_end_grab(seat->pointer);
+	if (pointer)
+		weston_pointer_end_grab(pointer);
 
-	if (seat->keyboard_device_count) {
-		weston_keyboard_end_grab(seat->keyboard);
-		if (seat->keyboard->input_method_resource)
-			seat->keyboard->grab = &seat->keyboard->input_method_grab;
+	if (keyboard) {
+		weston_keyboard_end_grab(keyboard);
+		if (keyboard->input_method_resource)
+			keyboard->grab = &keyboard->input_method_grab;
 	}
 
 	return EXPOSAY_LAYOUT_INACTIVE;
@@ -566,28 +568,30 @@
 exposay_transition_active(struct desktop_shell *shell)
 {
 	struct weston_seat *seat = shell->exposay.seat;
+	struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+	struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
 	struct shell_output *shell_output;
 	bool animate = false;
 
 	shell->exposay.workspace = get_current_workspace(shell);
-	shell->exposay.focus_prev = get_default_view (seat->keyboard->focus);
-	shell->exposay.focus_current = get_default_view (seat->keyboard->focus);
+	shell->exposay.focus_prev = get_default_view(keyboard->focus);
+	shell->exposay.focus_current = get_default_view(keyboard->focus);
 	shell->exposay.clicked = NULL;
 	wl_list_init(&shell->exposay.surface_list);
 
 	lower_fullscreen_layer(shell, NULL);
 	shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
-	weston_keyboard_start_grab(seat->keyboard,
+	weston_keyboard_start_grab(keyboard,
 	                           &shell->exposay.grab_kbd);
-	weston_keyboard_set_focus(seat->keyboard, NULL);
+	weston_keyboard_set_focus(keyboard, NULL);
 
 	shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
-	if (seat->pointer_device_count) {
-		weston_pointer_start_grab(seat->pointer,
+	if (pointer) {
+		weston_pointer_start_grab(pointer,
 		                          &shell->exposay.grab_ptr);
-		weston_pointer_set_focus(seat->pointer, NULL,
-				         seat->pointer->x,
-					 seat->pointer->y);
+		weston_pointer_set_focus(pointer, NULL,
+				         pointer->x,
+					 pointer->y);
 	}
 	wl_list_for_each(shell_output, &shell->output_list, link) {
 		enum exposay_layout_state state;