aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-07-03 00:52:25 -0400
committerSimon Ser <contact@emersion.fr>2020-07-15 19:31:13 +0200
commita145430afac6e1d0fbf65250b25573fdf1b2e4fd (patch)
treedfe53c945911c04f62d912b36b17c87f422ca379
parent6ef5d18757ef5ae2f38d41d914f7d7df100e3799 (diff)
input/pointer: add wlr_seat_pointer_wrap
It allows a compositor to do things like skip motion events on pointer constraint unlock. References: https://github.com/swaywm/sway/pull/5431
-rw-r--r--include/wlr/types/wlr_seat.h6
-rw-r--r--types/seat/wlr_seat_pointer.c14
2 files changed, 14 insertions, 6 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 7b47da08..332ab0d3 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -410,6 +410,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
* pointer.
diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c
index 9ad5f88c..37c637b5 100644
--- a/types/seat/wlr_seat_pointer.c
+++ b/types/seat/wlr_seat_pointer.c
@@ -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 = {
@@ -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;
@@ -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,