Przeglądaj źródła

Cocoa: Make frame autosave hint a string

Camilla Löwy 7 lat temu
rodzic
commit
9da2285b14
6 zmienionych plików z 16 dodań i 16 usunięć
  1. 1 1
      README.md
  2. 5 5
      docs/window.dox
  3. 3 4
      include/GLFW/glfw3.h
  4. 2 2
      src/cocoa_window.m
  5. 1 1
      src/internal.h
  6. 4 3
      src/window.c

+ 1 - 1
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_JOYSTICK_HAT_BUTTONS` init hint (#889)
 - Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946)
 - 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_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_GRAPHICS_SWITCHING` window hint (#377,#935)
 - Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
 - Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
 - Added macOS specific `GLFW_COCOA_MENUBAR` init hint
 - Added macOS specific `GLFW_COCOA_MENUBAR` init hint

+ 5 - 5
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
 framebuffers on Retina displays.  Possible values are `GLFW_TRUE` and
 `GLFW_FALSE`.  This is ignored on other platforms.
 `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
 @anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint
 __GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics
 __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_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_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_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_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE`                | `GLFW_TRUE` or `GLFW_FALSE`
 GLFW_X11_CLASS_NAME           | `""`                        | An ASCII encoded `WM_CLASS` class name
 GLFW_X11_CLASS_NAME           | `""`                        | An ASCII encoded `WM_CLASS` class name
 GLFW_X11_INSTANCE_NAME        | `""`                        | An ASCII encoded `WM_CLASS` instance name
 GLFW_X11_INSTANCE_NAME        | `""`                        | An ASCII encoded `WM_CLASS` instance name

+ 3 - 4
include/GLFW/glfw3.h

@@ -964,7 +964,7 @@ extern "C" {
 #define GLFW_CONTEXT_CREATION_API   0x0002200B
 #define GLFW_CONTEXT_CREATION_API   0x0002200B
 
 
 #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
 #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_COCOA_GRAPHICS_SWITCHING 0x00023003
 
 
 #define GLFW_X11_CLASS_NAME         0x00024001
 #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.
  *  `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  *
  *
  *  @remark @macos When activating frame autosaving with
  *  @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
  *  @remark @x11 Some window managers will not respect the placement of
  *  initially hidden windows.
  *  initially hidden windows.

+ 2 - 2
src/cocoa_window.m

@@ -1096,8 +1096,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
             [window->ns.object zoom:nil];
             [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];
     window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
 
 

+ 1 - 1
src/internal.h

@@ -304,7 +304,7 @@ struct _GLFWwndconfig
     GLFWbool      centerCursor;
     GLFWbool      centerCursor;
     struct {
     struct {
         GLFWbool  retina;
         GLFWbool  retina;
-        GLFWbool  frame;
+        char      frameName[256];
     } ns;
     } ns;
     struct {
     struct {
         char      className[256];
         char      className[256];

+ 4 - 3
src/window.c

@@ -349,9 +349,6 @@ GLFWAPI void glfwWindowHint(int hint, int value)
         case GLFW_COCOA_RETINA_FRAMEBUFFER:
         case GLFW_COCOA_RETINA_FRAMEBUFFER:
             _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
             _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
             return;
             return;
-        case GLFW_COCOA_FRAME_AUTOSAVE:
-            _glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
         case GLFW_COCOA_GRAPHICS_SWITCHING:
         case GLFW_COCOA_GRAPHICS_SWITCHING:
             _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
             _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
             return;
             return;
@@ -404,6 +401,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
 
 
     switch (hint)
     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:
         case GLFW_X11_CLASS_NAME:
             strncpy(_glfw.hints.window.x11.className, value,
             strncpy(_glfw.hints.window.x11.className, value,
                     sizeof(_glfw.hints.window.x11.className) - 1);
                     sizeof(_glfw.hints.window.x11.className) - 1);