Commit 4ee6861f authored by Erwan Tulou's avatar Erwan Tulou

skins2(Linux): fix some drag&drop issues

On Linux, drag&drop provides a null-terminated character string, consisting of
one or more filenames. When there are more than one filename, either CR LF
(e.g Nautilus) or just LF (e.g Konqueror) are used as the sub delimiter.
This patch ensures that drag&drop now works for both cases.

In addition, if more than one item are selected, only the first item is
launched instead of all of them.
parent d9cdd294
......@@ -168,16 +168,28 @@ void X11DragDrop::dndDrop( ldata_t data )
{
char* psz_dup = strdup( buffer );
char* psz_new = psz_dup;
bool first = true;
while( psz_new && *psz_new )
{
char* psz_end = strchr( psz_new, '\n' );
if( psz_end )
int skip = 0;
const char* sep[] = { "\r\n", "\n", NULL };
for( int i = 0; sep[i]; i++ )
{
char* psz_end = strstr( psz_new, sep[i] );
if( !psz_end )
continue;
*psz_end = '\0';
skip = strlen( sep[i] );
break;
}
if( *psz_new )
{
bool playOnDrop = m_playOnDrop && first;
CmdAddItem( getIntf(), psz_new, playOnDrop ).execute();
first = false;
}
CmdAddItem cmd( getIntf(), psz_new, m_playOnDrop );
cmd.execute();
psz_new = psz_end ? psz_end + 1 : NULL;
psz_new += strlen( psz_new ) + skip;
}
free( psz_dup );
XFree( buffer );
......
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