Skip to content

Commit

Permalink
Merge pull request #1410 from mitchellh/macos-scale
Browse files Browse the repository at this point in the history
apprt/embedded: do not allow NaN or small content scales
  • Loading branch information
mitchellh authored Jan 29, 2024
2 parents 0e46783 + 5c0e634 commit 80a91a6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/apprt/embedded.zig
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,15 @@ pub const Surface = struct {
}

pub fn updateContentScale(self: *Surface, x: f64, y: f64) void {
// We are an embedded API so the caller can send us all sorts of
// garbage. We want to make sure that the float values are valid
// and we don't want to support fractional scaling below 1.
const x_scaled = @max(1, if (std.math.isNan(x)) 1 else x);
const y_scaled = @max(1, if (std.math.isNan(y)) 1 else y);

self.content_scale = .{
.x = @floatCast(x),
.y = @floatCast(y),
.x = @floatCast(x_scaled),
.y = @floatCast(y_scaled),
};

self.core_surface.contentScaleCallback(self.content_scale) catch |err| {
Expand Down

0 comments on commit 80a91a6

Please sign in to comment.