From 551d19205bfc1d20a1ff546bf09655322122ba46 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Thu, 18 Jan 2024 06:38:08 +0100 Subject: [PATCH] gtk: respect minimum split size when using resize keys This is the GTK equivalent of #1304. --- src/apprt/gtk/Split.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apprt/gtk/Split.zig b/src/apprt/gtk/Split.zig index af44bc758..e6d1bd787 100644 --- a/src/apprt/gtk/Split.zig +++ b/src/apprt/gtk/Split.zig @@ -163,10 +163,15 @@ fn removeChild( /// Move the divider in the given direction by the given amount. pub fn moveDivider(self: *Split, direction: input.SplitResizeDirection, amount: u16) void { + const min_pos = 10; + const pos = c.gtk_paned_get_position(self.paned); const new = switch (direction) { - .up, .left => pos - amount, - .down, .right => pos + amount, + .up, .left => @max(pos - amount, min_pos), + .down, .right => new_pos: { + const max_pos: u16 = @as(u16, @intFromFloat(self.maxPosition())) - min_pos; + break :new_pos @min(pos + amount, max_pos); + }, }; c.gtk_paned_set_position(self.paned, new);