DragAndDropContainer::performExternalDragDropOfFile not working on Linux


performExternalDragDropOfFile does not work on Linux, it just hangs the application. Here is how to reproduce the issue:

If I add the following class inside the Juce “DragAndDropDemo” component:

    struct ExtDragComponent : public Component {
    void paint(Graphics &g) override { g.fillAll(Colours::yellow); }
    void mouseDrag(const MouseEvent &e) override {
        StringArray files; files.add("/path/to/file");
        std::cerr << "performExternalDragDropOfFiles!!\n";
        is_dragging = true;
        juce::DragAndDropContainer::performExternalDragDropOfFiles(files, false, this, nullptr);
    void mouseDoubleClick(const MouseEvent &e) override {
ExtDragComponent ext_drag;

And add it to the DragAndDropDemo component with:

        addAndMakeVisible(ext_drag); ext_drag.setBounds(300, 10, 100, 20);

Then the drag action on that component will trigger performExternalDragDropOfFiles on a file. This works fine on windows and macos, but on Linux it just grabs the mouse cursor, switch it to a ‘hand’ cursor and nothing happens. Since the cursor is grabbed, clicks outside the application do nothing and it is quite hard to exit the application, that’s why I added an exit call in mouseDoubleClick.

Thanks for reporting. I’ve merged a fix here:

1 Like

I works perfectly, thanks a lot !

1 Like