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