From 466131519202311056812eb8a247b8aa95bc418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 1 Jan 2017 19:41:50 +0100 Subject: [PATCH] Add GLFW_COCOA_FRAME_AUTOSAVE Fixes #195. --- README.md | 1 + docs/window.dox | 6 ++++++ include/GLFW/glfw3.h | 6 ++++++ src/cocoa_window.m | 3 +++ src/internal.h | 1 + src/window.c | 3 +++ 6 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 9ba95d99..afaa2b6c 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ information on what to include when reporting a bug. - Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#281,#850) - Added definition of `GLAPIENTRY` to public header - Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint +- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195) - Removed `GLFW_USE_RETINA` compile-time option - Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored - Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding diff --git a/docs/window.dox b/docs/window.dox index 8168005d..b4d5d2b8 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -411,6 +411,11 @@ being listed. __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution framebuffers on Retina displays. This is ignored on other platforms. +@anchor GLFW_COCOA_FRAME_AUTOSAVE_hint +__GLFW_COCOA_FRAME_AUTOSAVE__ specifies whether to activate frame autosaving +using the window title specified at window creation. This is ignored on other +platforms. + @subsubsection window_hints_values Supported and default values @@ -449,6 +454,7 @@ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GL GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` +GLFW_COCOA_FRAME_AUTOSAVE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` @section window_events Window event processing diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e050478a..c27e20bb 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -830,6 +830,7 @@ extern "C" { #define GLFW_CONTEXT_CREATION_API 0x0002200B #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 +#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002 /*! @} */ #define GLFW_NO_API 0 @@ -2037,6 +2038,11 @@ GLFWAPI void glfwWindowHint(int hint, int value); * a custom `Info.plist` template for this, which can be found as * `CMake/MacOSXBundleInfo.plist.in` in the source tree. * + * @remark @macos When activating frame autosaving with + * [GLFW_COCOA_FRAME_AUTOSAVE](@ref GLFW_COCOA_FRAME_AUTOSAVE_hint), the + * specified window size may be overriden by a previously saved size and + * position. + * * @remark @x11 Some window managers will not respect the placement of * initially hidden windows. * diff --git a/src/cocoa_window.m b/src/cocoa_window.m index a8bccc88..f40108fb 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1036,6 +1036,9 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object zoom:nil]; } + if (wndconfig->ns.frame) + [window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->title]]; + window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; if (wndconfig->ns.retina) diff --git a/src/internal.h b/src/internal.h index ed89ba56..3da9da2e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -266,6 +266,7 @@ struct _GLFWwndconfig GLFWbool maximized; struct { GLFWbool retina; + GLFWbool frame; } ns; }; diff --git a/src/window.c b/src/window.c index 419db4dd..f6d71b68 100644 --- a/src/window.c +++ b/src/window.c @@ -346,6 +346,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; break; + case GLFW_COCOA_FRAME_AUTOSAVE: + _glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE; + break; case GLFW_CLIENT_API: _glfw.hints.context.client = value; break;