Skip to content

Set a dark background for the Variables view - #1788

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:variables_view_background
Open

tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:variables_view_background

Conversation

@tobiasmelcher

Copy link
Copy Markdown
Contributor

Variables View on MacOS flickers with white background in dark mode when variable nodes are expanded via the keyboard.
See screencast:

variable_viewer_white_background.mov

One can also see that the Variables View gets a white background after closing a debug session.
This pull request sets a dark background color for the Variables View in the css style settings so that the flickering disappears.

@akurtakov

Copy link
Copy Markdown
Member

@tobias-melcher Would you please try instead removing setBackground calls in

if (control.getBackground().equals(fSashForm.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND))) {
? IMO this flickering comes from background set once by the view and later overriden by the theme engine, if the view doesn't play with colors there shouldn't be flickering.
Please test in both light and dark.

@github-actions

github-actions Bot commented Mar 24, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   36m 0s ⏱️ - 2m 34s
 5 022 tests ±0   5 000 ✅ ±0   22 💤 ±0  0 ❌ ±0 
12 957 runs  ±0  12 803 ✅ ±0  154 💤 ±0  0 ❌ ±0 

Results for commit ee552ea. ± Comparison against base commit 2518f7f.

♻️ This comment has been updated with latest results.

@tobiasmelcher

tobiasmelcher commented Mar 24, 2025 •

Copy link
Copy Markdown
Contributor Author

@tobias-melcher Would you please try instead removing setBackground calls in

if (control.getBackground().equals(fSashForm.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND))) {

? IMO this flickering comes from background set once by the view and later overriden by the theme engine, if the view doesn't play with colors there shouldn't be flickering.
Please test in both light and dark.

I tried this. It was still flickering after removing both calls
fSashForm.setBackground(fSashForm.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
and
fSashForm.setBackground(fSashForm.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

I have seen that tree.setBackground() is called with null of the VariablesView by the CSS engine and I assume that his is making the problem. The flickering does not appear on Windows, only on MacOS. So, the SWT tree implementation for Mac behaves differently than on Windows regarding setBackground(null) call.

@tobiasmelcher

tobiasmelcher commented Mar 24, 2025 •

Copy link
Copy Markdown
Contributor Author
tree_background_color

I think I found it.

@Override
Color defaultBackground () {
	return display.getWidgetColor (SWT.COLOR_LIST_BACKGROUND);
}

Tree#defaultBackground returns a white color also when theme is set to dark.
If no CSS style is set, then CSSSWTColorHelper is calling tree.setBackgroundColor(null) with null as argument and therefore the white background color is taken.

Looking at the windows implementation doesn't make it more clear.

@Override
int defaultBackground () {
	return OS.GetSysColor (OS.COLOR_WINDOW);
}

Both implementations do not take theming into account. Is that good? I think no. What is your opinion? Or should display.getWidgetColor (SWT.COLOR_LIST_BACKGROUND); return a dark color in dark theme?

@vogella

vogella commented Mar 24, 2025

Copy link
Copy Markdown
Contributor

IIRC we also configure the SWT colors according to the theme but they are set to late during startup.

@azoitl tried to fix this a long time ago. See eclipse-platform/eclipse.platform.ui#259 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=577912

@tobiasmelcher

Copy link
Copy Markdown
Contributor Author

IIRC we also configure the SWT colors according to the theme but they are set to late during startup.

@azoitl tried to fix this a long time ago. See eclipse-platform/eclipse.platform.ui#259 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=577912

@vogella, could you please point me to the location where the Theming Engine is overriding the SWT.COLOR_LIST_BACKGROUND color for the dark mode. I cannot find it. Thanks a lot.

@BeckerWdf

Copy link
Copy Markdown
Member

IIRC we also configure the SWT colors according to the theme but they are set to late during startup.
@azoitl tried to fix this a long time ago. See eclipse-platform/eclipse.platform.ui#259 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=577912

@vogella, could you please point me to the location where the Theming Engine is overriding the SWT.COLOR_LIST_BACKGROUND color for the dark mode. I cannot find it. Thanks a lot.

I know of this location:
https://github.com/eclipse-platform/eclipse.platform.ui/blob/b6af990cac142bdba33768e29ec0d62482f0ba54/bundles/org.eclipse.ui.themes/css/dark/e4-dark_preferencestyle.css#L4

but there SWT.COLOR_LIST_BACKGROUND is not redefined.

@tobiasmelcher

Copy link
Copy Markdown
Contributor Author

flickering appears because the tree background color is sometimes set to white in the dark mode because of following CSS:

Tree[swt-lines-visible="true"]
background-color: unset;

org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper#setBackground is then called with color argument "null" and the SWT Tree implementation on MacOS then takes its default background color via display.getWidgetColor (SWT.COLOR_LIST_BACKGROUND); . I don't see a mechanism where the display widget colors are overridden by the CSS styles.

Unfortunately, I don't know in which CSS file this "background-color: unset;" is written down. There are too many CSS files.

@BeckerWdf

Copy link
Copy Markdown
Member

Unfortunately, I don't know in which CSS file this "background-color: unset;" is written down. There are too many CSS files.

It's here: https://github.com/eclipse-platform/eclipse.platform.ui/blob/b6af990cac142bdba33768e29ec0d62482f0ba54/bundles/org.eclipse.ui.themes/css/e4-dark_mac.css#L44

@tobiasmelcher

Copy link
Copy Markdown
Contributor Author

Unfortunately, I don't know in which CSS file this "background-color: unset;" is written down. There are too many CSS files.

It's here: https://github.com/eclipse-platform/eclipse.platform.ui/blob/b6af990cac142bdba33768e29ec0d62482f0ba54/bundles/org.eclipse.ui.themes/css/e4-dark_mac.css#L44

thanks so much. Removing

Tree[swt-lines-visible=true] {
	background-color: unset;
}

from bundles/org.eclipse.ui.themes/css/e4-dark_mac.css fixes the flickering problem. Do you know the reason why this was introduced?

@vogella

vogella commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

Unfortunately, I don't know in which CSS file this "background-color: unset;" is written down. There are too many CSS files.

from bundles/org.eclipse.ui.themes/css/e4-dark_mac.css fixes the flickering problem. Do you know the reason why this was introduced?

Maybe to handle an older now fixed bug in SWT Mac? If you do not see a bad impact in the light theme with this line removed, just send a PR to remove it. Maybe the same applies for the CSS for trees?

@tobiasmelcher

Copy link
Copy Markdown
Contributor Author

I removed

Table[swt-lines-visible=true] {
	background-color: unset;
}

Tree[swt-lines-visible=true] {
	background-color: unset;
}

from e4-dark_mac.css locally and did some testing. Unfortunately, the zebra style then disappears from the "Problems" and other views. So, this approach is not the way to go because zebra seems quite important in the dark theme.

I would therefore vote that we go with the approach of this pull request by explicitly setting a background color for the Variables view so that the white flickering while expanding tree nodes disappears. This white flickering hurts in the eyes and must be fixed from my point of view.
Please let me know if you have an alternative proposal which will also solve the flickering issue?

@BeckerWdf
BeckerWdf force-pushed the variables_view_background branch from 53794e6 to b9adeb0 Compare April 1, 2025 09:00
@BeckerWdf

Copy link
Copy Markdown
Member

windows build failure is unrelated.
Plan to merge tomorrow if nobody objects.

@BeckerWdf BeckerWdf added this to the 4.36 M1 milestone Apr 1, 2025
@BeckerWdf BeckerWdf added macOS happens on macOS bug Something isn't working usability and removed macOS happens on macOS labels Apr 1, 2025

#VariablesViewer {
font-family: '#org-eclipse-debug-ui-VariableTextFont';
background-color: #2F2F2F;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change causes a side effect: The tree in the variables view does then no longer have the zebra 🦓 lines.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interesting thing is that e.g. JDTs problems view also uses this zebra feature but does not have this flickering issue.

@akurtakov akurtakov removed this from the 4.36 M1 milestone Jun 6, 2025
@tobiasmelcher
tobiasmelcher force-pushed the variables_view_background branch from b9adeb0 to b9a2fb8 Compare November 19, 2026 17:02
@tobiasmelcher tobiasmelcher changed the title set background color for variables view in dark mode Set a dark background for the Variables view Nov 19, 2026
@tobiasmelcher
tobiasmelcher force-pushed the variables_view_background branch from b9a2fb8 to ee552ea Compare November 19, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants