[PATCH v3] compositor: send a pointer motion if the focus surface moves under the pointer

Kristian Høgsberg hoegsberg at gmail.com
Wed Feb 27 13:01:18 PST 2013


On Thu, Feb 21, 2013 at 04:36:20PM +0100, Giulio Camuffo wrote:
> ---
>  src/compositor.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 64d0830..025c6fd 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -776,6 +776,7 @@ weston_device_repick(struct weston_seat *seat)
>  	const struct wl_pointer_grab_interface *interface;
>  	struct weston_surface *surface, *focus;
>  	struct wl_pointer *pointer = seat->seat.pointer;
> +	int32_t curr_x, curr_y;
>  
>  	if (!pointer)
>  		return;
> @@ -783,16 +784,26 @@ weston_device_repick(struct weston_seat *seat)
>  	surface = weston_compositor_pick_surface(seat->compositor,
>  						 pointer->x,
>  						 pointer->y,
> -						 &pointer->current_x,
> -						 &pointer->current_y);
> +						 &curr_x,
> +						 &curr_y);
>  
>  	if (&surface->surface != pointer->current) {
>  		interface = pointer->grab->interface;
>  		pointer->current = &surface->surface;
>  		interface->focus(pointer->grab, &surface->surface,
> -				 pointer->current_x,
> -				 pointer->current_y);
> +				 curr_x,
> +				 curr_y);
> +	} else if (pointer->current_x != curr_x ||
> +			pointer->current_y != curr_y) {
> +		/* The current surface moved under the cursor, send
> +		 * a motion event. */
> +		interface = pointer->grab->interface;
> +		interface->motion(pointer->grab, weston_compositor_get_time(),
> +				  curr_x,
> +				  curr_y);

Using weston_compositor_get_time() here is problematic (we need to get
rid of that function, it's always problematic...).  Input events come
with their own timestamp, which are CLOCK_MONOTONIC, while
weston_compositor_get_time() is based on gettimeofday().  Motion
events and button clicks corresponds to somebody actually moving the
pointer and we have evdev events with kernel timestamps for those.
The timestamps are there to allow application reason about the timing
of "real world events" like time of a double click or pointer speed.

Whenever we have to "make up a timestamp" there's something wrong.
The reason enter and leave don't have timestamps is that they can
happen in response to windows getting mapped or unmapped, which can
happen whenever a clients decides to unmap its window.  So there's no
inherent timestamp and not always corresponding pointer motion
involved (and if there is, a motion event with timestamp will follow).  

I wonder if we're better off sending a leave/enter pair here, since
that doesn't need a timestamp and doesn't imply that the pointer
moved.

Kristian

>  	}
> +	pointer->current_x = curr_x;
> +	pointer->current_y = curr_y;
>  
>  	focus = (struct weston_surface *) pointer->grab->focus;
>  	if (focus)
> -- 
> 1.8.1.3
> 
> _______________________________________________
> 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