mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-22 18:28:52 -05:00
Wayland: Clean up clipboard writing
This commit is contained in:
parent
ad4a9e42f0
commit
34418951cc
|
@ -1591,10 +1591,6 @@ static void dataSourceHandleSend(void* userData,
|
||||||
const char* mimeType,
|
const char* mimeType,
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
char* string = _glfw.wl.clipboardString;
|
|
||||||
size_t len = strlen(string);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (_glfw.wl.selectionSource != source)
|
if (_glfw.wl.selectionSource != source)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -1603,6 +1599,7 @@ static void dataSourceHandleSend(void* userData,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* string = _glfw.wl.clipboardString;
|
||||||
if (!string)
|
if (!string)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -1619,22 +1616,26 @@ static void dataSourceHandleSend(void* userData,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len > 0)
|
size_t length = strlen(string);
|
||||||
|
|
||||||
|
while (length > 0)
|
||||||
{
|
{
|
||||||
ret = write(fd, string, len);
|
const ssize_t result = write(fd, string, length);
|
||||||
if (ret == -1 && errno == EINTR)
|
if (result == -1)
|
||||||
continue;
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
{
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Error while writing the clipboard: %s",
|
"Wayland: Error while writing the clipboard: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
close(fd);
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
len -= ret;
|
|
||||||
string += ret;
|
length -= result;
|
||||||
|
string += result;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user