From 9da2285b140ba054875906159cd63f739dbaf448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Dec 2017 16:45:38 +0100 Subject: [PATCH] Cocoa: Make frame autosave hint a string --- README.md | 2 +- docs/window.dox | 10 +++++----- include/GLFW/glfw3.h | 7 +++---- src/cocoa_window.m | 4 ++-- src/internal.h | 2 +- src/window.c | 7 ++++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3667b8e7..421bdab8 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ information on what to include when reporting a bug. - Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889) - Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946) - Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint -- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195) +- Added macOS specific `GLFW_COCOA_FRAME_NAME` window hint (#195) - Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935) - Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint - Added macOS specific `GLFW_COCOA_MENUBAR` init hint diff --git a/docs/window.dox b/docs/window.dox index 994904f9..1d2b4651 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -443,10 +443,10 @@ __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution framebuffers on Retina displays. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. 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. Possible values are -`GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. +@anchor GLFW_COCOA_FRAME_NAME_hint +__GLFW_COCOA_FRAME_NAME__ specifies the UTF-8 encoded name to use for autosaving +the window frame, or if empty disables frame autosaving for the window. This is +ignored on other platforms. This is set with @ref glfwWindowHintString. @anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint __GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics @@ -515,7 +515,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` +GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e51f335f..9ade8c74 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -964,7 +964,7 @@ extern "C" { #define GLFW_CONTEXT_CREATION_API 0x0002200B #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 -#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002 +#define GLFW_COCOA_FRAME_NAME 0x00023002 #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003 #define GLFW_X11_CLASS_NAME 0x00024001 @@ -2360,9 +2360,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * `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. + * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified + * window size and position may be overriden by previously saved values. * * @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 cbea7374..c91fbb91 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1096,8 +1096,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object zoom:nil]; } - if (wndconfig->ns.frame) - [window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->title]]; + if (strlen(wndconfig->ns.frameName)) + [window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->ns.frameName]]; window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; diff --git a/src/internal.h b/src/internal.h index a9f16c6b..dda8ae75 100644 --- a/src/internal.h +++ b/src/internal.h @@ -304,7 +304,7 @@ struct _GLFWwndconfig GLFWbool centerCursor; struct { GLFWbool retina; - GLFWbool frame; + char frameName[256]; } ns; struct { char className[256]; diff --git a/src/window.c b/src/window.c index de03f5fb..fe9d60dd 100644 --- a/src/window.c +++ b/src/window.c @@ -349,9 +349,6 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; return; - case GLFW_COCOA_FRAME_AUTOSAVE: - _glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE; - return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return; @@ -404,6 +401,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value) switch (hint) { + case GLFW_COCOA_FRAME_NAME: + strncpy(_glfw.hints.window.ns.frameName, value, + sizeof(_glfw.hints.window.ns.frameName) - 1); + return; case GLFW_X11_CLASS_NAME: strncpy(_glfw.hints.window.x11.className, value, sizeof(_glfw.hints.window.x11.className) - 1);