FileDragAndDropTarget on scaled display


Hello new friends.

I think the os -> window drag and drop behaviour might suffer the same issues as previously found on windows when using a display with scaling enabled. The coordinates supplied to e.g fileDragMove are off. Adding the suggested workaround from the previous issue on windows:

    const Displays::Display &mainDisplay = Desktop::getInstance().getDisplays().getMainDisplay();
    const float scale = 1.f / mainDisplay.scale;
    dropPos = dropPos.transformedBy(AffineTransform::scale(scale)).roundToInt();

to juce_linux_X11_Windowing.cpp does seem to fix the problem.
But i assume more care is needed to handle multiple displays etc.

What do you think ?


There’s a few helper methods for converting between physical and logical pixels in the Displays class (it’s not as easy as it seems!).

Does changing line 3060 of juce_linux_X11_Windowing.cpp to the following fix the issue?

Point<int> dropPos ((int)[2] >> 16,
                    (int)[2] & 0xffff);

dropPos = Desktop::getInstance().getDisplays().physicalToLogical (dropPos);
dropPos -= bounds.getPosition();

Yes, that seems to work


Great, I’ll get that pushed shortly.