core: darwin: Only recreate swapchain and send resize event if the window size actually changed

This commit is contained in:
foxnne 2024-12-20 14:09:59 -06:00 committed by Emi Gutekanst
parent 8520c6d7d4
commit cc387ddb59

View file

@ -354,6 +354,7 @@ const WindowDelegateCallbacks = struct {
const frame = native_window.frame();
const content_rect = native_window.contentRectForFrameRect(frame);
if (core_window.width != @as(u32, @intFromFloat(content_rect.size.width)) or core_window.height != @as(u32, @intFromFloat(content_rect.size.height))) {
core_window.width = @intFromFloat(content_rect.size.width);
core_window.height = @intFromFloat(content_rect.size.height);
@ -369,7 +370,6 @@ const WindowDelegateCallbacks = struct {
core_window.swap_chain.release();
core_window.swap_chain = core_window.device.createSwapChain(core_window.surface, &core_window.swap_chain_descriptor);
}
core.windows.setValueRaw(block.context.window_id, core_window);
@ -378,6 +378,8 @@ const WindowDelegateCallbacks = struct {
.size = .{ .width = core_window.width, .height = core_window.height },
} });
}
}
}
pub fn windowShouldClose(block: *objc.foundation.BlockLiteral(*Context)) callconv(.C) bool {
const core: *Core = block.context.core;