From 4bc436a8ec88819aed70639a063194cb935df6ab Mon Sep 17 00:00:00 2001 From: Ivan Duran Date: Fri, 15 Nov 2024 22:39:48 +0300 Subject: [PATCH] Fix issue with scaled displays --- src/apprt/gtk/Split.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/apprt/gtk/Split.zig b/src/apprt/gtk/Split.zig index 92e3989b9..2442113a4 100644 --- a/src/apprt/gtk/Split.zig +++ b/src/apprt/gtk/Split.zig @@ -129,10 +129,14 @@ pub fn init( // Skip resize logic if percent is 50 (this is the default behavior) if (new_split.percent != 50) { const allocation = sibling.size; + + // get the content scale to handle scaled HiDPI displays + const scale = try sibling.getContentScale(); + const split_percentage: f32 = @as(f32, @floatFromInt(new_split.percent)) / 100; const total_surface_size: f32 = switch (self.orientation) { - .horizontal => @floatFromInt(allocation.width), - .vertical => @floatFromInt(allocation.height), + .horizontal => @as(f32, @floatFromInt(allocation.width)) / scale.x, + .vertical => @as(f32, @floatFromInt(allocation.height)) / scale.y, }; // percentage to apply based on direction