From d04d4444af28eee52147af2695b766c1443bafc3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Aug 2022 12:59:15 +0530 Subject: [PATCH] implement primary selection api on cocoa as stubs, can be useful for #5357 --- glfw/cocoa_window.m | 7 +++++++ glfw/input.c | 2 +- glfw/internal.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 1074e422f..e07197e1c 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2479,6 +2479,13 @@ void _glfwPlatformSetClipboardString(const char* string) [pasteboard setString:@(string) forType:NSPasteboardTypeString]; } +void _glfwPlatformSetPrimarySelectionString(const char* string) { + (void)string; + // Apple doesnt have a primary selection +} + +const char* _glfwPlatformGetPrimarySelectionString(void) { return ""; } + const char* _glfwPlatformGetClipboardString(void) { NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; diff --git a/glfw/input.c b/glfw/input.c index eff7250da..ea2c48073 100644 --- a/glfw/input.c +++ b/glfw/input.c @@ -1540,7 +1540,7 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle UNUSED) return _glfwPlatformGetClipboardString(); } -#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) +#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) || defined(__APPLE__) GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle UNUSED, const char* string) { assert(string != NULL); diff --git a/glfw/internal.h b/glfw/internal.h index f420b4068..a36403457 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -675,7 +675,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetClipboardString(const char* string); const char* _glfwPlatformGetClipboardString(void); -#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) +#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) || defined(__APPLE__) void _glfwPlatformSetPrimarySelectionString(const char* string); const char* _glfwPlatformGetPrimarySelectionString(void); #endif