RFR: 8355203: [macos] AquaButtonUI and AquaRootPaneUI repaint default button unnecessarily
Jeremy Wood
duke at openjdk.org
Wed Apr 23 18:15:11 UTC 2025
On Wed, 23 Apr 2025 08:15:14 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>> If I understand your question, I think the answer is:
>>
>> Yes, the State.DEFAULTBUTTON constant is necessary for default JButtons to render correctly.
>>
>> In case I misunderstood the question here is some additional context:
>>
>> The only place `DEFAULTBUTTON` is referenced is here:
>>
>> protected State getButtonState(final AbstractButton b, final ButtonModel model) {
>> if (!b.isEnabled()) return State.DISABLED;
>>
>> // The default button shouldn't draw its color when the window is inactive.
>> // Changed for <rdar://problem/3614421>: Aqua LAF Buttons are incorrectly drawn disabled
>> // all we need to do is make sure we aren't the default button any more and that
>> // we aren't active, but we still are enabled if the button is enabled.
>> // if we set dimmed we would appear disabled despite being enabled and click through
>> // works so this now matches the text drawing and most importantly the HIG
>> if (!AquaFocusHandler.isActive(b)) return State.INACTIVE;
>>
>> if (model.isArmed() && model.isPressed()) return State.PRESSED;
>> if (model.isSelected() && isSelectionPressing()) return State.PRESSED;
>> if ((b instanceof JButton) && ((JButton)b).isDefaultButton()) return State.DEFAULTBUTTON;
>>
>> return State.ACTIVE;
>> }
>>
>>
>> I tried removing the line that returned `DEFAULTBUTTON`, but then the test attached to this PR failed; the default button rendered like a generic Aqua JButton. So we still need some mechanism to make sure default buttons paint correctly. In this branch: that mechanism is State.DEFAULTBUTTON.
>
>>public static final State DEFAULTBUTTON = new State(_pulsed);
>
> This line maps the State.DEFAULTBUTTON constant to the _pulsed property in JRS (JRSUIProperties.h). Although _pulse is no longer supported, there does not seem to be a suitable alternative, so unfortunately we're still stuck with pulse forever.
>
>
> enum {
> kJRSUI_State_active = 1,
> kJRSUI_State_inactive = 2,
> kJRSUI_State_disabled = 3,
> kJRSUI_State_pressed = 4,
> kJRSUI_State_pulsed = 5,
> kJRSUI_State_rollover = 6,
> kJRSUI_State_drag = 7
> };
> typedef CFIndex JRSUIState;
Ah, thanks for identifying the problem.
Wait... is that still the correct file? When I search my machine for that file I get a path like:
`/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/JavaRuntimeSupport.framework/Versions/A/Headers/JRSUIProperties.h`
But I don't see a copy of that file for JDK v20 or higher.
Either way: any objections to my adding comments like these for posterity?
<img width="545" alt="image" src="https://github.com/user-attachments/assets/ec0ed40e-e876-4cb1-9b65-b93f35c6931b" />
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24778#discussion_r2056642928
More information about the client-libs-dev
mailing list