[PATCH weston 11/19] input: Pass the appropriate pointer type to bindings instead of a seat

Jonas Ådahl jadahl at gmail.com
Wed Jul 1 01:54:03 PDT 2015


On Wed, Jun 03, 2015 at 03:53:30PM -0500, Derek Foreman wrote:
> 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.
> 
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  desktop-shell/exposay.c    |   4 +-
>  desktop-shell/shell.c      | 125 +++++++++++++++++++++++----------------------
>  desktop-shell/shell.h      |   2 +-
>  ivi-shell/ivi-shell.c      |   4 +-
>  src/bindings.c             |  19 +++----
>  src/compositor-drm.c       |  15 +++---
>  src/compositor-fbdev.c     |   3 +-
>  src/compositor-rpi.c       |   3 +-
>  src/compositor-wayland.c   |   6 +--
>  src/compositor.c           |   2 +-
>  src/compositor.h           |  10 ++--
>  src/gl-renderer.c          |   8 +--
>  src/pixman-renderer.c      |   2 +-
>  src/screenshooter.c        |  14 ++---
>  tests/surface-screenshot.c |   3 +-
>  15 files changed, 116 insertions(+), 104 deletions(-)
> 
> diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
> index 4916b39..ec65e7d 100644
> --- a/desktop-shell/exposay.c
> +++ b/desktop-shell/exposay.c
> @@ -652,10 +652,10 @@ exposay_set_state(struct desktop_shell *shell, enum exposay_target_state state,
>  }
>  

<snip>

>  
>  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_compositor *c = (struct drm_compositor *) seat->compositor;
> +	struct drm_compositor *c =
> +		(struct drm_compositor *)keyboard->seat->compositor;

nit: Same comment as a previous patch regarding style.

Disregarding that... Reviewed-by: Jonas Ådahl <jadahl at gmail.com>

>  
>  	switch_to_gl_renderer(c);
>  }
> diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
> index 3f3394f..582ce47 100644
> --- a/src/compositor-fbdev.c
> +++ b/src/compositor-fbdev.c
> @@ -797,7 +797,8 @@ fbdev_restore(struct weston_compositor *compositor)
>  }
>  
>  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 1c0a783..a7d763b 100644
> --- a/src/compositor-rpi.c
> +++ b/src/compositor-rpi.c
> @@ -442,7 +442,8 @@ rpi_restore(struct weston_compositor *compositor)
>  }
>  
>  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 935701a..15f58b7 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -1920,14 +1920,14 @@ create_cursor(struct wayland_compositor *c, struct weston_config *config)
>  }
>  
>  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_compositor *c = data;
>  	struct wayland_input *input = NULL;
>  
>  	wl_list_for_each(input, &c->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 8f02b4d..041c03f 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4485,7 +4485,7 @@ weston_environment_get_fd(const char *env)
>  }
>  
>  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 867f8c4..4d9e1a0 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -1150,7 +1150,7 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
>  
>  
>  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 *
> @@ -1160,7 +1160,7 @@ weston_compositor_add_key_binding(struct weston_compositor *compositor,
>  				  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 *
> @@ -1169,7 +1169,7 @@ weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
>  				       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 *
> @@ -1179,7 +1179,7 @@ weston_compositor_add_button_binding(struct weston_compositor *compositor,
>  				     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 *
> @@ -1188,7 +1188,7 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
>  				    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 d18e124..d28f0fc 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -2425,8 +2425,8 @@ compile_shaders(struct weston_compositor *ec)
>  }
>  
>  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);
> @@ -2451,8 +2451,8 @@ fragment_debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
>  }
>  
>  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 c650d55..74a9416 100644
> --- a/src/pixman-renderer.c
> +++ b/src/pixman-renderer.c
> @@ -800,7 +800,7 @@ pixman_renderer_surface_copy_content(struct weston_surface *surface,
>  }
>  
>  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 fc648a1..fd9571f 100644
> --- a/src/screenshooter.c
> +++ b/src/screenshooter.c
> @@ -282,8 +282,8 @@ screenshooter_sigchld(struct weston_process *process, int status)
>  }
>  
>  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;
> @@ -556,9 +556,10 @@ weston_recorder_destroy(struct weston_recorder *recorder)
>  }
>  
>  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;
> @@ -582,9 +583,8 @@ recorder_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *da
>  		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);
> diff --git a/tests/surface-screenshot.c b/tests/surface-screenshot.c
> index 57ec925..8badcf2 100644
> --- a/tests/surface-screenshot.c
> +++ b/tests/surface-screenshot.c
> @@ -128,13 +128,14 @@ unpremultiply_and_swap_a8b8g8r8_to_PAMrgba(void *pixels, size_t size)
>  }
>  
>  static void
> -trigger_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
> +trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
>  		void *data)
>  {
>  	const char *prefix = "surfaceshot-";
>  	const char *suffix = ".pam";
>  	char fname[1024];
>  	struct weston_surface *surface;
> +	struct weston_seat *seat = keyboard->seat;
>  	int width, height;
>  	char desc[512];
>  	void *pixels;
> -- 
> 2.1.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list