<AWT Dev> RFR: 8257414: Drag n Drop target area is wrong on high DPI systems [v2]

Sergey Bylokhov serb at openjdk.java.net
Tue Feb 23 22:33:40 UTC 2021


On Fri, 12 Feb 2021 21:53:05 GMT, Olga Mikhaltsova <omikhaltcova at openjdk.org> wrote:

>> src/java.desktop/unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java line 618:
>> 
>>> 616:             try {
>>> 617:                 for (int i = 0; i < gdslen; i++) {
>>> 618:                     long screenRoot = XlibWrapper.RootWindow(display, i);
>> 
>> I am not sure this will work in the multi-monitors configuration when the screen is split across a few monitors(when Xinerama is enabled for example). In such a configuration, only one root window and only one X11 screen exist. And the index of the GraphicsDevice is the index of the "virtual" monitor, so you cannot pass this index to the "XlibWrapper.RootWindow".
>> 
>> A few questions:
>> * Are you sure that to scale the x/y in the device space you need to find where the pointer is located? And not where the x/y coordinates are located themselves?
>> * Did you try to iterate over the devices->downscale the bounds of each GD to the device scale and upscale the x/y using the selected device. Such utility method can be added to the SunGraphicsEnvironment
>
> Sergey, thanks for the hint! Hope I understand you right. Please, review my changes!
> 
> I decided to do necessary scaling in place and not to add an utility method to SunGraphicsEnvironment due to the following doubts: 
> the methods from SunGraphicsEnvironment can be called from different OS and I'm going to use GraphicsConfig::getBounds() but I see that the Unix implementation includes downscaling (X11GraphicsConfig::getBounds(), src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java) and the Windows one is not (Win32GraphicsConfig::getBounds(), src/java.desktop/windows/classes/sun/awt/Win32GraphicsConfig.java); 
> so for Unix I need upscaling before checking the point position but for Windows it is not needed. 
> Please, correct me if I'm wrong!
> 
> Concerning my previous implementation based on the cursor position, would you be so kind to take a look at XMouseInfoPeer::fillPointWithCoords(..) (src/java.desktop/unix/classes/sun/awt/X11/XMouseInfoPeer.java) in order to check whether it should be also fixed?

Yes, I think the fillPointWithCoords is also broken.

I'll run the tests for this change.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1907


More information about the awt-dev mailing list