Fix issue with scaled displays

This commit is contained in:
Ivan Duran
2024-11-15 22:39:48 +03:00
parent c089f0495c
commit 4bc436a8ec

View File

@ -129,10 +129,14 @@ pub fn init(
// Skip resize logic if percent is 50 (this is the default behavior) // Skip resize logic if percent is 50 (this is the default behavior)
if (new_split.percent != 50) { if (new_split.percent != 50) {
const allocation = sibling.size; 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 split_percentage: f32 = @as(f32, @floatFromInt(new_split.percent)) / 100;
const total_surface_size: f32 = switch (self.orientation) { const total_surface_size: f32 = switch (self.orientation) {
.horizontal => @floatFromInt(allocation.width), .horizontal => @as(f32, @floatFromInt(allocation.width)) / scale.x,
.vertical => @floatFromInt(allocation.height), .vertical => @as(f32, @floatFromInt(allocation.height)) / scale.y,
}; };
// percentage to apply based on direction // percentage to apply based on direction