Add a touch binding to activate a surface
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.
This commit is contained in:
parent
2cd6da1400
commit
a28c69358c
|
@ -93,6 +93,24 @@ weston_compositor_add_button_binding(struct weston_compositor *compositor,
|
|||
return binding;
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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,
|
||||
|
|
|
@ -3012,6 +3012,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);
|
||||
|
||||
|
@ -3072,6 +3073,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);
|
||||
|
||||
|
|
|
@ -574,6 +574,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;
|
||||
|
||||
|
@ -983,6 +984,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);
|
||||
|
@ -1013,6 +1023,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,
|
||||
|
|
|
@ -1144,6 +1144,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
|
||||
|
|
36
src/shell.c
36
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);
|
||||
|
|
Loading…
Reference in New Issue