Преглед на файлове

Add GLFW_COCOA_FRAME_AUTOSAVE

Fixes #195.
Camilla Löwy преди 8 години
родител
ревизия
4661315192
променени са 6 файла, в които са добавени 20 реда и са изтрити 0 реда
  1. 1 0
      README.md
  2. 6 0
      docs/window.dox
  3. 6 0
      include/GLFW/glfw3.h
  4. 3 0
      src/cocoa_window.m
  5. 1 0
      src/internal.h
  6. 3 0
      src/window.c

+ 1 - 0
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

+ 6 - 0
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

+ 6 - 0
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.
  *

+ 3 - 0
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)

+ 1 - 0
src/internal.h

@@ -266,6 +266,7 @@ struct _GLFWwndconfig
     GLFWbool      maximized;
     struct {
         GLFWbool  retina;
+        GLFWbool  frame;
     } ns;
 };
 

+ 3 - 0
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;