Simplified clipboard cache layout.

This commit is contained in:
Camilla Berglund 2012-04-09 15:27:32 +02:00
parent b8676f01db
commit fcd67c69ec
3 changed files with 10 additions and 12 deletions

View File

@ -48,7 +48,7 @@
Atom _glfwSelectionRequest(XSelectionRequestEvent* request) Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
{ {
Atom* formats = _glfwLibrary.X11.selection.formats; Atom* formats = _glfwLibrary.X11.selection.formats;
char* target = _glfwLibrary.X11.selection.clipboard.string; char* target = _glfwLibrary.X11.selection.string;
if (request->target == XA_STRING) if (request->target == XA_STRING)
{ {
@ -73,7 +73,7 @@ Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
8, 8,
PropModeReplace, PropModeReplace,
(unsigned char*) target, (unsigned char*) target,
_glfwLibrary.X11.selection.clipboard.stringlen); _glfwLibrary.X11.selection.stringLength);
} }
else else
{ {
@ -106,14 +106,14 @@ void _glfwPlatformSetClipboardData(void* data, size_t size, int format)
memcpy(cb, data, size); memcpy(cb, data, size);
// Set the string length // Set the string length
_glfwLibrary.X11.selection.clipboard.stringlen = size; _glfwLibrary.X11.selection.stringLength = size;
// Check if existing clipboard memory needs to be freed // Check if existing clipboard memory needs to be freed
if (_glfwLibrary.X11.selection.clipboard.string) if (_glfwLibrary.X11.selection.string)
free(_glfwLibrary.X11.selection.clipboard.string); free(_glfwLibrary.X11.selection.string);
// Now set the clipboard (awaiting the event SelectionRequest) // Now set the clipboard (awaiting the event SelectionRequest)
_glfwLibrary.X11.selection.clipboard.string = cb; _glfwLibrary.X11.selection.string = cb;
break; break;
} }

View File

@ -632,8 +632,8 @@ int _glfwPlatformTerminate(void)
#endif #endif
// Free clipboard memory // Free clipboard memory
if (_glfwLibrary.X11.selection.clipboard.string) if (_glfwLibrary.X11.selection.string)
free(_glfwLibrary.X11.selection.clipboard.string); free(_glfwLibrary.X11.selection.string);
return GL_TRUE; return GL_TRUE;
} }

View File

@ -232,10 +232,8 @@ typedef struct _GLFWlibraryX11
struct { struct {
Atom atom; Atom atom;
Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT]; Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];
struct { size_t stringLength;
size_t stringlen;
char* string; char* string;
} clipboard;
Atom request; Atom request;
int converted; int converted;
} selection; } selection;