1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Clarified clipboard format atom use.

This commit is contained in:
Camilla Berglund 2012-04-09 15:21:54 +02:00
parent 3252829fe0
commit b8676f01db
3 changed files with 15 additions and 16 deletions

View File

@ -47,7 +47,7 @@
Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
{
Atom* formats = _glfwLibrary.X11.selection.atoms.string;
Atom* formats = _glfwLibrary.X11.selection.formats;
char* target = _glfwLibrary.X11.selection.clipboard.string;
if (request->target == XA_STRING)
@ -63,8 +63,8 @@ Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
(unsigned char*) target,
8);
}
else if (request->target == formats[_GLFW_STRING_ATOM_COMPOUND] ||
request->target == formats[_GLFW_STRING_ATOM_UTF8])
else if (request->target == formats[_GLFW_CLIPBOARD_FORMAT_COMPOUND] ||
request->target == formats[_GLFW_CLIPBOARD_FORMAT_UTF8])
{
XChangeProperty(_glfwLibrary.X11.display,
request->requestor,
@ -147,11 +147,11 @@ size_t _glfwPlatformGetClipboardData(void* data, size_t size, int format)
// Get the currently active window
Window window = _glfwLibrary.activeWindow->X11.handle;
for (i = 0; i < _GLFW_STRING_ATOM_COUNT; i++)
for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++)
{
// Specify the format we would like.
_glfwLibrary.X11.selection.request =
_glfwLibrary.X11.selection.atoms.strings[i];
_glfwLibrary.X11.selection.formats[i];
// Convert the selection into a format we would like.
XConvertSelection(_glfwLibrary.X11.display,

View File

@ -461,11 +461,12 @@ static GLboolean initDisplay(void)
XInternAtom(_glfwLibrary.X11.display, "CLIPBOARD", False);
// Find or create selection atoms
_glfwLibrary.X11.selection.atoms.string[_GLFW_STRING_ATOM_UTF8] =
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_UTF8] =
XInternAtom(_glfwLibrary.X11.display, "UTF8_STRING", False);
_glfwLibrary.X11.selection.atoms.string[_GLFW_STRING_ATOM_COMPOUND] =
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_COMPOUND] =
XInternAtom(_glfwLibrary.X11.display, "COMPOUND_STRING", False);
_glfwLibrary.X11.selection.atoms.string[_GLFW_STRING_ATOM_STRING] = XA_STRING;
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_STRING] =
XA_STRING;
return GL_TRUE;
}

View File

@ -85,11 +85,11 @@
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryX11 X11
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX GLX
// String atoms
#define _GLFW_STRING_ATOM_UTF8 0
#define _GLFW_STRING_ATOM_COMPOUND 1
#define _GLFW_STRING_ATOM_STRING 2
#define _GLFW_STRING_ATOM_COUNT 3
// Clipboard format atom indices
#define _GLFW_CLIPBOARD_FORMAT_UTF8 0
#define _GLFW_CLIPBOARD_FORMAT_COMPOUND 1
#define _GLFW_CLIPBOARD_FORMAT_STRING 2
#define _GLFW_CLIPBOARD_FORMAT_COUNT 3
//========================================================================
// GLFW platform specific types
@ -231,9 +231,7 @@ typedef struct _GLFWlibraryX11
// Selection data
struct {
Atom atom;
struct {
Atom string[_GLFW_STRING_ATOM_COUNT];
} atoms;
Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];
struct {
size_t stringlen;
char *string;