From b10312e24913c5360d50806d3897742b4f12b30d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 28 Mar 2019 13:09:22 +0530 Subject: [PATCH] Upstream fixes for vulkan surface creation and the retina hint https://github.com/glfw/glfw/commit/e108c0de0d531123b560931c07c5a226e7d7a3da https://github.com/glfw/glfw/commit/980fc9b52f397ec54ce65f69abe9ff694622b4ab --- glfw/cocoa_platform.h | 1 + glfw/cocoa_window.m | 17 +++++------------ glfw/nsgl_context.m | 3 +++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index a1523e90d..d9586c29e 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -117,6 +117,7 @@ typedef struct _GLFWwindowNS id layer; GLFWbool maximized; + GLFWbool retina; // Cached window properties to filter out duplicate events int width, height; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b3bc3b84d..fddcee4d4 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -592,14 +592,6 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; _glfwInputWindowDamage(window); } -- (id)makeBackingLayer -{ - if (window->ns.layer) - return window->ns.layer; - - return [super makeBackingLayer]; -} - - (void)cursorUpdate:(NSEvent *)event { updateCursorImage(window); @@ -728,7 +720,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; window->ns.yscale = yscale; _glfwInputWindowContentScale(window, xscale, yscale); - if (window->ns.layer) + if (window->ns.retina && window->ns.layer) [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; } } @@ -1285,8 +1277,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - if (wndconfig->ns.retina) - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + window->ns.retina = wndconfig->ns.retina; if (fbconfig->transparent) { @@ -2031,7 +2022,9 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; } - [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + if (window->ns.retina) + [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + [window->ns.view setLayer:window->ns.layer]; [window->ns.view setWantsLayer:YES]; memset(&sci, 0, sizeof(sci)); diff --git a/glfw/nsgl_context.m b/glfw/nsgl_context.m index ede99a319..cfa398d94 100644 --- a/glfw/nsgl_context.m +++ b/glfw/nsgl_context.m @@ -299,6 +299,9 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, [window->context.nsgl.object setValues:&opaque forParameter:NSOpenGLContextParameterSurfaceOpacity]; } + if (window->ns.retina) + [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + [window->context.nsgl.object setView:window->ns.view]; window->context.makeCurrent = makeContextCurrentNSGL;