mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 14:24:35 +00:00
Cocoa: Fix MoltenVK layer scale out of sync
The contents scale of the hosted CAMetalLayer created for MoltenVK was
updated only after the GLFW content scale and framebuffer size events
were emitted, causing the layer to get out of sync with the monitor the
window was on.
(cherry picked from commit 076bfd55be
)
This commit is contained in:
parent
a7202e2341
commit
545b6c7970
@ -124,6 +124,8 @@ information on what to include when reporting a bug.
|
|||||||
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
||||||
later (#1783,#1796)
|
later (#1783,#1796)
|
||||||
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||||
|
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
|
||||||
|
related events were emitted
|
||||||
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,6 +520,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
||||||
|
const float xscale = fbRect.size.width / contentRect.size.width;
|
||||||
|
const float yscale = fbRect.size.height / contentRect.size.height;
|
||||||
|
|
||||||
|
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
||||||
|
{
|
||||||
|
if (window->ns.retina && window->ns.layer)
|
||||||
|
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
||||||
|
|
||||||
|
window->ns.xscale = xscale;
|
||||||
|
window->ns.yscale = yscale;
|
||||||
|
_glfwInputWindowContentScale(window, xscale, yscale);
|
||||||
|
}
|
||||||
|
|
||||||
if (fbRect.size.width != window->ns.fbWidth ||
|
if (fbRect.size.width != window->ns.fbWidth ||
|
||||||
fbRect.size.height != window->ns.fbHeight)
|
fbRect.size.height != window->ns.fbHeight)
|
||||||
@ -528,19 +540,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->ns.fbHeight = fbRect.size.height;
|
window->ns.fbHeight = fbRect.size.height;
|
||||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float xscale = fbRect.size.width / contentRect.size.width;
|
|
||||||
const float yscale = fbRect.size.height / contentRect.size.height;
|
|
||||||
|
|
||||||
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
|
||||||
{
|
|
||||||
window->ns.xscale = xscale;
|
|
||||||
window->ns.yscale = yscale;
|
|
||||||
_glfwInputWindowContentScale(window, xscale, yscale);
|
|
||||||
|
|
||||||
if (window->ns.retina && window->ns.layer)
|
|
||||||
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
|
Loading…
Reference in New Issue
Block a user