Deprecate window parameter of clipboard functions

This commit is contained in:
Camilla Löwy 2017-11-04 21:11:58 +01:00
parent f2756d0b3f
commit 31cbb20ba2
12 changed files with 23 additions and 31 deletions

View File

@ -168,6 +168,7 @@ information on what to include when reporting a bug.
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
- Added `GenerateMappings.cmake` script for updating gamepad mappings
- Deprecated window parameter of clipboard string functions
- Removed `GLFW_USE_RETINA` compile-time option
- Removed `GLFW_USE_CHDIR` compile-time option
- Removed `GLFW_USE_MENUBAR` compile-time option

View File

@ -846,7 +846,7 @@ converted to one, you can retrieve it with @ref glfwGetClipboardString. See the
reference documentation for the lifetime of the returned string.
@code
const char* text = glfwGetClipboardString(window);
const char* text = glfwGetClipboardString(NULL);
if (text)
{
insert_text(text);
@ -860,13 +860,9 @@ The contents of the system clipboard can be set to a UTF-8 encoded string with
@ref glfwSetClipboardString.
@code
glfwSetClipboardString(window, "A string with words in it");
glfwSetClipboardString(NULL, "A string with words in it");
@endcode
The clipboard functions take a window handle argument because some window
systems require a window to communicate with the system clipboard. Any valid
window may be used.
@section path_drop Path drop input

View File

@ -4655,7 +4655,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
* This function sets the system clipboard to the specified, UTF-8 encoded
* string.
*
* @param[in] window The window that will own the clipboard contents.
* @param[in] window Deprecated. Any valid window or `NULL`.
* @param[in] string A UTF-8 encoded string.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
@ -4684,7 +4684,7 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
* if its contents cannot be converted, `NULL` is returned and a @ref
* GLFW_FORMAT_UNAVAILABLE error is generated.
*
* @param[in] window The window that will request the clipboard contents.
* @param[in] window Deprecated. Any valid window or `NULL`.
* @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
* if an [error](@ref error_handling) occurred.
*

View File

@ -1740,7 +1740,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
updateCursorImage(window);
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];
@ -1750,7 +1750,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
forType:NSStringPboardType];
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];

View File

@ -1099,21 +1099,16 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(string != NULL);
_GLFW_REQUIRE_INIT();
_glfwPlatformSetClipboardString(window, string);
_glfwPlatformSetClipboardString(string);
}
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetClipboardString(window);
return _glfwPlatformGetClipboardString();
}
GLFWAPI double glfwGetTime(void)

View File

@ -647,8 +647,8 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string);
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window);
void _glfwPlatformSetClipboardString(const char* string);
const char* _glfwPlatformGetClipboardString(void);
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
void _glfwPlatformUpdateGamepadGUID(char* guid);

View File

@ -858,13 +858,13 @@ int _glfwPlatformGetKeyScancode(int key)
return _glfw.mir.scancodes[key];
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);

View File

@ -266,11 +266,11 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
{
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
return NULL;
}

View File

@ -1796,7 +1796,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
updateCursorImage(window);
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
int characterCount;
HANDLE object;
@ -1839,7 +1839,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
CloseClipboard();
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
HANDLE object;
WCHAR* buffer;

View File

@ -1008,14 +1008,14 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
}
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
// TODO
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Clipboard setting not implemented yet");
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
// TODO
_glfwInputError(GLFW_PLATFORM_ERROR,

View File

@ -2773,7 +2773,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
}
}
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
void _glfwPlatformSetClipboardString(const char* string)
{
free(_glfw.x11.clipboardString);
_glfw.x11.clipboardString = strdup(string);
@ -2791,7 +2791,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
}
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
const char* _glfwPlatformGetClipboardString(void)
{
return getSelectionString(_glfw.x11.CLIPBOARD);
}

View File

@ -67,7 +67,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
{
const char* string;
string = glfwGetClipboardString(window);
string = glfwGetClipboardString(NULL);
if (string)
printf("Clipboard contains \"%s\"\n", string);
else
@ -79,7 +79,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
if (mods == MODIFIER)
{
const char* string = "Hello GLFW World!";
glfwSetClipboardString(window, string);
glfwSetClipboardString(NULL, string);
printf("Setting clipboard to \"%s\"\n", string);
}
break;