<Swing Dev> Questionable Rendering of Disabled Text

Phil Race philip.race at oracle.com
Thu Nov 9 18:50:38 UTC 2017


Protocol is that there first be a bug report and then a "RFR" (request 
for review) is sent
to the list referencing the bug + the fix

I have filed https://bugs.openjdk.java.net/browse/JDK-8191041

and verified that it works. So we can perhaps short-circuit that this 
time .. but not next time ..

As to the blueprints path it looks safer to leave it since I don't know 
how to test it
so I would be happy to commit the patch as is but I think this opinion 
needs to be
reviewed by someone else on the list first ..

-phil.

On 11/03/2017 09:53 PM, Michael D wrote:
> Apologies, noticed I broke the patch between testing and submission.
>
> Correct and re-tested version
>
>
> --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
> +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
> @@ -47,34 +47,17 @@ class GTKGraphicsUtils extends SynthGraphicsUtils {
>               return;
>           }
>           int componentState = context.getComponentState();
> -        if ((componentState & SynthConstants.DISABLED) ==
> -                              SynthConstants.DISABLED){
> -            if (!GTKLookAndFeel.is3()) {
> -                Color orgColor = g.getColor();
> -                g.setColor(context.getStyle().getColor(context,
> -                        GTKColorType.WHITE));
> -                x += 1;
> -                y += 1;
> -                super.paintText(context, g, text, x, y, mnemonicIndex);
>
> -                g.setColor(orgColor);
> -                x -= 1;
> -                y -= 1;
> -            }
> -            super.paintText(context, g, text, x, y, mnemonicIndex);
> -        }
> -        else {
> -            String themeName = GTKLookAndFeel.getGtkThemeName();
> -            if (themeName != null && themeName.startsWith("blueprint") &&
> -                shouldShadowText(context.getRegion(), componentState)) {
> +        String themeName = GTKLookAndFeel.getGtkThemeName();
> +        if (themeName != null && themeName.startsWith("blueprint") &&
> +            shouldShadowText(context.getRegion(), componentState)) {
>
> -                g.setColor(Color.BLACK);
> -                super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
> -                g.setColor(Color.WHITE);
> -            }
> -
> -            super.paintText(context, g, text, x, y, mnemonicIndex);
> +            g.setColor(Color.BLACK);
> +            super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
> +            g.setColor(Color.WHITE);
>           }
> +
> +        super.paintText(context, g, text, x, y, mnemonicIndex);
>       }
>
>       /**
>
> On 4 November 2017 at 07:13, Michael D <me at md-5.net> wrote:
>> My bad,
>>
>> Patch just looks like this (bit messy because of indent change).
>> Thanks
>> Michael
>>
>>
>>
>>
>> --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
>> +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
>> @@ -46,35 +46,17 @@ class GTKGraphicsUtils extends SynthGraphicsUtils {
>>               // ignore this.
>>               return;
>>           }
>> -        int componentState = context.getComponentState();
>> -        if ((componentState & SynthConstants.DISABLED) ==
>> -                              SynthConstants.DISABLED){
>> -            if (!GTKLookAndFeel.is3()) {
>> -                Color orgColor = g.getColor();
>> -                g.setColor(context.getStyle().getColor(context,
>> -                        GTKColorType.WHITE));
>> -                x += 1;
>> -                y += 1;
>> -                super.paintText(context, g, text, x, y, mnemonicIndex);
>>
>> -                g.setColor(orgColor);
>> -                x -= 1;
>> -                y -= 1;
>> -            }
>> -            super.paintText(context, g, text, x, y, mnemonicIndex);
>> -        }
>> -        else {
>> -            String themeName = GTKLookAndFeel.getGtkThemeName();
>> -            if (themeName != null && themeName.startsWith("blueprint") &&
>> -                shouldShadowText(context.getRegion(), componentState)) {
>> +        String themeName = GTKLookAndFeel.getGtkThemeName();
>> +        if (themeName != null && themeName.startsWith("blueprint") &&
>> +            shouldShadowText(context.getRegion(), componentState)) {
>>
>> -                g.setColor(Color.BLACK);
>> -                super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
>> -                g.setColor(Color.WHITE);
>> -            }
>> -
>> -            super.paintText(context, g, text, x, y, mnemonicIndex);
>> +            g.setColor(Color.BLACK);
>> +            super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
>> +            g.setColor(Color.WHITE);
>>           }
>> +
>> +        super.paintText(context, g, text, x, y, mnemonicIndex);
>>       }
>>
>>       /**
>>
>> On 4 November 2017 at 06:39, Philip Race <philip.race at oracle.com> wrote:
>>> Yes these mailing lists strip attachements
>>> So an in-line patch .. or send directly to one of us to host it for you on
>>> cr.openjdk.java.net.
>>>
>>> -phil.
>>>
>>> On 11/3/17, 12:34 PM, Sergey Bylokhov wrote:
>>>> Hi, Michael.
>>>> It seems that the attached patch was removed from the email, can you
>>>> please provide a link to it or inline in email.
>>>> Thank you.
>>>>
>>>> On 03/11/2017 03:09, Michael D wrote:
>>>>> On 3 November 2017 at 21:07, Michael D <me at md-5.net> wrote:
>>>>>> Hi All,
>>>>>>
>>>>>> Last couple of days I've been trying to root out this bug -
>>>>>> https://bugs.launchpad.net/ubuntu/+source/openjdk-8/+bug/1729558 which
>>>>>> has resulted in poor looking rendering on my machine.
>>>>>> It turns out that the cause of this behavior is that Swing tries to do
>>>>>> its own magic disabled item rendering by turning the text white and
>>>>>> shifting it a pixel in each direction. I have no doubt there was
>>>>>> probably a good reason for this, however the file has remained
>>>>>> unchanged since its initial import in 2007! (Maybe someone from Oracle
>>>>>> can find out more)
>>>>>> Removing this code (patch attached) makes disabled menu items render
>>>>>> correctly in both light and dark GTK themes. Its completely trivial,
>>>>>> but I've nonetheless provided the patch for context. There is also
>>>>>> some adjacent code that references a metacity theme called "blueprint"
>>>>>> that also seems pre 2007 era, but I've left that in as I have no idea
>>>>>> of its context.
>>>>>>
>>>>>> Appreciate if this change / bug could be reviewed & discussed. In the
>>>>>> meantime I will also forward it downstream to Ubuntu as this is where
>>>>>> I encountered it / affects my usage.
>>>>>>
>>>>>> Thanks
>>>>>> Michael
>>>>
>>>>




More information about the swing-dev mailing list