bindings: Make run binding functions take apropriate device instead of a seat
Going from seat to input device requires that we test the device before relying on the pointer. In all of these binding functions we can trust exactly one input device type directly. If we pass that in instead of a seat it's more obvious that we can trust the one pointer we have. When a seat is required, we can access through the device we have and use that to get to other device types for the seat, provided we validate them appropriately. Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
parent
b591a30ac2
commit
99a6a2db4c
@ -280,12 +280,13 @@ install_binding_grab(struct weston_keyboard *keyboard, uint32_t time,
|
||||
|
||||
void
|
||||
weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_keyboard *keyboard,
|
||||
uint32_t time, uint32_t key,
|
||||
enum wl_keyboard_key_state state)
|
||||
{
|
||||
struct weston_binding *b, *tmp;
|
||||
struct weston_surface *focus;
|
||||
struct weston_seat *seat = keyboard->seat;
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||
return;
|
||||
@ -297,15 +298,15 @@ weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||
wl_list_for_each_safe(b, tmp, &compositor->key_binding_list, link) {
|
||||
if (b->key == key && b->modifier == seat->modifier_state) {
|
||||
weston_key_binding_handler_t handler = b->handler;
|
||||
focus = seat->keyboard->focus;
|
||||
handler(seat->keyboard, time, key, b->data);
|
||||
focus = keyboard->focus;
|
||||
handler(keyboard, time, key, b->data);
|
||||
|
||||
/* If this was a key binding and it didn't
|
||||
* install a keyboard grab, install one now to
|
||||
* swallow the key press. */
|
||||
if (seat->keyboard->grab ==
|
||||
&seat->keyboard->default_grab)
|
||||
install_binding_grab(seat->keyboard,
|
||||
if (keyboard->grab ==
|
||||
&keyboard->default_grab)
|
||||
install_binding_grab(keyboard,
|
||||
time,
|
||||
key,
|
||||
focus);
|
||||
@ -315,13 +316,13 @@ weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||
|
||||
void
|
||||
weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_keyboard *keyboard,
|
||||
enum weston_keyboard_modifier modifier,
|
||||
enum wl_keyboard_key_state state)
|
||||
{
|
||||
struct weston_binding *b, *tmp;
|
||||
|
||||
if (seat->keyboard->grab != &seat->keyboard->default_grab)
|
||||
if (keyboard->grab != &keyboard->default_grab)
|
||||
return;
|
||||
|
||||
wl_list_for_each_safe(b, tmp, &compositor->modifier_binding_list, link) {
|
||||
@ -340,13 +341,13 @@ weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
|
||||
return;
|
||||
}
|
||||
|
||||
handler(seat->keyboard, modifier, b->data);
|
||||
handler(keyboard, modifier, b->data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_pointer *pointer,
|
||||
uint32_t time, uint32_t button,
|
||||
enum wl_pointer_button_state state)
|
||||
{
|
||||
@ -360,34 +361,35 @@ weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||||
b->key = button;
|
||||
|
||||
wl_list_for_each_safe(b, tmp, &compositor->button_binding_list, link) {
|
||||
if (b->button == button && b->modifier == seat->modifier_state) {
|
||||
if (b->button == button &&
|
||||
b->modifier == pointer->seat->modifier_state) {
|
||||
weston_button_binding_handler_t handler = b->handler;
|
||||
handler(seat->pointer, time, button, b->data);
|
||||
handler(pointer, time, button, b->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
weston_compositor_run_touch_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat, uint32_t time,
|
||||
struct weston_touch *touch, uint32_t time,
|
||||
int touch_type)
|
||||
{
|
||||
struct weston_binding *b, *tmp;
|
||||
|
||||
if (seat->touch->num_tp != 1 || touch_type != WL_TOUCH_DOWN)
|
||||
if (touch->num_tp != 1 || touch_type != WL_TOUCH_DOWN)
|
||||
return;
|
||||
|
||||
wl_list_for_each_safe(b, tmp, &compositor->touch_binding_list, link) {
|
||||
if (b->modifier == seat->modifier_state) {
|
||||
if (b->modifier == touch->seat->modifier_state) {
|
||||
weston_touch_binding_handler_t handler = b->handler;
|
||||
handler(seat->touch, time, b->data);
|
||||
handler(touch, time, b->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_pointer *pointer,
|
||||
uint32_t time, uint32_t axis,
|
||||
wl_fixed_t value)
|
||||
{
|
||||
@ -398,9 +400,10 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||
b->key = axis;
|
||||
|
||||
wl_list_for_each_safe(b, tmp, &compositor->axis_binding_list, link) {
|
||||
if (b->axis == axis && b->modifier == seat->modifier_state) {
|
||||
if (b->axis == axis &&
|
||||
b->modifier == pointer->seat->modifier_state) {
|
||||
weston_axis_binding_handler_t handler = b->handler;
|
||||
handler(seat->pointer, time, axis, value, b->data);
|
||||
handler(pointer, time, axis, value, b->data);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -410,7 +413,7 @@ weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||
|
||||
int
|
||||
weston_compositor_run_debug_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_keyboard *keyboard,
|
||||
uint32_t time, uint32_t key,
|
||||
enum wl_keyboard_key_state state)
|
||||
{
|
||||
@ -424,7 +427,7 @@ weston_compositor_run_debug_binding(struct weston_compositor *compositor,
|
||||
|
||||
count++;
|
||||
handler = binding->handler;
|
||||
handler(seat->keyboard, time, key, binding->data);
|
||||
handler(keyboard, time, key, binding->data);
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -480,8 +483,8 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
|
||||
}
|
||||
|
||||
if (check_binding) {
|
||||
if (weston_compositor_run_debug_binding(ec, db->seat, time,
|
||||
key, state)) {
|
||||
if (weston_compositor_run_debug_binding(ec, grab->keyboard,
|
||||
time, key, state)) {
|
||||
/* We ran a binding so swallow the press and keep the
|
||||
* grab to swallow the released too. */
|
||||
send = 0;
|
||||
|
@ -1213,31 +1213,32 @@ weston_binding_list_destroy_all(struct wl_list *list);
|
||||
|
||||
void
|
||||
weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat, uint32_t time,
|
||||
struct weston_keyboard *keyboard,
|
||||
uint32_t time,
|
||||
uint32_t key,
|
||||
enum wl_keyboard_key_state state);
|
||||
|
||||
void
|
||||
weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat,
|
||||
struct weston_keyboard *keyboard,
|
||||
enum weston_keyboard_modifier modifier,
|
||||
enum wl_keyboard_key_state state);
|
||||
void
|
||||
weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat, uint32_t time,
|
||||
struct weston_pointer *pointer, 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,
|
||||
struct weston_touch *touch, uint32_t time,
|
||||
int touch_type);
|
||||
int
|
||||
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat, uint32_t time,
|
||||
struct weston_pointer *pointer, uint32_t time,
|
||||
uint32_t axis, int32_t value);
|
||||
int
|
||||
weston_compositor_run_debug_binding(struct weston_compositor *compositor,
|
||||
struct weston_seat *seat, uint32_t time,
|
||||
struct weston_keyboard *keyboard, uint32_t time,
|
||||
uint32_t key,
|
||||
enum wl_keyboard_key_state state);
|
||||
|
||||
|
16
src/input.c
16
src/input.c
@ -973,7 +973,7 @@ run_modifier_bindings(struct weston_seat *seat, uint32_t old, uint32_t new)
|
||||
for (i = 0; i < ARRAY_LENGTH(mods); i++) {
|
||||
if (diff & (1 << mods[i].xkb))
|
||||
weston_compositor_run_modifier_binding(compositor,
|
||||
seat,
|
||||
keyboard,
|
||||
mods[i].weston,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
}
|
||||
@ -982,7 +982,7 @@ run_modifier_bindings(struct weston_seat *seat, uint32_t old, uint32_t new)
|
||||
for (i = 0; i < ARRAY_LENGTH(mods); i++) {
|
||||
if (diff & (1 << mods[i].xkb))
|
||||
weston_compositor_run_modifier_binding(compositor,
|
||||
seat,
|
||||
keyboard,
|
||||
mods[i].weston,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
}
|
||||
@ -1034,7 +1034,7 @@ notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
|
||||
pointer->button_count--;
|
||||
}
|
||||
|
||||
weston_compositor_run_button_binding(compositor, seat, time, button,
|
||||
weston_compositor_run_button_binding(compositor, pointer, time, button,
|
||||
state);
|
||||
|
||||
pointer->grab->interface->button(pointer->grab, time, button, state);
|
||||
@ -1058,8 +1058,8 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
if (weston_compositor_run_axis_binding(compositor, seat,
|
||||
time, axis, value))
|
||||
if (weston_compositor_run_axis_binding(compositor, pointer,
|
||||
time, axis, value))
|
||||
return;
|
||||
|
||||
resource_list = &pointer->focus_resource_list;
|
||||
@ -1346,8 +1346,8 @@ notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
|
||||
|
||||
if (grab == &keyboard->default_grab ||
|
||||
grab == &keyboard->input_method_grab) {
|
||||
weston_compositor_run_key_binding(compositor, seat, time, key,
|
||||
state);
|
||||
weston_compositor_run_key_binding(compositor, keyboard, time,
|
||||
key, state);
|
||||
grab = keyboard->grab;
|
||||
}
|
||||
|
||||
@ -1542,7 +1542,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
|
||||
return;
|
||||
}
|
||||
|
||||
weston_compositor_run_touch_binding(ec, seat,
|
||||
weston_compositor_run_touch_binding(ec, touch,
|
||||
time, touch_type);
|
||||
|
||||
grab->interface->down(grab, time, touch_id, sx, sy);
|
||||
|
Loading…
x
Reference in New Issue
Block a user