On Wed, 3 Jan 2024 03:33:05 GMT, Martin Fox <m...@openjdk.org> wrote:

>> When reporting input method candidate position the code in 
>> GlassViewEventHandler is not applying the platform scale factors. This is 
>> causing incorrect IM positions to be reported to glass on hi-dpi monitors.
>> 
>> This PR a no-op on Mac since the platform scale factors are always 1.0. I 
>> don't think it affects the current Linux XIM code at all but XIM is so 
>> out-of-date it has become difficult to test. PR #1080 will replace the old 
>> XIM code and needs this fix to work properly on hi-dpi screens.
>
> Martin Fox has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Reverting file

This works fine for a single screen, but not for multiple screens. Also, it 
isn't sufficient to multiply the x and y by the platform scale for screens that 
don't touch the origin of the virtual screen space. See [this comment in PR 
#853](https://github.com/openjdk/jfx/pull/853#issuecomment-1206747079). I left 
inline comments with what I think needs to be changed.

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassViewEventHandler.java
 line 672:

> 670:     public double[] getInputMethodCandidatePos(int offset) {
> 671:         Point2D p2d = scene.inputMethodRequests.getTextLocation(offset);
> 672:         final Screen s = Screen.getMainScreen();

This won't work for multiple screens. You'll need something like 
`scene.getPlatformView().getWindow().getScreen()` (with the appropriate null 
checks).

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassViewEventHandler.java
 line 677:

> 675:         double[] ret = new double[2];
> 676:         ret[0] = p2d.getX() * pScaleX;
> 677:         ret[1] = p2d.getY() * pScaleY;

You should use `Screen::toPlatformX/Y` or it won't work for all screen 
arrangements.

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

PR Review: https://git.openjdk.org/jfx/pull/1311#pullrequestreview-1803016057
PR Review Comment: https://git.openjdk.org/jfx/pull/1311#discussion_r1440905659
PR Review Comment: https://git.openjdk.org/jfx/pull/1311#discussion_r1440906238

Reply via email to