diff --git a/README.md b/README.md index a3f03d7f..8cc1909e 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. - Bugfix: The cached current context could get out of sync - [Cocoa] Bugfix: The cached `NSScreen` for a monitor could get out of sync - [Cocoa] Bugfix: The `GLFW_AUTO_ICONIFY` window hint was ignored + - [Cocoa] Bugfix: Resizing a window to its minimum size would segfault + - [Cocoa] Bugfix: Creating or showing a window would make its context current - [X11] Bugfix: `glfwInit` would segfault on systems without RandR diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 42ba6811..efa32948 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -173,6 +173,8 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect) - (void)windowDidResize:(NSNotification *)notification { + [window->nsgl.context update]; + if (_glfw.focusedWindow == window && window->cursorMode == GLFW_CURSOR_DISABLED) { @@ -189,6 +191,8 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect) - (void)windowDidMove:(NSNotification *)notification { + [window->nsgl.context update]; + if (_glfw.focusedWindow == window && window->cursorMode == GLFW_CURSOR_DISABLED) { @@ -302,7 +306,7 @@ static int translateKey(unsigned int key) // Content view class for the GLFW window //------------------------------------------------------------------------ -@interface GLFWContentView : NSOpenGLView +@interface GLFWContentView : NSView { _GLFWwindow* window; NSTrackingArea* trackingArea; @@ -330,8 +334,7 @@ static int translateKey(unsigned int key) - (id)initWithGlfwWindow:(_GLFWwindow *)initWindow { - self = [super initWithFrame:NSMakeRect(0, 0, 1, 1) - pixelFormat:nil]; + self = [super init]; if (self != nil) { window = initWindow; @@ -894,9 +897,19 @@ static GLboolean createWindow(_GLFWwindow* window, [window->ns.object setLevel:NSFloatingWindowLevel]; } + window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; + +#if defined(_GLFW_USE_RETINA) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) + [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ +#endif /*_GLFW_USE_RETINA*/ + [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]]; [window->ns.object setDelegate:window->ns.delegate]; [window->ns.object setAcceptsMouseMovedEvents:YES]; + [window->ns.object setContentView:window->ns.view]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) @@ -925,22 +938,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!_glfwCreateContext(window, ctxconfig, fbconfig)) return GL_FALSE; - window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - -#if defined(_GLFW_USE_RETINA) -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; -#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ -#endif /*_GLFW_USE_RETINA*/ - - [window->ns.object setContentView:window->ns.view]; - // NOTE: If you set the pixel format before the context it creates another - // context, only to have it destroyed by the next line - // We cannot use the view to create the context because that interface - // does not support context resource sharing - [window->ns.view setOpenGLContext:window->nsgl.context]; - [window->ns.view setPixelFormat:window->nsgl.pixelFormat]; [window->nsgl.context setView:window->ns.view]; if (wndconfig->monitor)