RFR: 8355203: [macos] AquaButtonUI and AquaRootPaneUI repaint default button unnecessarily

Sergey Bylokhov serb at openjdk.org
Wed Apr 23 08:17:42 UTC 2025


On Wed, 23 Apr 2025 05:16:01 GMT, Jeremy Wood <duke at openjdk.org> wrote:

>> or default button appearance is different?
>
> 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;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24778#discussion_r2055504102


More information about the client-libs-dev mailing list