mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Separated formats from targets.
This commit is contained in:
parent
dab22c4c53
commit
ae1532670c
@ -44,6 +44,10 @@
|
|||||||
Atom _glfwWriteSelection(XSelectionRequestEvent* request)
|
Atom _glfwWriteSelection(XSelectionRequestEvent* request)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||||
|
_glfw.x11.COMPOUND_STRING,
|
||||||
|
XA_STRING };
|
||||||
|
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
||||||
|
|
||||||
if (request->property == None)
|
if (request->property == None)
|
||||||
{
|
{
|
||||||
@ -55,14 +59,20 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
|
|||||||
{
|
{
|
||||||
// The list of supported targets was requested
|
// The list of supported targets was requested
|
||||||
|
|
||||||
|
const Atom targets[] = { _glfw.x11.TARGETS,
|
||||||
|
_glfw.x11.MULTIPLE,
|
||||||
|
_glfw.x11.UTF8_STRING,
|
||||||
|
_glfw.x11.COMPOUND_STRING,
|
||||||
|
XA_STRING };
|
||||||
|
|
||||||
XChangeProperty(_glfw.x11.display,
|
XChangeProperty(_glfw.x11.display,
|
||||||
request->requestor,
|
request->requestor,
|
||||||
request->property,
|
request->property,
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(unsigned char*) _glfw.x11.selection.formats,
|
(unsigned char*) targets,
|
||||||
_GLFW_CLIPBOARD_FORMAT_COUNT);
|
sizeof(targets) / sizeof(targets[0]));
|
||||||
|
|
||||||
return request->property;
|
return request->property;
|
||||||
}
|
}
|
||||||
@ -83,13 +93,13 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
|
|||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < _GLFW_CLIPBOARD_FORMAT_COUNT; j++)
|
for (j = 0; j < formatCount; j++)
|
||||||
{
|
{
|
||||||
if (targets[i] == _glfw.x11.selection.formats[j])
|
if (targets[i] == formats[j])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j < _GLFW_CLIPBOARD_FORMAT_COUNT)
|
if (j < formatCount)
|
||||||
{
|
{
|
||||||
XChangeProperty(_glfw.x11.display,
|
XChangeProperty(_glfw.x11.display,
|
||||||
request->requestor,
|
request->requestor,
|
||||||
@ -118,9 +128,9 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
|
|||||||
return request->property;
|
return request->property;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++)
|
for (i = 0; i < formatCount; i++)
|
||||||
{
|
{
|
||||||
if (request->target == _glfw.x11.selection.formats[i])
|
if (request->target == formats[i])
|
||||||
{
|
{
|
||||||
// The requested target is one we support
|
// The requested target is one we support
|
||||||
|
|
||||||
@ -165,6 +175,9 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
|||||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||||
|
_glfw.x11.COMPOUND_STRING,
|
||||||
|
XA_STRING };
|
||||||
|
|
||||||
if (_glfwFindWindowByHandle(XGetSelectionOwner(_glfw.x11.display,
|
if (_glfwFindWindowByHandle(XGetSelectionOwner(_glfw.x11.display,
|
||||||
_glfw.x11.CLIPBOARD)))
|
_glfw.x11.CLIPBOARD)))
|
||||||
@ -177,14 +190,14 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
|||||||
free(_glfw.x11.selection.string);
|
free(_glfw.x11.selection.string);
|
||||||
_glfw.x11.selection.string = NULL;
|
_glfw.x11.selection.string = NULL;
|
||||||
|
|
||||||
for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++)
|
for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++)
|
||||||
{
|
{
|
||||||
char* data;
|
char* data;
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
||||||
XConvertSelection(_glfw.x11.display,
|
XConvertSelection(_glfw.x11.display,
|
||||||
_glfw.x11.CLIPBOARD,
|
_glfw.x11.CLIPBOARD,
|
||||||
_glfw.x11.selection.formats[i],
|
formats[i],
|
||||||
_glfw.x11.selection.property,
|
_glfw.x11.selection.property,
|
||||||
window->x11.handle, CurrentTime);
|
window->x11.handle, CurrentTime);
|
||||||
|
|
||||||
|
@ -547,11 +547,6 @@ static GLboolean initDisplay(void)
|
|||||||
_glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
|
_glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
|
||||||
_glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
|
_glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
|
||||||
|
|
||||||
// Store clipboard format atoms in order of preference
|
|
||||||
_glfw.x11.selection.formats[0] = _glfw.x11.UTF8_STRING;
|
|
||||||
_glfw.x11.selection.formats[1] = _glfw.x11.COMPOUND_STRING;
|
|
||||||
_glfw.x11.selection.formats[2] = XA_STRING;
|
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,6 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
|
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
|
||||||
|
|
||||||
#define _GLFW_CLIPBOARD_FORMAT_COUNT 3
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW platform specific types
|
// GLFW platform specific types
|
||||||
@ -177,7 +175,6 @@ typedef struct _GLFWlibraryX11
|
|||||||
} timer;
|
} timer;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];
|
|
||||||
char* string;
|
char* string;
|
||||||
Atom property;
|
Atom property;
|
||||||
} selection;
|
} selection;
|
||||||
|
Loading…
Reference in New Issue
Block a user