Bug 543270 - Table/Tree sort column drawn white in Dark theme if backgroundControl has same color as the Table/Tree
Summary: Table/Tree sort column drawn white in Dark theme if backgroundControl has sam...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.11   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo, triaged
Depends on:
Blocks: 577357
  Show dependency tree
 
Reported: 2019-01-08 13:26 EST by Mike Marchand CLA
Modified: 2022-01-18 09:25 EST (History)
3 users (show)

See Also:


Attachments
Screenshot of Table with wrong sort column background color. (4.62 KB, image/png)
2019-01-08 13:26 EST, Mike Marchand CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Marchand CLA 2019-01-08 13:26:32 EST
Created attachment 277106 [details]
Screenshot of Table with wrong sort column background color.

This issue was discovered while working on a custom Dark theme for our product.

The issue arises when a Tree/Table and it's backgroundControl (from findBackgroundControl()) have the same background.

From CSSSWTColorHelper.java
/** Helper function to avoid setting colors unnecessarily */
public static void setBackground(Control control, Color newColor) {
	if (!equals(control.getBackground(), newColor)) {
		control.setBackground(newColor);
	}
}

If the newColor is the same color as the Tree's backgroundControl then we will never call control.setBackground() which will leave Control.background = -1.

Later when a Tree goes to render and it calls getSortColumnPixel(), that function does not look at the backgroundControl, it calls getBackgroundPixel() which looks directly at Control.background.  Since Control.background is -1, it will return OS.GetSysColor(OS.COLOR_WINDOW) which in my case was white.

I believe(am not certain) the fix is to fix getBackgroundPixel so that it looks at the backgroundControl's color.

The workaround was to force Trees and Tables to be a different color then other backgrounds in CSS.
Comment 1 Mike Marchand CLA 2019-01-08 15:10:34 EST
This issue exists on Linux as well.
Comment 2 Eric Williams CLA 2019-01-08 15:11:58 EST
(In reply to Mike Marchand from comment #1)
> This issue exists on Linux as well.

Which distribution and GTK3 version?
Comment 3 Mike Marchand CLA 2019-01-08 16:33:46 EST
It was a coworker's VM running 18.04.1 LTS, I am unsure which GTK version they were using.  I might be able to provide an update on that tomorrow.
Comment 4 Mike Marchand CLA 2019-01-09 10:54:42 EST
The gtk version is 3.22.30
Comment 5 Eric Williams CLA 2019-01-09 11:27:46 EST
Is it reproducible in a pure SWT snippet? If so, can you post it here?
Comment 6 Mike Marchand CLA 2020-05-07 15:37:28 EDT
I never followed up from your question.  At the time I was unable to get this to reproduce with a pure swt snippet.
Comment 7 Niraj Modi CLA 2022-01-18 09:24:37 EST
(In reply to Mike Marchand from comment #6)
> I never followed up from your question.  At the time I was unable to get
> this to reproduce with a pure swt snippet.

Also not reproducible in Eclipse dark-theme.
Marking as works for me.