RFR: 8333919: dragViewOffsetX/dragViewOffsetY are ignored for the dragView image [v2]

Jose Pereda jpereda at openjdk.org
Mon Aug 12 10:02:39 UTC 2024


On Fri, 9 Aug 2024 08:13:16 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:

>> When fixing [JDK-8233955](https://bugs.openjdk.org/browse/JDK-8233955) offset calculation was left out, which made Dragboard offset API not work on macOS.
>> 
>> This change fixes this mistake. Now drag image should be properly offset.
>
> Lukasz Kostyra has updated the pull request incrementally with one additional commit since the last revision:
> 
>   GlassViewDelegate: Correctly set origin and offset in dragImage
>   
>   - Centering to dragImage was removed - origin is now top-left of dragImage
>   - Offset direction was swapped

modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m line 1049:

> 1047:         if (image != nil)
> 1048:         {
> 1049:             // select the center of the image as the drag origin

The old comment about RT-17629 (https://bugs.openjdk.org/browse/JDK-8091965) does not apply anymore: after this PR, the offset, which comes from the Java layer, does adjust the drag image origin.

So I believe we can remove the whole comment as well (and possibly close RT-17629).

modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m line 1068:

> 1066: 
> 1067:                 dragPoint.x -= offset.x;
> 1068:                 dragPoint.y -= offset.y;

This works fine now, _if_ the offset values are smaller than the imageHalf X,Y values, which doesn't make sense anymore:

- If you drag from {0,0} (top-left), it works from that position
- But if you drag from {imageW, imageH} (bottom-right), the offset is clamped to the image centre, which it is not expected.

So now we need to change the above lines to clamp the offset between 0,0 and imageW,H (though Windows doesn't clamp the offset at all).

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1532#discussion_r1713448689
PR Review Comment: https://git.openjdk.org/jfx/pull/1532#discussion_r1713460897


More information about the openjfx-dev mailing list