gtk: respect minimum split size when using resize keys

This is the GTK equivalent of #1304.
This commit is contained in:
Thorsten Ball
2024-01-18 06:38:08 +01:00
parent 8fad0b7c6f
commit 551d19205b

View File

@ -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);