[PATCH weston 5/5] compositor: split drag surface update into smaller functions

Kristian Hoegsberg hoegsberg at gmail.com
Thu Mar 1 14:38:02 PST 2012


On Thu, Mar 01, 2012 at 02:09:45PM +0200, Ander Conselvan de Oliveira wrote:

Thanks, applied.
Kristian

> ---
>  src/compositor.c |   58 +++++++++++++++++++++++++++++++++++++++--------------
>  1 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 4b607d0..1281066 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1915,6 +1915,42 @@ weston_input_device_release(struct weston_input_device *device)
>  	wl_input_device_release(&device->input_device);
>  }
>  
> +static void
> +device_setup_new_drag_surface(struct weston_input_device *device,
> +			      struct weston_surface *surface)
> +{
> +	struct wl_input_device *input_device = &device->input_device;
> +
> +	device->drag_surface = surface;
> +
> +	weston_surface_set_position(device->drag_surface,
> +				    input_device->x, input_device->y);
> +
> +	wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
> +		       &device->drag_surface_destroy_listener.link);
> +}
> +
> +static void
> +device_release_drag_surface(struct weston_input_device *device)
> +{
> +	undef_region(&device->drag_surface->input);
> +	wl_list_remove(&device->drag_surface_destroy_listener.link);
> +	device->drag_surface = NULL;
> +}
> +
> +static void
> +device_map_drag_surface(struct weston_input_device *device)
> +{
> +	if (device->drag_surface->output ||
> +	    !device->drag_surface->buffer)
> +		return;
> +
> +	wl_list_insert(weston_compositor_top(device->compositor),
> +		       &device->drag_surface->link);
> +	weston_surface_assign_output(device->drag_surface);
> +	empty_region(&device->drag_surface->input);
> +}
> +
>  static  void
>  weston_input_update_drag_surface(struct wl_input_device *input_device,
>  				 int dx, int dy)
> @@ -1933,30 +1969,20 @@ weston_input_update_drag_surface(struct wl_input_device *input_device,
>  		surface_changed = 1;
>  
>  	if (!input_device->drag_surface || surface_changed) {
> -		undef_region(&device->drag_surface->input);
> -		wl_list_remove(&device->drag_surface_destroy_listener.link);
> -		device->drag_surface = NULL;
> +		device_release_drag_surface(device);
>  		if (!surface_changed)
>  			return;
>  	}
>  
>  	if (!device->drag_surface || surface_changed) {
> -		device->drag_surface = (struct weston_surface *)
> +		struct weston_surface *surface = (struct weston_surface *)
>  			input_device->drag_surface;
> -
> -		weston_surface_set_position(device->drag_surface,
> -					    input_device->x, input_device->y);
> -		wl_list_insert(device->drag_surface->surface.resource.destroy_listener_list.prev,
> -			       &device->drag_surface_destroy_listener.link);
> +		device_setup_new_drag_surface(device, surface);
>  	}
>  
> -	if (device->drag_surface->output == NULL &&
> -	    device->drag_surface->buffer) {
> -		wl_list_insert(weston_compositor_top(device->compositor),
> -			       &device->drag_surface->link);
> -		weston_surface_assign_output(device->drag_surface);
> -		empty_region(&device->drag_surface->input);
> -	}
> +	/* the client may not have attached a buffer to the drag surface
> +	 * when we setup it up, so check if map is needed on every update */
> +	device_map_drag_surface(device);
>  
>  	/* the client may have attached a buffer with a different size to
>  	 * the drag surface, causing the input region to be reset */
> -- 
> 1.7.4.1
> 
> _______________________________________________
> 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