|
|
|
@ -142,8 +142,7 @@ void _glfwPlatformSetClipboardData(void *data, size_t size, int format) |
|
|
|
|
XSetSelectionOwner(_glfwLibrary.X11.display, XA_PRIMARY, |
|
|
|
|
_glfwLibrary.activeWindow->X11.handle, CurrentTime); |
|
|
|
|
XSetSelectionOwner(_glfwLibrary.X11.display, |
|
|
|
|
_glfwLibrary.X11.selection.atoms.clipboard |
|
|
|
|
[_GLFW_CLIPBOARD_ATOM_CLIPBOARD], |
|
|
|
|
_glfwLibrary.X11.selection.atom, |
|
|
|
|
_glfwLibrary.activeWindow->X11.handle, CurrentTime); |
|
|
|
|
XFlush(_glfwLibrary.X11.display); |
|
|
|
|
} |
|
|
|
@ -162,44 +161,36 @@ size_t _glfwPlatformGetClipboardData(void *data, size_t size, int format) |
|
|
|
|
|
|
|
|
|
// Try different clipboards and formats that relate to the GLFW
|
|
|
|
|
// format with preference for more appropriate formats first
|
|
|
|
|
Atom *xcbrd = _glfwLibrary.X11.selection.atoms.clipboard; |
|
|
|
|
Atom *xcbrdend = _glfwLibrary.X11.selection.atoms.clipboard + |
|
|
|
|
_GLFW_CLIPBOARD_ATOM_COUNT; |
|
|
|
|
Atom *xfmt = getInternalFormat(format); |
|
|
|
|
Atom *xfmtend = xfmt + _GLFW_STRING_ATOM_COUNT; |
|
|
|
|
|
|
|
|
|
// Get the currently active window
|
|
|
|
|
Window window = _glfwLibrary.activeWindow->X11.handle; |
|
|
|
|
|
|
|
|
|
for ( ; xcbrd != xcbrdend; xcbrd++) |
|
|
|
|
for ( ; xfmt != xfmtend; xfmt++) |
|
|
|
|
{ |
|
|
|
|
for ( ; xfmt != xfmtend; xfmt++) |
|
|
|
|
{ |
|
|
|
|
// Specify the format we would like.
|
|
|
|
|
_glfwLibrary.X11.selection.request = *xfmt; |
|
|
|
|
|
|
|
|
|
// Convert the selection into a format we would like.
|
|
|
|
|
XConvertSelection(_glfwLibrary.X11.display, *xcbrd, |
|
|
|
|
*xfmt, None, window, CurrentTime); |
|
|
|
|
XFlush(_glfwLibrary.X11.display); |
|
|
|
|
// Specify the format we would like.
|
|
|
|
|
_glfwLibrary.X11.selection.request = *xfmt; |
|
|
|
|
|
|
|
|
|
// Process pending events until we get a SelectionNotify.
|
|
|
|
|
while (!_glfwLibrary.X11.selection.converted) |
|
|
|
|
_glfwPlatformWaitEvents(); |
|
|
|
|
// Convert the selection into a format we would like.
|
|
|
|
|
XConvertSelection(_glfwLibrary.X11.display, |
|
|
|
|
_glfwLibrary.X11.selection.atom, |
|
|
|
|
*xfmt, None, window, CurrentTime); |
|
|
|
|
XFlush(_glfwLibrary.X11.display); |
|
|
|
|
|
|
|
|
|
// Successful?
|
|
|
|
|
if (_glfwLibrary.X11.selection.converted == 1) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// Process pending events until we get a SelectionNotify.
|
|
|
|
|
while (!_glfwLibrary.X11.selection.converted) |
|
|
|
|
_glfwPlatformWaitEvents(); |
|
|
|
|
|
|
|
|
|
// Successful?
|
|
|
|
|
if (_glfwLibrary.X11.selection.converted == 1) |
|
|
|
|
{ |
|
|
|
|
_glfwLibrary.X11.selection.converted = 0; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Successful?
|
|
|
|
|
if (_glfwLibrary.X11.selection.converted == 1) |
|
|
|
|
_glfwLibrary.X11.selection.converted = 0; |
|
|
|
|
|
|
|
|
|
// Unsuccessful conversion, bail with no clipboard data
|
|
|
|
|
if (_glfwLibrary.X11.selection.converted) |
|
|
|
|
{ |
|
|
|
|