diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-08-07 21:34:38 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-08-07 21:36:28 +0200 |
| commit | e66c8b00195cce0f8ba2fdd0b5d1b19c121bf715 (patch) | |
| tree | dba78a4d2be405ec755a2073778660ff3ee5eaa1 | |
| parent | 0c4e3295b190770da1f346779c18777c9504721b (diff) | |
| download | river-e66c8b00195cce0f8ba2fdd0b5d1b19c121bf715.tar.gz river-e66c8b00195cce0f8ba2fdd0b5d1b19c121bf715.tar.xz | |
code: clean up cursor resize mode
- offset_{x,y} is consistent with delta_{x,y}
- no need to name the type, it's only referenced in one place
| -rw-r--r-- | river/Cursor.zig | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/river/Cursor.zig b/river/Cursor.zig index ec9a216..ae2be4c 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -33,18 +33,16 @@ const Seat = @import("Seat.zig"); const View = @import("View.zig"); const ViewStack = @import("view_stack.zig").ViewStack; -const ResizeData = struct { - view: *View, - /// Offset from the lower right corner of the view - x_offset: i32, - y_offset: i32, -}; - const Mode = union(enum) { passthrough: void, down: *View, move: *View, - resize: ResizeData, + resize: struct { + view: *View, + /// Offset from the lower right corner of the view + offset_x: i32, + offset_y: i32, + }, /// Enter move or resize mode fn enter(self: *Self, mode: @TagType(Mode), event: *c.wlr_event_pointer_button, view: *View) void { @@ -61,8 +59,8 @@ const Mode = union(enum) { .resize => .{ .resize = .{ .view = view, - .x_offset = cur_box.x + @intCast(i32, cur_box.width) - @floatToInt(i32, self.wlr_cursor.x), - .y_offset = cur_box.y + @intCast(i32, cur_box.height) - @floatToInt(i32, self.wlr_cursor.y), + .offset_x = cur_box.x + @intCast(i32, cur_box.width) - @floatToInt(i32, self.wlr_cursor.x), + .offset_y = cur_box.y + @intCast(i32, cur_box.height) - @floatToInt(i32, self.wlr_cursor.y), }, }, }; @@ -171,8 +169,8 @@ const Mode = union(enum) { c.wlr_cursor_warp_closest( self.wlr_cursor, device, - @intToFloat(f64, box.x + @intCast(i32, box.width) - data.x_offset), - @intToFloat(f64, box.y + @intCast(i32, box.height) - data.y_offset), + @intToFloat(f64, box.x + @intCast(i32, box.width) - data.offset_x), + @intToFloat(f64, box.y + @intCast(i32, box.height) - data.offset_y), ); }, } |
