| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -47,31 +47,33 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					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
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // (yet). For cleanliness, would we need something like iconv?
 | 
					 | 
					 | 
					 | 
					        // (yet). For cleanliness, would we need something like iconv?
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        XChangeProperty(_glfwLibrary.X11.display, | 
					 | 
					 | 
					 | 
					        XChangeProperty(_glfwLibrary.X11.display, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            request->requestor, | 
					 | 
					 | 
					 | 
					                        request->requestor, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            request->target, | 
					 | 
					 | 
					 | 
					                        request->target, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            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, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            request->target, | 
					 | 
					 | 
					 | 
					                        request->target, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            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; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -158,7 +160,7 @@ size_t _glfwPlatformGetClipboardData(void *data, size_t size, int format) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Convert the selection into a format we would like.
 | 
					 | 
					 | 
					 | 
					        // Convert the selection into a format we would like.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        XConvertSelection(_glfwLibrary.X11.display, | 
					 | 
					 | 
					 | 
					        XConvertSelection(_glfwLibrary.X11.display, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          _glfwLibrary.X11.selection.atom, | 
					 | 
					 | 
					 | 
					                          _glfwLibrary.X11.selection.atom, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            *xfmt, None, window, CurrentTime); | 
					 | 
					 | 
					 | 
					                          *xfmt, None, window, CurrentTime); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        XFlush(_glfwLibrary.X11.display); | 
					 | 
					 | 
					 | 
					        XFlush(_glfwLibrary.X11.display); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Process pending events until we get a SelectionNotify.
 | 
					 | 
					 | 
					 | 
					        // Process pending events until we get a SelectionNotify.
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -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); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |