Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
input/pointer: add wlr_seat_pointer_wrap
Browse files Browse the repository at this point in the history
It allows a compositor to do things like skip motion events on pointer
constraint unlock.

References: swaywm/sway#5431
  • Loading branch information
Xyene authored and emersion committed Jul 15, 2020
1 parent 6ef5d18 commit a145430
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions include/wlr/types/wlr_seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
*/
void wlr_seat_pointer_notify_clear_focus(struct wlr_seat *wlr_seat);

/**
* Warp the pointer of this seat to the given surface-local coordinates, without
* generating motion events.
*/
void wlr_seat_pointer_warp(struct wlr_seat *wlr_seat, double sx, double sy);

/**
* Notify the seat of motion over the given surface. Pass surface-local
* coordinates where the pointer motion occurred. Defers to any grab of the
Expand Down
14 changes: 8 additions & 6 deletions types/seat/wlr_seat_pointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
wlr_seat->pointer_state.focused_client = client;
wlr_seat->pointer_state.focused_surface = surface;
if (surface != NULL) {
wlr_seat->pointer_state.sx = sx;
wlr_seat->pointer_state.sy = sy;
wlr_seat_pointer_warp(wlr_seat, sx, sy);
} else {
wlr_seat->pointer_state.sx = NAN;
wlr_seat->pointer_state.sy = NAN;
wlr_seat_pointer_warp(wlr_seat, NAN, NAN);
}

struct wlr_seat_pointer_focus_change_event event = {
Expand All @@ -220,6 +218,11 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat) {
wlr_seat_pointer_enter(wlr_seat, NULL, 0, 0);
}

void wlr_seat_pointer_warp(struct wlr_seat *wlr_seat, double sx, double sy) {
wlr_seat->pointer_state.sx = sx;
wlr_seat->pointer_state.sy = sy;
}

void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
double sx, double sy) {
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
Expand All @@ -241,8 +244,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
wl_fixed_from_double(sy));
}

wlr_seat->pointer_state.sx = sx;
wlr_seat->pointer_state.sy = sy;
wlr_seat_pointer_warp(wlr_seat, sx, sy);
}

uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
Expand Down

0 comments on commit a145430

Please sign in to comment.