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

Commit a145430

Browse files
Xyeneemersion
authored andcommitted
input/pointer: add wlr_seat_pointer_wrap
It allows a compositor to do things like skip motion events on pointer constraint unlock. References: swaywm/sway#5431
1 parent 6ef5d18 commit a145430

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

include/wlr/types/wlr_seat.h

+6
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
409409
*/
410410
void wlr_seat_pointer_notify_clear_focus(struct wlr_seat *wlr_seat);
411411

412+
/**
413+
* Warp the pointer of this seat to the given surface-local coordinates, without
414+
* generating motion events.
415+
*/
416+
void wlr_seat_pointer_warp(struct wlr_seat *wlr_seat, double sx, double sy);
417+
412418
/**
413419
* Notify the seat of motion over the given surface. Pass surface-local
414420
* coordinates where the pointer motion occurred. Defers to any grab of the

types/seat/wlr_seat_pointer.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
199199
wlr_seat->pointer_state.focused_client = client;
200200
wlr_seat->pointer_state.focused_surface = surface;
201201
if (surface != NULL) {
202-
wlr_seat->pointer_state.sx = sx;
203-
wlr_seat->pointer_state.sy = sy;
202+
wlr_seat_pointer_warp(wlr_seat, sx, sy);
204203
} else {
205-
wlr_seat->pointer_state.sx = NAN;
206-
wlr_seat->pointer_state.sy = NAN;
204+
wlr_seat_pointer_warp(wlr_seat, NAN, NAN);
207205
}
208206

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

221+
void wlr_seat_pointer_warp(struct wlr_seat *wlr_seat, double sx, double sy) {
222+
wlr_seat->pointer_state.sx = sx;
223+
wlr_seat->pointer_state.sy = sy;
224+
}
225+
223226
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
224227
double sx, double sy) {
225228
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
@@ -241,8 +244,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
241244
wl_fixed_from_double(sy));
242245
}
243246

244-
wlr_seat->pointer_state.sx = sx;
245-
wlr_seat->pointer_state.sy = sy;
247+
wlr_seat_pointer_warp(wlr_seat, sx, sy);
246248
}
247249

248250
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,

0 commit comments

Comments
 (0)