Commit 95848385 authored by Erwan Tulou's avatar Erwan Tulou

skins(Linux): add support for multiple files in drag&drap

selection is made of several items separated with '\n' and terminated with a final '\0'. When selection is limited to one item, the '\n' is missing.
parent 62cc24a8
......@@ -163,35 +163,24 @@ void X11DragDrop::dndDrop( ldata_t data )
XGetWindowProperty( XDISPLAY, src, propAtom, 0, 1024, False,
AnyPropertyType, &type, &format, &nitems, &nbytes,
(unsigned char**)&buffer );
string selection = "";
if( buffer != NULL )
{
selection = buffer;
XFree( buffer );
}
if( selection != "" )
if( buffer != NULL )
{
// TODO: multiple files handling
string::size_type end = selection.find( "\n", 0 );
selection = selection.substr( 0, end - 1 );
end = selection.find( "\r", 0 );
selection = selection.substr( 0, end - 1 );
// Find the protocol, if any
if( selection.find( "file://", 0 ) == 0 )
char* psz_dup = strdup( buffer );
char* psz_new = psz_dup;
while( psz_new && *psz_new )
{
selection.erase( 0, 7 );
}
char *psz_fileName = new char[selection.size() + 1];
strncpy( psz_fileName, selection.c_str(), selection.size() + 1 );
char* psz_end = strchr( psz_new, '\n' );
if( psz_end )
*psz_end = '\0';
// Add the file
CmdAddItem cmd( getIntf(), psz_fileName, m_playOnDrop );
CmdAddItem cmd( getIntf(), psz_new, m_playOnDrop );
cmd.execute();
delete[] psz_fileName;
psz_new = psz_end ? psz_end + 1 : NULL;
}
free( psz_dup );
XFree( buffer );
}
// Tell the source we accepted the drop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment