RFR: 8155030: The Menu Mnemonics are always displayed for GTK LAF [v8]

Abhishek Kumar abhiscxk at openjdk.org
Mon Jun 24 07:24:15 UTC 2024


On Mon, 24 Jun 2024 06:21:51 GMT, Abhishek Kumar <abhiscxk at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java line 45:
>> 
>>> 43:     private SynthStyle style;
>>> 44:     static final AltProcessor altProcessor = new AltProcessor();
>>> 45:     static boolean altProcessorInstalledFlag;
>> 
>> Wouldn't it be easier to install `altProcessor` always in `SynthLookAndFeel.initialize` and to uninstall it in `SynthLookAndFeel.uninitialize` like it's done in `WindowsLookAndFeel`:
>> 
>> https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L197-L198
>> 
>> Then `altProcessor` would do nothing if the `RootPane.altPress` property isn't set or is `false`.
>> 
>> Requesting the value of `RootPane.altPress` from `UIManager` each time `postProcessKeyEvent` is called is inefficient, so you can store the value in `altProcessor` when look and feel is installed.
>> 
>> If `RootPane.altPress` can be changed dynamically, you can install a `PropertyChangeListener` to `UIManager`.
>
>> Wouldn't it be easier to install altProcessor always in SynthLookAndFeel.initialize and to uninstall it in SynthLookAndFeel.uninitialize like it's done in WindowsLookAndFeel:
> https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L197-L198
> Then altProcessor would do nothing if the RootPane.altPress property isn't set or is false.
> 
> In my initial fix, I added the `altProcessor` handler in `SynthLookAndFeel.initialize` with condition check for GTK L&F. Phil has suggested not to check for GTK L&F instead look for some alternate way like mentioned [here](https://github.com/openjdk/jdk/pull/18992#discussion_r1595782003).
> 
> Now I left with few options:
> 1. Install `altProcessor` handler similar to `WindowsLookAndFeel` implementation but that results in unnecessary installation of `alt handler for Nimbus L&F (derived from Synth L&F)` as well.
> 2. Add the `RootPane.altPress` condition check before installing the `altProcessor` handler but the value returned for `RootPane.altPress` is always **false** and that left with `altProcessor` handler uninstalled.
> 
> So, the handler implementation is moved to `SynthRootPaneUI`.

>Requesting the value of RootPane.altPress from UIManager each time postProcessKeyEvent is called is inefficient, so you can store the value in altProcessor when look and feel is installed.

I guess you are pointing out the code in SynthGraphicsUtils.paintText method where RootPane.altPress value is retrieved from UIManager each time. Storing the value in it's constructor doesn't reflect the correct value and is always `false`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18992#discussion_r1650472661


More information about the client-libs-dev mailing list