No immediate plans… Not being much of a linux guru, I often leave this kind of thing until people suggest bits of code as a starting point, because although it’s usually simple enough to write the code for windowing tasks, the almost total lack of documentation means that it can be a PITA to figure out where to begin.
Let’s start by reviewing the existing implementation. Looking at the JuceDemo->DnD, it’s not fully functional. Internal dnd works, but it doesn’t react to incoming files from external applications. After reviewing the specs (http://www.newplanetsoftware.com/xdnd/), working through juce_linux_Windowing.cpp and looking at a lot of code from other implementations, I think I’ve got it fixed with the patch below.
It has been tested successfully with the following filemanagers:
Dolphin (KDE default)[/]
Konqueror (older KDE/QT default)[/]
Nautilus (GNOME/GTK default)[/]
Thunar (XFCE/Enlightenment default)[/]
PCMan (LXDE default)[/]
Please let me know if you have any questions or comments.
I intend to continue by fixing TextDragAndDropTarget to actually receive text (like text/plain) and not treat it like incoming files. That might depend somewhat on your acceptance of the patch below, so I’ll be very grateful for a prompt review!
Oh and one more thing: Some implementations (read QT/KDE) don’t actually make the dragged filenames available until the very drop, so callbacks fileDragEnter/fileDragMove/fileDragExit promised at http://www.rawmaterialsoftware.com/api/classFileDragAndDropTarget.html may or may not be called during the DnD operation. In essence, they get called with GTK-based drag-sources, but not with QT-based.
Great, thank you. This is what I’m hoping to do for Linux DnD:
Complete the existing implementation
 Implement return of “silent rectangle” to XdndPosition messages (basically tells the source “as long as you stay within this rect, don’t bother sending XdndPosition messages unless your control keys change”).[/]
 Handle dropped url:s, like from Firefox[/]
 Handle dropped text (TextDragAndDropTarget)[/][/list] Hopefully
 Ability to act as Xdnd source, implement performExternalDragDropOfFiles() & performExternalDragDropOfText()[/][/list]
Suggestions and comments are very welcome. I also have a question:
During the DnD transaction, there is a negotiation of “Action”. Action is “what should I do once the file is received - copy it / move it / link to it /ask the user / private action”. Somewhat like right-dragging in MS Windows. My question: Is this implemented somewhere at all in JUCE, like callbacks or other info about suggested action after a file drop?
BTW, none of the patches you’ve posted have ever worked for me… They all just give me error messages when I try to apply them. It’s not a line-endings problem, is there a linux/mac format difference? (seems unlikely)
Just merged with tip including the fixes for Linux DnD (a25acde). There is one thing from my patch that I believe got lost: In order to receive other incoming text/uri-list than “file://…”, like www-urls dragged from a browser, the below patch (or something similar) needs to be applied.
[code]diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp
index a207b61…4c189a6 100644
@@ -2516,7 +2516,7 @@ private:
if (Atoms::isMimeTypeFile (dragAndDropCurrentMimeType))
for (int i = 0; i < lines.size(); ++i)
Yeah, I know, but for me to drop the file in and review the changes in my git client can’t go wrong, whereas the last time I tried to apply your diff, I wasted half an hour messing about with line-endings trying to make it work, then gave up and merged it all by hand…
Anyway, thanks for the changes, I’ll have a look asap!