input: Pass the appropriate pointer type to bindings instead of a seat

Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer.  However, in a binding you're
guaranteed that the seat has a device of that type.  If we pass in
that type instead of the seat, it's obvious we don't have to test it.

The bindings can still get the seat pointer via whatever->seat if they
need it.

This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.

Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
diff --git a/src/bindings.c b/src/bindings.c
index ec505dc..cc726af 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -298,7 +298,7 @@
 		if (b->key == key && b->modifier == seat->modifier_state) {
 			weston_key_binding_handler_t handler = b->handler;
 			focus = seat->keyboard->focus;
-			handler(seat, time, key, b->data);
+			handler(seat->keyboard, time, key, b->data);
 
 			/* If this was a key binding and it didn't
 			 * install a keyboard grab, install one now to
@@ -337,7 +337,7 @@
 			return;
 		}
 
-		handler(seat, modifier, b->data);
+		handler(seat->keyboard, modifier, b->data);
 	}
 }
 
@@ -359,7 +359,7 @@
 	wl_list_for_each_safe(b, tmp, &compositor->button_binding_list, link) {
 		if (b->button == button && b->modifier == seat->modifier_state) {
 			weston_button_binding_handler_t handler = b->handler;
-			handler(seat, time, button, b->data);
+			handler(seat->pointer, time, button, b->data);
 		}
 	}
 }
@@ -377,7 +377,7 @@
 	wl_list_for_each_safe(b, tmp, &compositor->touch_binding_list, link) {
 		if (b->modifier == seat->modifier_state) {
 			weston_touch_binding_handler_t handler = b->handler;
-			handler(seat, time, b->data);
+			handler(seat->touch, time, b->data);
 		}
 	}
 }
@@ -397,7 +397,7 @@
 	wl_list_for_each_safe(b, tmp, &compositor->axis_binding_list, link) {
 		if (b->axis == axis && b->modifier == seat->modifier_state) {
 			weston_axis_binding_handler_t handler = b->handler;
-			handler(seat, time, axis, value, b->data);
+			handler(seat->pointer, time, axis, value, b->data);
 			return 1;
 		}
 	}
@@ -421,7 +421,7 @@
 
 		count++;
 		handler = binding->handler;
-		handler(seat, time, key, binding->data);
+		handler(seat->keyboard, time, key, binding->data);
 	}
 
 	return count;
@@ -540,7 +540,8 @@
 };
 
 static void
-debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+debug_binding(struct weston_keyboard *keyboard, uint32_t time,
+	      uint32_t key, void *data)
 {
 	struct debug_binding_grab *grab;
 
@@ -548,10 +549,10 @@
 	if (!grab)
 		return;
 
-	grab->seat = seat;
+	grab->seat = keyboard->seat;
 	grab->key[0] = key;
 	grab->grab.interface = &debug_binding_keyboard_grab;
-	weston_keyboard_start_grab(seat->keyboard, &grab->grab);
+	weston_keyboard_start_grab(keyboard, &grab->grab);
 }
 
 /** Install the trigger binding for debug bindings.
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 42195ec..b4ca916 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2764,7 +2764,8 @@
 }
 
 static void
-switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+switch_vt_binding(struct weston_keyboard *keyboard, uint32_t time,
+		  uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
 
@@ -2828,7 +2829,8 @@
 }
 
 static void
-planes_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+planes_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
+	       void *data)
 {
 	struct drm_backend *b = data;
 
@@ -2908,7 +2910,7 @@
 }
 
 static void
-recorder_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
+recorder_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
 		 void *data)
 {
 	struct drm_backend *b = data;
@@ -2993,10 +2995,11 @@
 }
 
 static void
-renderer_switch_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
-			void *data)
+renderer_switch_binding(struct weston_keyboard *keyboard, uint32_t time,
+			uint32_t key, void *data)
 {
-	struct drm_backend *b = (struct drm_backend *)seat->compositor->backend;
+	struct drm_backend *b =
+		(struct drm_backend *) keyboard->seat->compositor;
 
 	switch_to_gl_renderer(b);
 }
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 7117bc5..3110f74 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -803,7 +803,8 @@
 }
 
 static void
-switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+switch_vt_binding(struct weston_keyboard *keyboard, uint32_t time,
+		  uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
 
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 14bd76b..ac9faeb 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -448,7 +448,8 @@
 }
 
 static void
-switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+switch_vt_binding(struct weston_keyboard *keyboard, uint32_t time,
+		  uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
 
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index ddad3b1..a8e63e1 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1925,14 +1925,14 @@
 }
 
 static void
-fullscreen_binding(struct weston_seat *seat_base, uint32_t time, uint32_t key,
-		   void *data)
+fullscreen_binding(struct weston_keyboard *keyboard, uint32_t time,
+		   uint32_t key, void *data)
 {
 	struct wayland_backend *b = data;
 	struct wayland_input *input = NULL;
 
 	wl_list_for_each(input, &b->input_list, link)
-		if (&input->base == seat_base)
+		if (&input->base == keyboard->seat)
 			break;
 
 	if (!input || !input->output)
diff --git a/src/compositor.c b/src/compositor.c
index acaa433..4e88375 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4433,7 +4433,7 @@
 }
 
 static void
-timeline_key_binding_handler(struct weston_seat *seat, uint32_t time,
+timeline_key_binding_handler(struct weston_keyboard *keyboard, uint32_t time,
 			     uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
diff --git a/src/compositor.h b/src/compositor.h
index faaacc2..ee40ecc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1149,7 +1149,7 @@
 
 
 struct weston_binding;
-typedef void (*weston_key_binding_handler_t)(struct weston_seat *seat,
+typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
 					     uint32_t time, uint32_t key,
 					     void *data);
 struct weston_binding *
@@ -1159,7 +1159,7 @@
 				  weston_key_binding_handler_t binding,
 				  void *data);
 
-typedef void (*weston_modifier_binding_handler_t)(struct weston_seat *seat,
+typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
 					          enum weston_keyboard_modifier modifier,
 					          void *data);
 struct weston_binding *
@@ -1168,7 +1168,7 @@
 				       weston_modifier_binding_handler_t binding,
 				       void *data);
 
-typedef void (*weston_button_binding_handler_t)(struct weston_seat *seat,
+typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
 						uint32_t time, uint32_t button,
 						void *data);
 struct weston_binding *
@@ -1178,7 +1178,7 @@
 				     weston_button_binding_handler_t binding,
 				     void *data);
 
-typedef void (*weston_touch_binding_handler_t)(struct weston_seat *seat,
+typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
 					       uint32_t time,
 					       void *data);
 struct weston_binding *
@@ -1187,7 +1187,7 @@
 				    weston_touch_binding_handler_t binding,
 				    void *data);
 
-typedef void (*weston_axis_binding_handler_t)(struct weston_seat *seat,
+typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
 					      uint32_t time, uint32_t axis,
 					      wl_fixed_t value, void *data);
 struct weston_binding *
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 876dc56..88db26b 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -2429,8 +2429,8 @@
 }
 
 static void
-fragment_debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
-		       void *data)
+fragment_debug_binding(struct weston_keyboard *keyboard, uint32_t time,
+		       uint32_t key, void *data)
 {
 	struct weston_compositor *ec = data;
 	struct gl_renderer *gr = get_renderer(ec);
@@ -2455,8 +2455,8 @@
 }
 
 static void
-fan_debug_repaint_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
-		      void *data)
+fan_debug_repaint_binding(struct weston_keyboard *keyboard, uint32_t time,
+			  uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
 	struct gl_renderer *gr = get_renderer(compositor);
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index b19875d..e81f784 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -804,7 +804,7 @@
 }
 
 static void
-debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
+debug_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
 	      void *data)
 {
 	struct weston_compositor *ec = data;
diff --git a/src/screenshooter.c b/src/screenshooter.c
index b7b8dce..d54b47d 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -286,8 +286,8 @@
 }
 
 static void
-screenshooter_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
-		      void *data)
+screenshooter_binding(struct weston_keyboard *keyboard, uint32_t time,
+		      uint32_t key, void *data)
 {
 	struct screenshooter *shooter = data;
 	char *screenshooter_exe;
@@ -560,9 +560,10 @@
 }
 
 static void
-recorder_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data)
+recorder_binding(struct weston_keyboard *keyboard, uint32_t time,
+		 uint32_t key, void *data)
 {
-	struct weston_compositor *ec = seat->compositor;
+	struct weston_compositor *ec = keyboard->seat->compositor;
 	struct weston_output *output;
 	struct wl_listener *listener = NULL;
 	struct weston_recorder *recorder;
@@ -586,9 +587,8 @@
 		recorder->destroying = 1;
 		weston_output_schedule_repaint(recorder->output);
 	} else {
-		if (seat->keyboard && seat->keyboard->focus &&
-		    seat->keyboard->focus->output)
-			output = seat->keyboard->focus->output;
+		if (keyboard->focus && keyboard->focus->output)
+			output = keyboard->focus->output;
 		else
 			output = container_of(ec->output_list.next,
 					      struct weston_output, link);