Fix #160570: macOS: Broken window drawing on fullscreen window restoration

When Blender was opened with a fullscreen window, either by starting
Blender with the `--window-fullscreen` CLI option or by using a
startup.blender that was saved as fullscreen, window drawing would be
slightly broken and drawn out of bound until framebuffer drawn size was
refreshed. When using the macOS Stage Manager, the problem would be
exacerbated with the drawn Metal framebuffer content not matching the
window size, even after a size change refresh (as shown in #160570).

The issue came from the GHOST macOS WindowCocoa ctor restoring the
fullscreen TWindowState at the very end of the constructor *after* the
metalLayer drawn size was computed, leading to various issue. Fixed by
moving the fullscreen restoration logic between the drawing size
computation/update logic and the view/layer setup, and (importantly)
moving the makeKeyAndOrderFront window method call to the bottom of the
function to ensure the window is only made key when fully setup.

Pull Request: https://projects.blender.org/blender/blender/pulls/160923
This commit is contained in:
Jonas Holzman 2026-07-01 14:32:38 +02:00
parent effabfaae3
commit 2dd8b4c7c5

View file

@ -428,7 +428,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
window_.contentView = view;
window_.initialFirstResponder = view;
[window_ makeKeyAndOrderFront:nil];
if (state == GHOST_kWindowStateFullScreen) {
setState(GHOST_kWindowStateFullScreen);
}
updateDrawingSize();
@ -463,11 +465,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
window_.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary;
}
if (state == GHOST_kWindowStateFullScreen) {
setState(GHOST_kWindowStateFullScreen);
}
setNativePixelSize();
[window_ makeKeyAndOrderFront:nil];
}
}