From 9efc23a01d8a06fe8f1d8741f0b6a092d1265776 Mon Sep 17 00:00:00 2001 From: Thom Dickson Date: Tue, 10 Dec 2024 21:38:49 -0500 Subject: [PATCH] wip: allow directional split movement --- src/apprt/gtk/Split.zig | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/apprt/gtk/Split.zig b/src/apprt/gtk/Split.zig index 2d428acb2..8ddadfd13 100644 --- a/src/apprt/gtk/Split.zig +++ b/src/apprt/gtk/Split.zig @@ -313,11 +313,7 @@ pub fn directionMap(self: *const Split, from: Side) DirectionMap { if (self.directionPrevious(from)) |prev| { result.put(.previous, prev.surface); if (!prev.wrapped) { - // This behavior matches the behavior of macOS at the time of writing - // this. There is an open issue (#524) to make this depend on the - // actual physical location of the current split. result.put(.up, prev.surface); - result.put(.left, prev.surface); } } @@ -325,13 +321,57 @@ pub fn directionMap(self: *const Split, from: Side) DirectionMap { result.put(.next, next.surface); if (!next.wrapped) { result.put(.down, next.surface); - result.put(.right, next.surface); } } + if (self.directionLeft(from)) |left| { + result.put(.left, left); + } + + if (self.directionRight(from)) |right| { + result.put(.right, right); + } + return result; } +fn directionLeft(self: *const Split, from: Side) ?*Surface { + switch (from) { + .bottom_right => { + switch (self.orientation) { + .horizontal => return self.top_left.deepestSurface(.bottom_right), + .vertical => return directionLeft( + self.container.split() orelse return null, + .bottom_right, + ), + } + }, + .top_left => return directionLeft( + self.container.split() orelse return null, + .bottom_right, + ), + } +} + +fn directionRight(self: *const Split, from: Side) ?*Surface { + switch (from) { + .top_left => { + switch (self.orientation) { + .horizontal => return self.bottom_right.deepestSurface(.top_left), + .vertical => return directionRight( + self.container.split() orelse return null, + .top_left, + ), + } + }, + .bottom_right => return directionRight( + self.container.split() orelse return null, + .top_left, + ), + } +} + + fn directionPrevious(self: *const Split, from: Side) ?struct { surface: *Surface, wrapped: bool,