|
|
@ -147,19 +147,20 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
|
|
|
double x = cur->x + delta_x;
|
|
|
|
double x = cur->x + delta_x;
|
|
|
|
double y = cur->y + delta_y;
|
|
|
|
double y = cur->y + delta_y;
|
|
|
|
|
|
|
|
|
|
|
|
// cursor geometry constraints
|
|
|
|
// geometry constraints
|
|
|
|
if (cur->state->mapped_geometry) {
|
|
|
|
struct wlr_geometry *constraints = NULL;
|
|
|
|
int closest_x, closest_y;
|
|
|
|
if (cur->state->mapped_geometry != NULL ||
|
|
|
|
wlr_geometry_closest_boundary(cur->state->mapped_geometry, x, y,
|
|
|
|
c_device->mapped_geometry != NULL) {
|
|
|
|
&closest_x, &closest_y, NULL);
|
|
|
|
constraints = calloc(1, sizeof(struct wlr_geometry));
|
|
|
|
x = closest_x;
|
|
|
|
|
|
|
|
y = closest_y;
|
|
|
|
if (!wlr_geometry_intersection(cur->state->mapped_geometry,
|
|
|
|
}
|
|
|
|
c_device->mapped_geometry, &constraints)) {
|
|
|
|
|
|
|
|
// TODO handle no possible movement
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// device constraints
|
|
|
|
|
|
|
|
if (c_device->mapped_geometry) {
|
|
|
|
|
|
|
|
int closest_x, closest_y;
|
|
|
|
int closest_x, closest_y;
|
|
|
|
wlr_geometry_closest_boundary(c_device->mapped_geometry, x, y,
|
|
|
|
wlr_geometry_closest_boundary(constraints, x, y,
|
|
|
|
&closest_x, &closest_y, NULL);
|
|
|
|
&closest_x, &closest_y, NULL);
|
|
|
|
x = closest_x;
|
|
|
|
x = closest_x;
|
|
|
|
y = closest_y;
|
|
|
|
y = closest_y;
|
|
|
@ -177,10 +178,20 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
|
|
|
y = closest_y;
|
|
|
|
y = closest_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (constraints && !wlr_geometry_contains_point(constraints, x, y)) {
|
|
|
|
|
|
|
|
// TODO handle no possible movement
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (wlr_cursor_warp(cur, dev, x, y)) {
|
|
|
|
if (wlr_cursor_warp(cur, dev, x, y)) {
|
|
|
|
cur->x = x;
|
|
|
|
cur->x = x;
|
|
|
|
cur->y = y;
|
|
|
|
cur->y = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
if (constraints) {
|
|
|
|
|
|
|
|
free(constraints);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_pointer_motion(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_pointer_motion(struct wl_listener *listener, void *data) {
|
|
|
|