Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
Cursor: delete dead code
river/Cursor.zig | 67 --------------------------------------------------------
river/Window.zig | 33 ----------------------------
2 files changed, 100 deletions(-)
diff --git a/river/Cursor.zig b/river/Cursor.zig
index 826adac..d8ced5b 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -641,73 +641,6 @@ fn handleTabletToolButton(
tool.button(tablet, event);
}
-pub fn startResize(cursor: *Cursor, window: *Window, proposed_edges: ?wlr.Edges) void {
- if (cursor.constraint) |constraint| {
- if (constraint.state == .active) constraint.deactivate();
- }
-
- const edges = blk: {
- if (proposed_edges) |edges| {
- if (edges.top or edges.bottom or edges.left or edges.right) {
- break :blk edges;
- }
- }
- break :blk cursor.computeEdges(window);
- };
-
- const box = &window.current.box;
- const lx: i32 = @intFromFloat(cursor.wlr_cursor.x);
- const ly: i32 = @intFromFloat(cursor.wlr_cursor.y);
- const offset_x = if (edges.left) lx - box.x else box.x + box.width - lx;
- const offset_y = if (edges.top) ly - box.y else box.y + box.height - ly;
-
- window.pending.resizing = true;
-
- const new_mode: Mode = .{ .resize = .{
- .window = window,
- .edges = edges,
- .offset_x = offset_x,
- .offset_y = offset_y,
- .initial_width = @intCast(box.width),
- .initial_height = @intCast(box.height),
- } };
- cursor.enterMode(new_mode, window, wlr.Xcursor.getResizeName(edges));
-}
-
-fn computeEdges(cursor: *const Cursor, window: *const Window) wlr.Edges {
- const min_handle_size = 20;
- const box = &window.current.box;
-
- const sx = @as(i32, @intFromFloat(cursor.wlr_cursor.x)) - box.x;
- const sy = @as(i32, @intFromFloat(cursor.wlr_cursor.y)) - box.y;
-
- var edges: wlr.Edges = .{};
-
- if (box.width > min_handle_size * 2) {
- const handle = @max(min_handle_size, @divFloor(box.width, 5));
- if (sx < handle) {
- edges.left = true;
- } else if (sx > box.width - handle) {
- edges.right = true;
- }
- }
-
- if (box.height > min_handle_size * 2) {
- const handle = @max(min_handle_size, @divFloor(box.height, 5));
- if (sy < handle) {
- edges.top = true;
- } else if (sy > box.height - handle) {
- edges.bottom = true;
- }
- }
-
- if (!edges.top and !edges.bottom and !edges.left and !edges.right) {
- return .{ .bottom = true, .right = true };
- } else {
- return edges;
- }
-}
-
pub fn updateState(cursor: *Cursor) void {
if (cursor.constraint) |constraint| {
constraint.updateState();
diff --git a/river/Window.zig b/river/Window.zig
index 3836e7d..92a8344 100644
--- a/river/Window.zig
+++ b/river/Window.zig
@@ -595,39 +595,6 @@ pub fn configure(window: *Window) bool {
return track_configure;
}
-/// The change in x/y position of the window during resize cannot be determined
-/// until the size of the buffer actually committed is known. Clients are permitted
-/// by the protocol to take a size smaller than that requested by the compositor in
-/// order to maintain an aspect ratio or similar (mpv does this for example).
-pub fn resizeUpdatePosition(window: *Window, width: i32, height: i32) void {
- assert(window.inflight.resizing);
-
- const data = blk: {
- var it = server.input_manager.seats.iterator(.forward);
- while (it.next()) |seat| {
- if (seat.cursor.inflight_mode == .resize and
- seat.cursor.inflight_mode.resize.window == window)
- {
- break :blk seat.cursor.inflight_mode.resize;
- }
- } else {
- // The window resizing state should never be set when the window is
- // not the target of an interactive resize.
- unreachable;
- }
- };
-
- if (data.edges.left) {
- window.inflight.box.x += window.current.box.width - width;
- window.pending.box.x = window.inflight.box.x;
- }
-
- if (data.edges.top) {
- window.inflight.box.y += window.current.box.height - height;
- window.pending.box.y = window.inflight.box.y;
- }
-}
-
pub fn commitTransaction(window: *Window) void {
window.foreign_toplevel_handle.update();