[PATCH] Eat scroll event if a key binding function is executed because of it.

Kristian Høgsberg hoegsberg at gmail.com
Mon Mar 18 18:44:37 PDT 2013


On Thu, Mar 07, 2013 at 09:50:00PM +0100, Rune K. Svendsen wrote:
> From: "Rune K. Svendsen" <runesvend at gmail.com>
> 
> When an axis (scroll) event results in a key binding function
> being executed, eat the scroll event so the underlying window
> doesn't receive it.
> Thanks to Scott Moreau for helping me solve this.

Yeah, this looks fine.  In case of other bindings we rely on the binding
installing a grab which will swallow the event.  We don't have that for
axis events so let's just do this.

thanks,
Kristian

> ---
>  src/bindings.c   |    5 ++++-
>  src/compositor.c |    9 +++++----
>  src/compositor.h |    2 +-
>  3 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/src/bindings.c b/src/bindings.c
> index 6456f79..322736d 100644
> --- a/src/bindings.c
> +++ b/src/bindings.c
> @@ -250,7 +250,7 @@ weston_compositor_run_button_binding(struct weston_compositor *compositor,
>  	}
>  }
>  
> -WL_EXPORT void
> +WL_EXPORT int
>  weston_compositor_run_axis_binding(struct weston_compositor *compositor,
>  				   struct weston_seat *seat,
>  				   uint32_t time, uint32_t axis,
> @@ -262,8 +262,11 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor,
>  		if (b->axis == axis && b->modifier == seat->modifier_state) {
>  			weston_axis_binding_handler_t handler = b->handler;
>  			handler(&seat->seat, time, axis, value, b->data);
> +			return 1;
>  		}
>  	}
> +
> +	return 0;
>  }
>  
>  WL_EXPORT int
> diff --git a/src/compositor.c b/src/compositor.c
> index 248d3b4..18f4649 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1826,10 +1826,11 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
>  
>  	weston_compositor_wake(compositor);
>  
> -	if (value)
> -		weston_compositor_run_axis_binding(compositor, seat,
> -						   time, axis, value);
> -	else
> +	if (!value)
> +		return;
> +
> +	if (weston_compositor_run_axis_binding(compositor, seat,
> +						   time, axis, value))
>  		return;
>  
>  	if (pointer->focus_resource)
> diff --git a/src/compositor.h b/src/compositor.h
> index 4a0c1e3..0f1b20e 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -649,7 +649,7 @@ weston_compositor_run_button_binding(struct weston_compositor *compositor,
>  				     struct weston_seat *seat, uint32_t time,
>  				     uint32_t button,
>  				     enum wl_pointer_button_state value);
> -void
> +int
>  weston_compositor_run_axis_binding(struct weston_compositor *compositor,
>  				   struct weston_seat *seat, uint32_t time,
>  				   uint32_t axis, int32_t value);
> -- 
> 1.7.10.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