aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-05-02 19:22:15 -0400
committerSimon Ser <contact@emersion.fr>2020-05-21 10:45:08 +0200
commit6f0a0bd3852c6d92f30d43b9a39dc743987584ac (patch)
tree66b836ab37f4cf84957aaab4bdbc200691d3e08e /sway/input
parent45e4e9217238fe658b99634d284768439969ad79 (diff)
input/pointer: only warp cursor when the confine region has changed
Refs #5268.
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 646c61b3..8121cc84 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -774,7 +774,9 @@ static void check_constraint_region(struct sway_cursor *cursor) {
struct wlr_pointer_constraint_v1 *constraint = cursor->active_constraint;
pixman_region32_t *region = &constraint->region;
struct sway_view *view = view_from_wlr_surface(constraint->surface);
- if (view) {
+ if (cursor->active_confine_requires_warp && view) {
+ cursor->active_confine_requires_warp = false;
+
struct sway_container *con = view->container;
double sx = cursor->cursor->x - con->content_x + view->geometry.x;
@@ -813,6 +815,13 @@ static void handle_constraint_commit(struct wl_listener *listener,
check_constraint_region(cursor);
}
+static void handle_pointer_constraint_set_region(struct wl_listener *listener,
+ void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, constraint_commit);
+ cursor->active_confine_requires_warp = true;
+}
+
static void handle_request_pointer_set_cursor(struct wl_listener *listener,
void *data) {
struct sway_cursor *cursor =
@@ -1224,6 +1233,7 @@ void handle_constraint_destroy(struct wl_listener *listener, void *data) {
struct sway_seat *seat = constraint->seat->data;
struct sway_cursor *cursor = seat->cursor;
+ wl_list_remove(&sway_constraint->set_region.link);
wl_list_remove(&sway_constraint->destroy.link);
if (cursor->active_constraint == constraint) {
@@ -1247,6 +1257,9 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) {
calloc(1, sizeof(struct sway_pointer_constraint));
sway_constraint->constraint = constraint;
+ sway_constraint->set_region.notify = handle_pointer_constraint_set_region;
+ wl_signal_add(&constraint->events.set_region, &sway_constraint->set_region);
+
sway_constraint->destroy.notify = handle_constraint_destroy;
wl_signal_add(&constraint->events.destroy, &sway_constraint->destroy);
@@ -1290,6 +1303,8 @@ void sway_cursor_constrain(struct sway_cursor *cursor,
return;
}
+ cursor->active_confine_requires_warp = true;
+
// FIXME: Big hack, stolen from wlr_pointer_constraints_v1.c:121.
// This is necessary because the focus may be set before the surface
// has finished committing, which means that warping won't work properly,