mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 15:44:35 +00:00
Simplified string storage.
This commit is contained in:
parent
0ee55ab8e5
commit
0e9e37bfc4
@ -97,21 +97,11 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
|||||||
{
|
{
|
||||||
size_t size = strlen(string) + 1;
|
size_t size = strlen(string) + 1;
|
||||||
|
|
||||||
// Allocate memory to keep track of the clipboard
|
// Store the new string in preparation for a request event
|
||||||
char* cb = malloc(size);
|
free(_glfwLibrary.X11.selection.string);
|
||||||
|
_glfwLibrary.X11.selection.string = malloc(size);
|
||||||
// Copy the clipboard data
|
|
||||||
memcpy(cb, string, size);
|
|
||||||
|
|
||||||
// Set the string length
|
|
||||||
_glfwLibrary.X11.selection.stringLength = size;
|
_glfwLibrary.X11.selection.stringLength = size;
|
||||||
|
memcpy(_glfwLibrary.X11.selection.string, string, size);
|
||||||
// Check if existing clipboard memory needs to be freed
|
|
||||||
if (_glfwLibrary.X11.selection.string)
|
|
||||||
free(_glfwLibrary.X11.selection.string);
|
|
||||||
|
|
||||||
// Now set the clipboard (awaiting the event SelectionRequest)
|
|
||||||
_glfwLibrary.X11.selection.string = cb;
|
|
||||||
|
|
||||||
// Set the selection owner to our active window
|
// Set the selection owner to our active window
|
||||||
XSetSelectionOwner(_glfwLibrary.X11.display, XA_PRIMARY,
|
XSetSelectionOwner(_glfwLibrary.X11.display, XA_PRIMARY,
|
||||||
|
Loading…
Reference in New Issue
Block a user