RFR: 8181084: JavaFX show big icons in system menu on macOS with Retina display [v7]

Jose Pereda jpereda at openjdk.org
Tue Jul 26 09:07:49 UTC 2022


On Mon, 25 Jul 2022 16:11:05 GMT, Paul <duke at openjdk.org> wrote:

>> I hit on JDK-8181084 while making some changes to Scene Builder, so I decided to investigate.
>> 
>> Please note: I have not done any Objective-C or MacOS development before. So I would really like some feedback from someone else who knows this stuff better.
>> 
>> Anyway, after some googling, I discovered that MacOS uses points values for measurements and not pixels, so the actual fix for this issue was this block in `GlassMenu.m`:-
>> 
>> 
>>             if ((sx > 1) && (sy > 1) && (width > 1) && (height > 1)) {
>>                 NSSize imgSize = {width / sx, height / sy};
>>                 [image setSize: imgSize];
>>             }
>> 
>> 
>> The rest of the changes were needed in order to get the `scaleX` and `scaleY` values down from `PixelUtils.java` into `GlassMenu.m`.
>> 
>> Before this fix:-
>> 
>> <img width="239" alt="Screenshot 2022-02-26 at 22 16 30" src="https://user-images.githubusercontent.com/437990/155880981-92163087-696b-4442-b047-845c276deb27.png">
>> 
>> After this fix:-
>> 
>> <img width="218" alt="Screenshot 2022-02-26 at 22 18 17" src="https://user-images.githubusercontent.com/437990/155880985-6bff0a06-9aee-4db2-b696-64730b0a6feb.png">
>
> Paul has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Removes trailing whitespace.

modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m line 269:

> 267:         if (image != NULL)
> 268:         {
> 269:             if ((jPixelsWidthField > 0)

Not that you need to remove them, but the parenthesis in `(xxx > 0)` are not needed

modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m line 397:

> 395:         return;
> 396:     }
> 397:     jclass pixelsClass = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacPixels" withEnv: env];

Probably it's just me, but I'd move this after the exiting menu field methods.

modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m line 419:

> 417:     if ((*env)->ExceptionCheck(env)) return;
> 418:     jPixelsScaleYField = (*env)->GetFieldID(env, pixelsClass, "scaley", "F");
> 419:     if ((*env)->ExceptionCheck(env)) return;

The last check is not needed, you are going to return either there is a pending exception or not.

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

PR: https://git.openjdk.org/jfx/pull/743


More information about the openjfx-dev mailing list