[vlc-commits] commit: skins2(Linux): fix some drag&drop issues (Erwan Tulou )

git at videolan.org git at videolan.org
Sun Jan 16 23:05:52 CET 2011


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Jan 16 22:21:01 2011 +0100| [4ee6861fcd4fb5a09b76952f1f0799b2d3f763e3] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4ee6861fcd4fb5a09b76952f1f0799b2d3f763e3
---

 modules/gui/skins2/x11/x11_dragdrop.cpp |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/modules/gui/skins2/x11/x11_dragdrop.cpp b/modules/gui/skins2/x11/x11_dragdrop.cpp
index c8db5f8..e811119 100644
--- a/modules/gui/skins2/x11/x11_dragdrop.cpp
+++ b/modules/gui/skins2/x11/x11_dragdrop.cpp
@@ -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 );



More information about the vlc-commits mailing list