On Thu, Oct 03, 2013 at 04:43:04PM +0100, Neil Roberts wrote:
> Adds a new binding type for touch events via the new function
> weston_compositor_add_touch_binding. The binding can only be added for
> a touch down with the first finger. The shell now uses this to install
> a binding to activate the current surface.
> ---
>  src/bindings.c   | 36 ++++++++++++++++++++++++++++++++++++
>  src/compositor.c |  2 ++
>  src/compositor.h | 14 ++++++++++++++
>  src/input.c      |  2 ++
>  src/shell.c      | 36 ++++++++++++++++++++++++++++--------
>  5 files changed, 82 insertions(+), 8 deletions(-)

These four patches look good, all applied.

Kristian

> diff --git a/src/bindings.c b/src/bindings.c
> index f6ec9ea..03c9238 100644
> --- a/src/bindings.c
> +++ b/src/bindings.c
> @@ -94,6 +94,24 @@ weston_compositor_add_button_binding(struct 
> weston_compositor *compositor,
>  }
>  
>  WL_EXPORT struct weston_binding *
> +weston_compositor_add_touch_binding(struct weston_compositor *compositor,
> +                                 uint32_t modifier,
> +                                 weston_touch_binding_handler_t handler,
> +                                 void *data)
> +{
> +     struct weston_binding *binding;
> +
> +     binding = weston_compositor_add_binding(compositor, 0, 0, 0,
> +                                             modifier, handler, data);
> +     if (binding == NULL)
> +             return NULL;
> +
> +     wl_list_insert(compositor->touch_binding_list.prev, &binding->link);
> +
> +     return binding;
> +}
> +
> +WL_EXPORT struct weston_binding *
>  weston_compositor_add_axis_binding(struct weston_compositor *compositor,
>                                  uint32_t axis, uint32_t modifier,
>                                  weston_axis_binding_handler_t handler,
> @@ -253,6 +271,24 @@ weston_compositor_run_button_binding(struct 
> weston_compositor *compositor,
>       }
>  }
>  
> +WL_EXPORT void
> +weston_compositor_run_touch_binding(struct weston_compositor *compositor,
> +                                 struct weston_seat *seat, uint32_t time,
> +                                 int touch_type)
> +{
> +     struct weston_binding *b;
> +
> +     if (seat->num_tp != 1 || touch_type != WL_TOUCH_DOWN)
> +             return;
> +
> +     wl_list_for_each(b, &compositor->touch_binding_list, link) {
> +             if (b->modifier == seat->modifier_state) {
> +                     weston_touch_binding_handler_t handler = b->handler;
> +                     handler(seat, time, b->data);
> +             }
> +     }
> +}
> +
>  WL_EXPORT int
>  weston_compositor_run_axis_binding(struct weston_compositor *compositor,
>                                  struct weston_seat *seat,
> diff --git a/src/compositor.c b/src/compositor.c
> index b8e442a..935015a 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -3112,6 +3112,7 @@ weston_compositor_init(struct weston_compositor *ec,
>       wl_list_init(&ec->output_list);
>       wl_list_init(&ec->key_binding_list);
>       wl_list_init(&ec->button_binding_list);
> +     wl_list_init(&ec->touch_binding_list);
>       wl_list_init(&ec->axis_binding_list);
>       wl_list_init(&ec->debug_binding_list);
>  
> @@ -3172,6 +3173,7 @@ weston_compositor_shutdown(struct weston_compositor *ec)
>  
>       weston_binding_list_destroy_all(&ec->key_binding_list);
>       weston_binding_list_destroy_all(&ec->button_binding_list);
> +     weston_binding_list_destroy_all(&ec->touch_binding_list);
>       weston_binding_list_destroy_all(&ec->axis_binding_list);
>       weston_binding_list_destroy_all(&ec->debug_binding_list);
>  
> diff --git a/src/compositor.h b/src/compositor.h
> index 9b48287..ad5a786 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -575,6 +575,7 @@ struct weston_compositor {
>       struct wl_list plane_list;
>       struct wl_list key_binding_list;
>       struct wl_list button_binding_list;
> +     struct wl_list touch_binding_list;
>       struct wl_list axis_binding_list;
>       struct wl_list debug_binding_list;
>  
> @@ -984,6 +985,15 @@ 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,
> +                                            uint32_t time,
> +                                            void *data);
> +struct weston_binding *
> +weston_compositor_add_touch_binding(struct weston_compositor *compositor,
> +                                 enum weston_keyboard_modifier modifier,
> +                                 weston_touch_binding_handler_t binding,
> +                                 void *data);
> +
>  typedef void (*weston_axis_binding_handler_t)(struct weston_seat *seat,
>                                             uint32_t time, uint32_t axis,
>                                             wl_fixed_t value, void *data);
> @@ -1014,6 +1024,10 @@ 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
> +weston_compositor_run_touch_binding(struct weston_compositor *compositor,
> +                                 struct weston_seat *seat, uint32_t time,
> +                                 int touch_type);
>  int
>  weston_compositor_run_axis_binding(struct weston_compositor *compositor,
>                                  struct weston_seat *seat, uint32_t time,
> diff --git a/src/input.c b/src/input.c
> index 1313b52..3e4f4b1 100644
> --- a/src/input.c
> +++ b/src/input.c
> @@ -1147,6 +1147,8 @@ notify_touch(struct weston_seat *seat, uint32_t time, 
> int touch_id,
>                       weston_touch_set_focus(seat, NULL);
>               break;
>       }
> +
> +     weston_compositor_run_touch_binding(ec, seat, time, touch_type);
>  }
>  
>  static void
> diff --git a/src/shell.c b/src/shell.c
> index f033e8c..4a0c122 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -3124,15 +3124,12 @@ is_black_surface (struct weston_surface *es, struct 
> weston_surface **fs_surface)
>  }
>  
>  static void
> -click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t 
> button,
> -                       void *data)
> +activate_binding(struct weston_seat *seat,
> +              struct desktop_shell *shell,
> +              struct weston_surface *focus)
>  {
> -     struct weston_seat *ws = (struct weston_seat *) seat;
> -     struct desktop_shell *shell = data;
> -     struct weston_surface *focus;
>       struct weston_surface *main_surface;
>  
> -     focus = (struct weston_surface *) seat->pointer->focus;
>       if (!focus)
>               return;
>  
> @@ -3143,8 +3140,28 @@ click_to_activate_binding(struct weston_seat *seat, 
> uint32_t time, uint32_t butt
>       if (get_shell_surface_type(main_surface) == SHELL_SURFACE_NONE)
>               return;
>  
> -     if (seat->pointer->grab == &seat->pointer->default_grab)
> -             activate(shell, focus, ws);
> +     activate(shell, focus, seat);
> +}
> +
> +static void
> +click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t 
> button,
> +                       void *data)
> +{
> +     if (seat->pointer->grab != &seat->pointer->default_grab)
> +             return;
> +
> +     activate_binding(seat, data,
> +                      (struct weston_surface *) seat->pointer->focus);
> +}
> +
> +static void
> +touch_to_activate_binding(struct weston_seat *seat, uint32_t time, void 
> *data)
> +{
> +     if (seat->touch->grab != &seat->touch->default_grab)
> +             return;
> +
> +     activate_binding(seat, data,
> +                      (struct weston_surface *) seat->touch->focus);
>  }
>  
>  static void
> @@ -4496,6 +4513,9 @@ shell_add_bindings(struct weston_compositor *ec, struct 
> desktop_shell *shell)
>       weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
>                                            click_to_activate_binding,
>                                            shell);
> +     weston_compositor_add_touch_binding(ec, 0,
> +                                         touch_to_activate_binding,
> +                                         shell);
>       weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
>                                          MODIFIER_SUPER | MODIFIER_ALT,
>                                          surface_opacity_binding, NULL);
> -- 
> 1.8.3.1
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to