From 86808dbf47b2b07065838afb551cf334aca8ea4b Mon Sep 17 00:00:00 2001 From: Basil Keeler Date: Sat, 28 Mar 2026 20:03:04 -0500 Subject: [PATCH 1/3] Change window's output when being dragged between them --- src/Seat.zig | 22 ++++++++++++++++++++++ src/utils.zig | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/src/Seat.zig b/src/Seat.zig index 7a5447b..d4d4cd7 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -15,6 +15,7 @@ layer_focus: LayerFocus = .focus_none, pointer_op: PointerOp = .none, +pointer_pos: utils.Pos = .{}, /// State consumed in manage phase, reset at end of manage(). pending_manage: PendingManage = .{}, @@ -107,6 +108,11 @@ fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: * .op_release => { seat.pending_manage.op_released = true; }, + .pointer_position => |ev| { + seat.pointer_pos.x = ev.x; + seat.pointer_pos.y = ev.y; + }, + else => |ev| { log.debug("unhandled event: {s}", .{@tagName(ev)}); }, @@ -308,8 +314,24 @@ pub fn manage(seat: *Seat) void { switch (seat.pointer_op) { .none => {}, .move => { + const window = seat.focused_window orelse return; seat.river_seat_v1.opEnd(); seat.pointer_op = .none; + // Iterate over every display and check if the curser is inside it + var it = seat.context.wm.outputs.iterator(.forward); + while (it.next()) |output| { + if (utils.isPosInRect(seat.pointer_pos, output.geometry)) { + window.pending_manage.pending_output = .{ .output = output }; + std.log.debug("{}\n\n", .{output.geometry}); + + // We have to remove window from current output's windows list first + window.link.remove(); + output.windows.append(window); + + seat.pending_manage.output = .{ .output = output }; + window.pending_manage.pending_output = .{ .output = output }; + } + } }, .resize => |op| { op.window.river_window_v1.informResizeEnd(); diff --git a/src/utils.zig b/src/utils.zig index 0243443..80a60d4 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -19,6 +19,15 @@ pub const Rect = struct { y: i32 = 0, }; +pub const Pos = struct { + x: i32 = 0, + y: i32 = 0, +}; + +pub fn isPosInRect(pos: Pos, rect: Rect) bool { + return (pos.x > rect.x and pos.x < rect.x + rect.width) and (pos.y > rect.y and pos.y < rect.y + rect.height); +} + /// Parse a color in the format 0xRRGGBB or 0xRRGGBBAA and convert it to /// 32-bit color values (used by Window.set_borders in rwm). pub fn parseRgba(s: []const u8) !RiverColor { From 40cf36890a9ba669884ed7339353815b19fdf60b Mon Sep 17 00:00:00 2001 From: totalchaos Date: Sun, 29 Mar 2026 03:35:52 +0200 Subject: [PATCH 2/3] Remove line I added to test --- src/Seat.zig | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Seat.zig b/src/Seat.zig index d4d4cd7..975d4fd 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -322,8 +322,6 @@ pub fn manage(seat: *Seat) void { while (it.next()) |output| { if (utils.isPosInRect(seat.pointer_pos, output.geometry)) { window.pending_manage.pending_output = .{ .output = output }; - std.log.debug("{}\n\n", .{output.geometry}); - // We have to remove window from current output's windows list first window.link.remove(); output.windows.append(window); From ae779e4d147d54ebab672eb11c9485919bb16082 Mon Sep 17 00:00:00 2001 From: Basil Keeler Date: Sat, 28 Mar 2026 21:03:07 -0500 Subject: [PATCH 3/3] add suggested break when the correct monitor is found --- src/Seat.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Seat.zig b/src/Seat.zig index 975d4fd..77b95fe 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -328,6 +328,7 @@ pub fn manage(seat: *Seat) void { seat.pending_manage.output = .{ .output = output }; window.pending_manage.pending_output = .{ .output = output }; + break; } } },