input: let the pointer motion handlers move the pointer
this allows to implement pointer barriers by using a custom handler
This commit is contained in:
parent
412b024be8
commit
1959ab8d22
@ -233,7 +233,8 @@ struct weston_output {
|
||||
struct weston_pointer_grab;
|
||||
struct weston_pointer_grab_interface {
|
||||
void (*focus)(struct weston_pointer_grab *grab);
|
||||
void (*motion)(struct weston_pointer_grab *grab, uint32_t time);
|
||||
void (*motion)(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
void (*button)(struct weston_pointer_grab *grab,
|
||||
uint32_t time, uint32_t button, uint32_t state);
|
||||
void (*cancel)(struct weston_pointer_grab *grab);
|
||||
@ -359,6 +360,9 @@ weston_pointer_end_grab(struct weston_pointer *pointer);
|
||||
void
|
||||
weston_pointer_clamp(struct weston_pointer *pointer,
|
||||
wl_fixed_t *fx, wl_fixed_t *fy);
|
||||
void
|
||||
weston_pointer_move(struct weston_pointer *pointer,
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
|
||||
struct weston_keyboard *
|
||||
weston_keyboard_create(void);
|
||||
|
@ -278,7 +278,8 @@ drag_grab_focus(struct weston_pointer_grab *grab)
|
||||
}
|
||||
|
||||
static void
|
||||
drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_drag *drag =
|
||||
container_of(grab, struct weston_drag, grab);
|
||||
@ -286,6 +287,8 @@ drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
float fx, fy;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
|
||||
if (drag->icon) {
|
||||
fx = wl_fixed_to_double(pointer->x) + drag->dx;
|
||||
fy = wl_fixed_to_double(pointer->y) + drag->dy;
|
||||
|
25
src/input.c
25
src/input.c
@ -111,13 +111,16 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
|
||||
}
|
||||
|
||||
static void
|
||||
default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_pointer *pointer = grab->pointer;
|
||||
wl_fixed_t sx, sy;
|
||||
struct wl_list *resource_list;
|
||||
struct wl_resource *resource;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
|
||||
resource_list = &pointer->focus_resource_list;
|
||||
wl_resource_for_each(resource, resource_list) {
|
||||
weston_view_from_global_fixed(pointer->focus,
|
||||
@ -709,10 +712,9 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
|
||||
}
|
||||
|
||||
/* Takes absolute values */
|
||||
static void
|
||||
move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
||||
WL_EXPORT void
|
||||
weston_pointer_move(struct weston_pointer *pointer, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
int32_t ix, iy;
|
||||
|
||||
weston_pointer_clamp (pointer, &x, &y);
|
||||
@ -730,6 +732,7 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
||||
weston_view_schedule_repaint(pointer->sprite);
|
||||
}
|
||||
|
||||
pointer->grab->interface->focus(pointer->grab);
|
||||
wl_signal_emit(&pointer->motion_signal, pointer);
|
||||
}
|
||||
|
||||
@ -741,11 +744,7 @@ notify_motion(struct weston_seat *seat,
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
|
||||
weston_compositor_wake(ec);
|
||||
|
||||
move_pointer(seat, pointer->x + dx, pointer->y + dy);
|
||||
|
||||
pointer->grab->interface->focus(pointer->grab);
|
||||
pointer->grab->interface->motion(pointer->grab, time);
|
||||
pointer->grab->interface->motion(pointer->grab, time, pointer->x + dx, pointer->y + dy);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
@ -756,11 +755,7 @@ notify_motion_absolute(struct weston_seat *seat,
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
|
||||
weston_compositor_wake(ec);
|
||||
|
||||
move_pointer(seat, x, y);
|
||||
|
||||
pointer->grab->interface->focus(pointer->grab);
|
||||
pointer->grab->interface->motion(pointer->grab, time);
|
||||
pointer->grab->interface->motion(pointer->grab, time, x, y);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
@ -1095,7 +1090,7 @@ notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
if (output) {
|
||||
move_pointer(seat, x, y);
|
||||
weston_pointer_move(seat->pointer, x, y);
|
||||
} else {
|
||||
/* FIXME: We should call weston_pointer_set_focus(seat,
|
||||
* NULL) here, but somehow that breaks re-entry... */
|
||||
|
29
src/shell.c
29
src/shell.c
@ -1217,13 +1217,17 @@ noop_grab_focus(struct weston_pointer_grab *grab)
|
||||
}
|
||||
|
||||
static void
|
||||
move_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
move_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_move_grab *move = (struct weston_move_grab *) grab;
|
||||
struct weston_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = move->base.shsurf;
|
||||
int dx = wl_fixed_to_int(pointer->x + move->dx);
|
||||
int dy = wl_fixed_to_int(pointer->y + move->dy);
|
||||
int dx, dy;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
dx = wl_fixed_to_int(pointer->x + move->dx);
|
||||
dy = wl_fixed_to_int(pointer->y + move->dy);
|
||||
|
||||
if (!shsurf)
|
||||
return;
|
||||
@ -1327,7 +1331,8 @@ struct weston_resize_grab {
|
||||
};
|
||||
|
||||
static void
|
||||
resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
||||
struct weston_pointer *pointer = grab->pointer;
|
||||
@ -1336,6 +1341,8 @@ resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
wl_fixed_t from_x, from_y;
|
||||
wl_fixed_t to_x, to_y;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
|
||||
if (!shsurf)
|
||||
return;
|
||||
|
||||
@ -1513,8 +1520,10 @@ busy_cursor_grab_focus(struct weston_pointer_grab *base)
|
||||
}
|
||||
|
||||
static void
|
||||
busy_cursor_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
busy_cursor_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
weston_pointer_move(grab->pointer, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2270,12 +2279,15 @@ popup_grab_focus(struct weston_pointer_grab *grab)
|
||||
}
|
||||
|
||||
static void
|
||||
popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_pointer *pointer = grab->pointer;
|
||||
struct wl_resource *resource;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
|
||||
wl_resource_for_each(resource, &pointer->focus_resource_list) {
|
||||
weston_view_from_global_fixed(pointer->focus,
|
||||
pointer->x, pointer->y,
|
||||
@ -3086,7 +3098,8 @@ terminate_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct rotate_grab *rotate =
|
||||
container_of(grab, struct rotate_grab, base.grab);
|
||||
@ -3094,6 +3107,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
|
||||
struct shell_surface *shsurf = rotate->base.shsurf;
|
||||
float cx, cy, dx, dy, cposx, cposy, dposx, dposy, r;
|
||||
|
||||
weston_pointer_move(pointer, x, y);
|
||||
|
||||
if (!shsurf)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user