core: darwin: Only recreate swapchain and send resize event if the window size actually changed
This commit is contained in:
parent
8520c6d7d4
commit
cc387ddb59
1 changed files with 20 additions and 18 deletions
|
|
@ -354,6 +354,7 @@ const WindowDelegateCallbacks = struct {
|
||||||
const frame = native_window.frame();
|
const frame = native_window.frame();
|
||||||
const content_rect = native_window.contentRectForFrameRect(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.width = @intFromFloat(content_rect.size.width);
|
||||||
core_window.height = @intFromFloat(content_rect.size.height);
|
core_window.height = @intFromFloat(content_rect.size.height);
|
||||||
|
|
||||||
|
|
@ -369,7 +370,6 @@ const WindowDelegateCallbacks = struct {
|
||||||
core_window.swap_chain.release();
|
core_window.swap_chain.release();
|
||||||
|
|
||||||
core_window.swap_chain = core_window.device.createSwapChain(core_window.surface, &core_window.swap_chain_descriptor);
|
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);
|
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 },
|
.size = .{ .width = core_window.width, .height = core_window.height },
|
||||||
} });
|
} });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn windowShouldClose(block: *objc.foundation.BlockLiteral(*Context)) callconv(.C) bool {
|
pub fn windowShouldClose(block: *objc.foundation.BlockLiteral(*Context)) callconv(.C) bool {
|
||||||
const core: *Core = block.context.core;
|
const core: *Core = block.context.core;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue