diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2023-11-13 22:54:36 +0100 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2023-11-13 22:54:36 +0100 |
| commit | c50ed9c7e7b251e4c09e462fb93a3b0f9615195e (patch) | |
| tree | f6625ed77b43ed3e10d27dccdf0ec06827de67e1 | |
| parent | 69b61602cfa8ee5afd2a03748005e17eebeb6919 (diff) | |
| download | river-c50ed9c7e7b251e4c09e462fb93a3b0f9615195e.tar.gz river-c50ed9c7e7b251e4c09e462fb93a3b0f9615195e.tar.xz | |
Cursor: clamp cursor movement to resize bounds
Currently resizing a window allows moving the invisible "internal"
cursor infinitely far off screen despite the fact that the window is
bounded by the size constraints of the client and by the output
dimensions. This means that attempting to resize past these bounds in
one dimension will result in the "internal" cursor being far out of
bounds and will require an equal movement in the opposite direction in
order to continue resizing.
Exposing this implementation detail of an invisible "internal" cursor
separate from the rendered cursor is of course bad, so clamp it to the
bounds of the resize.
| -rw-r--r-- | river/Cursor.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/river/Cursor.zig b/river/Cursor.zig index b8fd61d..03868a9 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -895,11 +895,13 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, box.width = @max(box.width, constraints.min_width); box.width = @min(box.width, constraints.max_width); box.width = @min(box.width, x2 - border_width); + data.x = @floatFromInt(data.initial_width - box.width); } else if (data.edges.right) { box.width = data.initial_width + @as(i32, @intFromFloat(data.x)); box.width = @max(box.width, constraints.min_width); box.width = @min(box.width, constraints.max_width); box.width = @min(box.width, output_width - border_width - box.x); + data.x = @floatFromInt(box.width - data.initial_width); } if (data.edges.top) { @@ -908,11 +910,13 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, box.height = @max(box.height, constraints.min_height); box.height = @min(box.height, constraints.max_height); box.height = @min(box.height, y2 - border_width); + data.y = @floatFromInt(data.initial_height - box.height); } else if (data.edges.bottom) { box.height = data.initial_height + @as(i32, @intFromFloat(data.y)); box.height = @max(box.height, constraints.min_height); box.height = @min(box.height, constraints.max_height); box.height = @min(box.height, output_height - border_width - box.y); + data.y = @floatFromInt(box.height - data.initial_height); } server.root.applyPending(); |
