mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-27 04:28:52 -05:00
Formatting.
This commit is contained in:
parent
508207ae04
commit
168aba78d4
|
@ -47,7 +47,9 @@
|
||||||
|
|
||||||
Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
|
Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
|
||||||
{
|
{
|
||||||
Atom* atoms = _glfwLibrary.X11.selection.atoms.string;
|
Atom* formats = _glfwLibrary.X11.selection.atoms.string;
|
||||||
|
char* target = _glfwLibrary.X11.selection.clipboard.string;
|
||||||
|
|
||||||
if (request->target == XA_STRING)
|
if (request->target == XA_STRING)
|
||||||
{
|
{
|
||||||
// TODO: ISO Latin-1 specific characters don't get converted
|
// TODO: ISO Latin-1 specific characters don't get converted
|
||||||
|
@ -58,11 +60,11 @@ Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
|
||||||
request->target,
|
request->target,
|
||||||
8,
|
8,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(unsigned char*) _glfwLibrary.X11.selection.clipboard.string,
|
(unsigned char*) target,
|
||||||
8);
|
8);
|
||||||
}
|
}
|
||||||
else if (request->target == atoms[_GLFW_STRING_ATOM_COMPOUND] ||
|
else if (request->target == formats[_GLFW_STRING_ATOM_COMPOUND] ||
|
||||||
request->target == atoms[_GLFW_STRING_ATOM_UTF8])
|
request->target == formats[_GLFW_STRING_ATOM_UTF8])
|
||||||
{
|
{
|
||||||
XChangeProperty(_glfwLibrary.X11.display,
|
XChangeProperty(_glfwLibrary.X11.display,
|
||||||
request->requestor,
|
request->requestor,
|
||||||
|
@ -70,7 +72,7 @@ Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
|
||||||
request->target,
|
request->target,
|
||||||
8,
|
8,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(unsigned char*) _glfwLibrary.X11.selection.clipboard.string,
|
(unsigned char*) target,
|
||||||
_glfwLibrary.X11.selection.clipboard.stringlen);
|
_glfwLibrary.X11.selection.clipboard.stringlen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -91,14 +93,14 @@ Atom _glfwSelectionRequest(XSelectionRequestEvent* request)
|
||||||
// Set the clipboard contents
|
// Set the clipboard contents
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwPlatformSetClipboardData(void *data, size_t size, int format)
|
void _glfwPlatformSetClipboardData(void* data, size_t size, int format)
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case GLFW_CLIPBOARD_FORMAT_STRING:
|
case GLFW_CLIPBOARD_FORMAT_STRING:
|
||||||
{
|
{
|
||||||
// Allocate memory to keep track of the clipboard
|
// Allocate memory to keep track of the clipboard
|
||||||
char *cb = malloc(size+1);
|
char* cb = malloc(size + 1);
|
||||||
|
|
||||||
// Copy the clipboard data
|
// Copy the clipboard data
|
||||||
memcpy(cb, data, size);
|
memcpy(cb, data, size);
|
||||||
|
@ -135,10 +137,10 @@ void _glfwPlatformSetClipboardData(void *data, size_t size, int format)
|
||||||
// Return the current clipboard contents
|
// Return the current clipboard contents
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
size_t _glfwPlatformGetClipboardData(void *data, size_t size, int format)
|
size_t _glfwPlatformGetClipboardData(void* data, size_t size, int format)
|
||||||
{
|
{
|
||||||
size_t len, rembytes, dummy;
|
size_t len, rembytes, dummy;
|
||||||
unsigned char *d;
|
unsigned char* d;
|
||||||
int fmt;
|
int fmt;
|
||||||
Atom type;
|
Atom type;
|
||||||
|
|
||||||
|
@ -200,20 +202,31 @@ size_t _glfwPlatformGetClipboardData(void *data, size_t size, int format)
|
||||||
// The number of bytes remaining (which is all of them)
|
// The number of bytes remaining (which is all of them)
|
||||||
if (rembytes > 0)
|
if (rembytes > 0)
|
||||||
{
|
{
|
||||||
int result = XGetWindowProperty(_glfwLibrary.X11.display, window,
|
int result = XGetWindowProperty(_glfwLibrary.X11.display,
|
||||||
*xfmt, 0, rembytes, 0,
|
window,
|
||||||
AnyPropertyType, &type, &fmt,
|
*xfmt,
|
||||||
&len, &dummy, &d);
|
0, rembytes,
|
||||||
|
0,
|
||||||
|
AnyPropertyType,
|
||||||
|
&type,
|
||||||
|
&fmt,
|
||||||
|
&len, &dummy,
|
||||||
|
&d);
|
||||||
if (result == Success)
|
if (result == Success)
|
||||||
{
|
{
|
||||||
size_t s = size - 1 > rembytes ? rembytes : size - 1;
|
size_t s;
|
||||||
|
|
||||||
|
if (rembytes < size - 1)
|
||||||
|
s = rembytes;
|
||||||
|
else
|
||||||
|
s = size - 1;
|
||||||
|
|
||||||
// Copy the data out.
|
// Copy the data out.
|
||||||
memcpy(data, d, s);
|
memcpy(data, d, s);
|
||||||
|
|
||||||
// Null-terminate strings.
|
// Null-terminate strings.
|
||||||
if (format == GLFW_CLIPBOARD_FORMAT_STRING)
|
if (format == GLFW_CLIPBOARD_FORMAT_STRING)
|
||||||
((char *)data)[s] = '\0';
|
((char*) data)[s] = '\0';
|
||||||
|
|
||||||
// Free the data allocated using X11.
|
// Free the data allocated using X11.
|
||||||
XFree(d);
|
XFree(d);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user