Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 481122

Summary: [GTK3.18+] some set/get Background/Foreground color methods have no effect
Product: [Eclipse Project] Platform Reporter: Eric Williams <ericwill>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: adietish, mat.booth, mistria, peekpoker, snjezana.peco
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/61027
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=3dc220718412431322c00e1f820c9ce0168892f5
https://git.eclipse.org/r/61185
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ba37193032191f6c121bbbe35024e212582acf06
Whiteboard:
Bug Depends on:    
Bug Blocks: 474628    
Attachments:
Description Flags
Commit Dialog on GTK3.18 has incorrect colors none

Description Eric Williams CLA 2015-10-30 11:00:37 EDT
Created attachment 257656 [details]
Commit Dialog on GTK3.18 has incorrect colors

As of GTK3.18, gtk_widget_override_background_color() has been deprecated, along with several gtk_style_context_* functions, and GtkStateFlags.

This manifests itself differently across Eclipse, (bug 479998 is one example).

Attached is a screenshot showing the issue in the Commit Dialog, but there are other examples (Progress view, Run Configurations, etc.)

I believe the solution is to set background/foreground colors using CSS individually in each Widget, but I will investigate this further. Fetching the colors (i.e. getBackgroundColor(), etc.) will need to be updated also, as gtk_style_context_get_background_color() (as an example) is deprecated.
Comment 1 Eric Williams CLA 2015-10-30 14:32:28 EDT
Note, this is also responsible for 6 additional JUnit tests to fail.
Comment 2 Eric Williams CLA 2015-11-05 13:44:12 EST
(In reply to Eric Williams from comment #1)
> Note, this is also responsible for 6 additional JUnit tests to fail.

I did some investigation regarding this matter and it can be broken down in the following manner:

There are 8 additional tests that fail. They are all either setBackground() or setForeground() tests. Of these, there are two kinds of failure I am seeing.

1) Fetching a color: this happens only with setForeground() where a color will be set, but an entirely different color will be fetched when using getForeground(). This test failed once on GTK3.16 with setBackground(), but never with setForeground(). 

2) Setting a (background or foreground) color to null: this is supposed to reset the control's background/foreground color to the system default. On numerous occasions this test fails on GTK3.18.

(In reply to Eric Williams from comment #0)
> I believe the solution is to set background/foreground colors using CSS
> individually in each Widget, but I will investigate this further.

This approach doesn't seem to work.
Comment 3 Mickael Istria CLA 2015-11-13 01:44:08 EST
I would like to raise the importance of this issue as it currently prevents from showing Eclipse IDE working on recent GTK without having this ugly and highly visible issue.

Isn't this issue related to transparency of some composites?
Comment 4 Mat Booth CLA 2015-11-13 05:59:56 EST
Downstream bug: https://bugzilla.redhat.com/show_bug.cgi?id=1269892
Comment 5 Eric Williams CLA 2015-11-13 08:31:54 EST
(In reply to Mickael Istria from comment #3)
> I would like to raise the importance of this issue as it currently prevents
> from showing Eclipse IDE working on recent GTK without having this ugly and
> highly visible issue.
> 
> Isn't this issue related to transparency of some composites?

Not exactly. Currently in SWT we use gtk_widget_override_background_color() to set background colors for Widgets when the public method setBackground() is called.

As of GTK3.16 this function is deprecated and is broken as of GTK3.18. This means that it does not work reliably and thus results in these background color issues. I am currently working on a fix using CSS and it's at the top of my to-do list.
Comment 6 Eclipse Genie CLA 2015-11-23 11:29:13 EST
New Gerrit change created: https://git.eclipse.org/r/61027
Comment 7 Eric Williams CLA 2015-11-23 14:57:30 EST
(In reply to Eclipse Genie from comment #6)
> New Gerrit change created: https://git.eclipse.org/r/61027

This Gerrit change eliminates the failing set/getForegroundColor() test cases. The solution is outlined in this blog post, under the section "What do you have to do?": https://blogs.gnome.org/mclasen/2015/11/20/a-gtk-update/

Please note that this only fixes foreground color issues, and that the background color bug is still present in GTK3.18+.
Comment 9 Eclipse Genie CLA 2015-11-24 14:18:19 EST
New Gerrit change created: https://git.eclipse.org/r/61185
Comment 10 Eric Williams CLA 2015-11-24 14:23:49 EST
(In reply to Eclipse Genie from comment #9)
> New Gerrit change created: https://git.eclipse.org/r/61185

This change is just to fix a simple typo from the original patch.
Comment 12 Snjezana Peco CLA 2015-12-06 05:41:56 EST
*** Bug 483706 has been marked as a duplicate of this bug. ***
Comment 13 Eric Williams CLA 2015-12-07 09:38:40 EST
I'm going to mark this fixed as the failing tests are resolved, and forms/wizards now have their correct background colors.

For the replacement/removal of gtk_widget_override_background_color() and gtk_widget_override_color(), please see bug 483096 and bug 483097, respectively.
Comment 14 Michael CLA 2015-12-08 13:03:12 EST
Now that this has been addressed, is there any chance the fix will be available sometime in the current stable Mars release, or will those using gtk 3.18 need to wait until 4.6 in ~6 months? Thanks
Comment 15 Eric Williams CLA 2015-12-10 08:51:23 EST
(In reply to Michael from comment #14)
> Now that this has been addressed, is there any chance the fix will be
> available sometime in the current stable Mars release, or will those using
> gtk 3.18 need to wait until 4.6 in ~6 months? Thanks

I don't see any issues backporting this fix to Mars. I'll make a patch.