spawn_window.c
static void sendSelectionNotify(Display *disp, XSelectionRequestEvent *selectionRequest, const char *pathStr)
{
	if (xdndState.xdndExchangeStarted && xdndState.amISource) {
		// Allocate buffer (two bytes at end for CR/NL and another for null byte)
		size_t sizeOfPropertyData = strlen("file://") + strlen(pathStr) + 3;
		char *propertyData = malloc(sizeOfPropertyData);
		if (!propertyData)
			philError("malloc");

		// Copy data to buffer
		strcpy(propertyData, "file://");
		strcat(propertyData, pathStr);
		propertyData[sizeOfPropertyData-3] = 0xD;
		propertyData[sizeOfPropertyData-2] = 0xA;
		propertyData[sizeOfPropertyData-1] = '\0';

		// Set property on target window - do not copy end null byte
		XChangeProperty(disp, selectionRequest->requestor, selectionRequest->property,
			typesWeAccept[0], 8, PropModeReplace, (unsigned char *)propertyData, sizeOfPropertyData-1);

		// Free property buffer
		free(propertyData);

		// Declare message struct and populate its values
		XEvent message;
		memset(&message, 0, sizeof(message));
		message.xselection.type = SelectionNotify;
		message.xselection.display = disp;
		message.xselection.requestor = selectionRequest->requestor;
		message.xselection.selection = selectionRequest->selection;
		message.xselection.target = selectionRequest->target;
		message.xselection.property = selectionRequest->property;
		message.xselection.time = selectionRequest->time;

		// Send it to target window
		if (XSendEvent(disp, selectionRequest->requestor, False, 0, &message) == 0)
			philError("XSendEvent");
	}
}
// This is sent by the source to the target to say the data is ready
This is sent by the source to the target to say the data is ready
This is sent by the source to the target to say the data is ready
static void sendSelectionNotify(Display *disp, XSelectionRequestEvent *selectionRequest, const char *pathStr)
{
	if (xdndState.xdndExchangeStarted && xdndState.amISource) {
		size_t sizeOfPropertyData = strlen("file://") + strlen(pathStr) + 3;
		char *propertyData = malloc(sizeOfPropertyData);
		if (!propertyData)
			philError("malloc");
		strcpy(propertyData, "file://");
		strcat(propertyData, pathStr);
		propertyData[sizeOfPropertyData-3] = 0xD;
		propertyData[sizeOfPropertyData-2] = 0xA;
		propertyData[sizeOfPropertyData-1] = '\0';
		XChangeProperty(disp, selectionRequest->requestor, selectionRequest->property,
			typesWeAccept[0], 8, PropModeReplace, (unsigned char *)propertyData, sizeOfPropertyData-1);
		free(propertyData);
		XEvent message;
		memset(&message, 0, sizeof(message));
		message.xselection.type = SelectionNotify;
		message.xselection.display = disp;
		message.xselection.requestor = selectionRequest->requestor;
		message.xselection.selection = selectionRequest->selection;
		message.xselection.target = selectionRequest->target;
		message.xselection.property = selectionRequest->property;
		message.xselection.time = selectionRequest->time;
		if (XSendEvent(disp, selectionRequest->requestor, False, 0, &message) == 0)
			philError("XSendEvent");
	}
}
static void sendSelectionNotify ( Display * disp , XSelectionRequestEvent * selectionRequest , const char * pathStr ) { if ( xdndState . xdndExchangeStarted && xdndState . amISource ) { size_t sizeOfPropertyData = strlen ( " " ) + strlen ( pathStr ) + 3 ; char * propertyData = malloc ( sizeOfPropertyData ) ; if ( ! propertyData ) philError ( " " ) ; strcpy ( propertyData , " " ) ; strcat ( propertyData , pathStr ) ; propertyData [ sizeOfPropertyData - 3 ] = 0xD ; propertyData [ sizeOfPropertyData - 2 ] = 0xA ; propertyData [ sizeOfPropertyData - 1 ] = ' \0 ' ; XChangeProperty ( disp , selectionRequest -> requestor , selectionRequest -> property , typesWeAccept [ 0 ] , 8 , PropModeReplace , ( unsigned char * ) propertyData , sizeOfPropertyData - 1 ) ; free ( propertyData ) ; XEvent message ; memset ( & message , 0 , sizeof ( message ) ) ; message . xselection . type = SelectionNotify ; message . xselection . display = disp ; message . xselection . requestor = selectionRequest -> requestor ; message . xselection . selection = selectionRequest -> selection ; message . xselection . target = selectionRequest -> target ; message . xselection . property = selectionRequest -> property ; message . xselection . time = selectionRequest -> time ; if ( XSendEvent ( disp , selectionRequest -> requestor , False , 0 , & message ) == 0 ) philError ( " " ) ; } }
This is sent by the source to the target to say the data is ready
This is sent by the source to the target to say the data is ready
// Allocate buffer (two bytes at end for CR/NL and another for null byte) // Copy data to buffer // Set property on target window - do not copy end null byte // Free property buffer // Declare message struct and populate its values // Send it to target window