compositor: Change notify_motion to take relative motion events
This commit is contained in:
@@ -361,8 +361,10 @@ input_handle_motion(void *data, struct wl_pointer *pointer,
|
|||||||
check_focus(input, x, y);
|
check_focus(input, x, y);
|
||||||
if (input->focus)
|
if (input->focus)
|
||||||
notify_motion(&input->base, time,
|
notify_motion(&input->base, time,
|
||||||
x - wl_fixed_from_int(c->border.left),
|
x - wl_fixed_from_int(c->border.left) -
|
||||||
y - wl_fixed_from_int(c->border.top));
|
input->base.seat.pointer->x,
|
||||||
|
y - wl_fixed_from_int(c->border.top) -
|
||||||
|
input->base.seat.pointer->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ struct x11_compositor {
|
|||||||
|
|
||||||
/* We could map multi-pointer X to multiple wayland seats, but
|
/* We could map multi-pointer X to multiple wayland seats, but
|
||||||
* for now we only support core X input. */
|
* for now we only support core X input. */
|
||||||
struct weston_seat core_seat;
|
struct weston_seat core_seat;
|
||||||
|
int prev_x;
|
||||||
|
int prev_y;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
xcb_atom_t wm_protocols;
|
xcb_atom_t wm_protocols;
|
||||||
@@ -1008,8 +1010,10 @@ x11_compositor_deliver_motion_event(struct x11_compositor *c,
|
|||||||
if (!c->has_xkb)
|
if (!c->has_xkb)
|
||||||
update_xkb_state_from_core(c, motion_notify->state);
|
update_xkb_state_from_core(c, motion_notify->state);
|
||||||
output = x11_compositor_find_output(c, motion_notify->event);
|
output = x11_compositor_find_output(c, motion_notify->event);
|
||||||
x = wl_fixed_from_int(motion_notify->event_x);
|
x = wl_fixed_from_int(motion_notify->event_x - c->prev_x);
|
||||||
y = wl_fixed_from_int(motion_notify->event_y);
|
y = wl_fixed_from_int(motion_notify->event_y - c->prev_y);
|
||||||
|
c->prev_x = motion_notify->event_x;
|
||||||
|
c->prev_y = motion_notify->event_y;
|
||||||
x11_output_transform_coordinate(output, &x, &y);
|
x11_output_transform_coordinate(output, &x, &y);
|
||||||
|
|
||||||
notify_motion(&c->core_seat, weston_compositor_get_time(), x, y);
|
notify_motion(&c->core_seat, weston_compositor_get_time(), x, y);
|
||||||
@@ -1029,6 +1033,8 @@ x11_compositor_deliver_enter_event(struct x11_compositor *c,
|
|||||||
if (!c->has_xkb)
|
if (!c->has_xkb)
|
||||||
update_xkb_state_from_core(c, enter_notify->state);
|
update_xkb_state_from_core(c, enter_notify->state);
|
||||||
output = x11_compositor_find_output(c, enter_notify->event);
|
output = x11_compositor_find_output(c, enter_notify->event);
|
||||||
|
c->prev_x = enter_notify->event_x;
|
||||||
|
c->prev_y = enter_notify->event_y;
|
||||||
x = wl_fixed_from_int(enter_notify->event_x);
|
x = wl_fixed_from_int(enter_notify->event_x);
|
||||||
y = wl_fixed_from_int(enter_notify->event_y);
|
y = wl_fixed_from_int(enter_notify->event_y);
|
||||||
x11_output_transform_coordinate(output, &x, &y);
|
x11_output_transform_coordinate(output, &x, &y);
|
||||||
|
|||||||
+6
-3
@@ -1713,13 +1713,16 @@ clip_pointer_motion(struct weston_seat *seat, wl_fixed_t *fx, wl_fixed_t *fy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
move_pointer(struct weston_seat *seat, wl_fixed_t dx, wl_fixed_t dy)
|
||||||
{
|
{
|
||||||
struct weston_compositor *ec = seat->compositor;
|
struct weston_compositor *ec = seat->compositor;
|
||||||
struct wl_pointer *pointer = seat->seat.pointer;
|
struct wl_pointer *pointer = seat->seat.pointer;
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
|
wl_fixed_t x, y;
|
||||||
int32_t ix, iy;
|
int32_t ix, iy;
|
||||||
|
|
||||||
|
x = pointer->x + dx;
|
||||||
|
y = pointer->y + dy;
|
||||||
clip_pointer_motion(seat, &x, &y);
|
clip_pointer_motion(seat, &x, &y);
|
||||||
|
|
||||||
weston_seat_update_drag_surface(seat, x - pointer->x, y - pointer->y);
|
weston_seat_update_drag_surface(seat, x - pointer->x, y - pointer->y);
|
||||||
@@ -1748,7 +1751,7 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
|||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
notify_motion(struct weston_seat *seat,
|
notify_motion(struct weston_seat *seat,
|
||||||
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
|
||||||
{
|
{
|
||||||
const struct wl_pointer_grab_interface *interface;
|
const struct wl_pointer_grab_interface *interface;
|
||||||
struct weston_compositor *ec = seat->compositor;
|
struct weston_compositor *ec = seat->compositor;
|
||||||
@@ -1756,7 +1759,7 @@ notify_motion(struct weston_seat *seat,
|
|||||||
|
|
||||||
weston_compositor_wake(ec);
|
weston_compositor_wake(ec);
|
||||||
|
|
||||||
move_pointer(seat, x, y);
|
move_pointer(seat, dx, dy);
|
||||||
|
|
||||||
interface = pointer->grab->interface;
|
interface = pointer->grab->interface;
|
||||||
interface->motion(pointer->grab, time,
|
interface->motion(pointer->grab, time,
|
||||||
|
|||||||
+1
-3
@@ -254,9 +254,7 @@ evdev_flush_motion(struct evdev_device *device, uint32_t time)
|
|||||||
|
|
||||||
device->pending_events &= ~EVDEV_SYN;
|
device->pending_events &= ~EVDEV_SYN;
|
||||||
if (device->pending_events & EVDEV_RELATIVE_MOTION) {
|
if (device->pending_events & EVDEV_RELATIVE_MOTION) {
|
||||||
notify_motion(master, time,
|
notify_motion(master, time, device->rel.dx, device->rel.dy);
|
||||||
master->seat.pointer->x + device->rel.dx,
|
|
||||||
master->seat.pointer->y + device->rel.dy);
|
|
||||||
device->pending_events &= ~EVDEV_RELATIVE_MOTION;
|
device->pending_events &= ~EVDEV_RELATIVE_MOTION;
|
||||||
device->rel.dx = 0;
|
device->rel.dx = 0;
|
||||||
device->rel.dy = 0;
|
device->rel.dy = 0;
|
||||||
|
|||||||
+4
-1
@@ -122,10 +122,13 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
|
|||||||
{
|
{
|
||||||
struct weston_test *test = resource->data;
|
struct weston_test *test = resource->data;
|
||||||
struct weston_seat *seat = get_seat(test);
|
struct weston_seat *seat = get_seat(test);
|
||||||
|
struct wl_pointer *pointer = seat->seat.pointer;
|
||||||
|
|
||||||
test->compositor->focus = 1;
|
test->compositor->focus = 1;
|
||||||
|
|
||||||
notify_motion(seat, 100, wl_fixed_from_int(x), wl_fixed_from_int(y));
|
notify_motion(seat, 100,
|
||||||
|
wl_fixed_from_int(x) - pointer->x,
|
||||||
|
wl_fixed_from_int(y) - pointer->y);
|
||||||
|
|
||||||
notify_pointer_position(test, resource);
|
notify_pointer_position(test, resource);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user