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 ) ...@@ -163,35 +163,24 @@ void X11DragDrop::dndDrop( ldata_t data )
XGetWindowProperty( XDISPLAY, src, propAtom, 0, 1024, False, XGetWindowProperty( XDISPLAY, src, propAtom, 0, 1024, False,
AnyPropertyType, &type, &format, &nitems, &nbytes, AnyPropertyType, &type, &format, &nitems, &nbytes,
(unsigned char**)&buffer ); (unsigned char**)&buffer );
string selection = "";
if( buffer != NULL )
{
selection = buffer;
XFree( buffer );
}
if( selection != "" ) if( buffer != NULL )
{ {
// TODO: multiple files handling char* psz_dup = strdup( buffer );
string::size_type end = selection.find( "\n", 0 ); char* psz_new = psz_dup;
selection = selection.substr( 0, end - 1 ); while( psz_new && *psz_new )
end = selection.find( "\r", 0 );
selection = selection.substr( 0, end - 1 );
// Find the protocol, if any
if( selection.find( "file://", 0 ) == 0 )
{ {
selection.erase( 0, 7 ); char* psz_end = strchr( psz_new, '\n' );
} if( psz_end )
*psz_end = '\0';
char *psz_fileName = new char[selection.size() + 1];
strncpy( psz_fileName, selection.c_str(), selection.size() + 1 );
// Add the file CmdAddItem cmd( getIntf(), psz_new, m_playOnDrop );
CmdAddItem cmd( getIntf(), psz_fileName, m_playOnDrop ); cmd.execute();
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 // 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