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

Kevin Rushforth kcr at openjdk.org
Sat Aug 10 17:28:35 UTC 2024


On Thu, 8 Aug 2024 16:01:59 GMT, Jose Pereda <jpereda 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.
>
> I'm testing this PR, and I see that on macOS the offsets are now taken into account. 
> 
> However, comparing to Windows the behaviour is different:
> 
> - On Windows, offset 0,0 means the cursor is at the most top-left coordinates of the dragView image. Setting positive offsets in x, y goes to the right and down of the image (which goes in line with the usual JavaFX coordinate system)
> 
> - On macOS, with this PR, offset 0, 0 is at the centre of the dragView image, and positive offsets go to the opposite direction
> 
> From the test attached to the issue, and with this PR:
> 
> 
> WritableImage snapshot = source.snapshot(null, null);
> 
> db.setDragView(snapshot);
> db.setDragViewOffsetX(0);
> 
> db.setDragViewOffsetY(0);
> 
> on Windows -> cursor at the most top-left corner of the dragView
> on macOS -> cursor at the centre of the dragView.
> 
> And:
> 
> WritableImage snapshot = source.snapshot(null, null);
> 
> db.setDragView(snapshot);
> db.setDragViewOffsetX(snapshot.getWidth() / 2);
> 
> db.setDragViewOffsetY(snapshot.getHeight() / 2);
> 
> on Windows -> cursor at the centre of the dragView
> on macOS -> cursor at the most top-left corner of the dragView.
> 
> So I'd say macOS should do the same as Windows, and for that you could try:
> 
> -            dragPoint.x -= ([image size].width/2.0f);
> -            dragPoint.y -= ([image size].height/2.0f);
> +            // dragPoint.x -= ([image size].width/2.0f);
> +            // dragPoint.y -= ([image size].height/2.0f);
> 
> -                dragPoint.x += offset.x;
> -               dragPoint.y += offset.y;
> +               dragPoint.x -= offset.x;
> +               dragPoint.y -= offset.y;
> 
> 
> Does that make sense to you?

Reviewers: @jperedadnr @kevinrushforth

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

PR Comment: https://git.openjdk.org/jfx/pull/1532#issuecomment-2282218190


More information about the openjfx-dev mailing list