From c50ed9c7e7b251e4c09e462fb93a3b0f9615195e Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 13 Nov 2023 22:54:36 +0100 Subject: 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. --- river/Cursor.zig | 4 ++++ 1 file changed, 4 insertions(+) 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(); -- cgit v1.2.3