Skip to content

Commit

Permalink
Add system property to override inheritance of OS dark theme. #185
Browse files Browse the repository at this point in the history
- Still enabled by default, for backward compatibility.
- To disable, set the new property:
  org.eclipse.e4.ui.css.theme.disableOSDarkThemeInherit=true
  • Loading branch information
dhendriks authored and akurtakov committed Sep 6, 2022
1 parent 5686600 commit f7af9f0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public class ThemeEngine implements IThemeEngine {

public static final String E4_DARK_THEME_ID = "org.eclipse.e4.ui.css.theme.e4_dark";

public static final String DISABLE_OS_DARK_THEME_INHERIT = "org.eclipse.e4.ui.css.theme.disableOSDarkThemeInherit";

public ThemeEngine(Display display) {
this.display = display;

Expand Down Expand Up @@ -612,11 +614,12 @@ public void restore(String alternateTheme) {
/*
* Any Platform: if the system has Dark appearance set and Eclipse is using the
* default settings, then start Eclipse in Dark theme. Check that there is a
* dark theme present.
* dark theme present. Can be disabled using a system property.
*/
boolean hasDarkTheme = getThemes().stream().anyMatch(t -> t.getId().startsWith(E4_DARK_THEME_ID));
String themeToRestore = Display.isSystemDarkTheme() && hasDarkTheme ? E4_DARK_THEME_ID : alternateTheme;
if (themeToRestore != null && flag) {
boolean disableOSDarkThemeInherit = "true".equalsIgnoreCase(System.getProperty(DISABLE_OS_DARK_THEME_INHERIT));
if (themeToRestore != null && flag && !disableOSDarkThemeInherit) {
setTheme(themeToRestore, false);
}
}
Expand Down

0 comments on commit f7af9f0

Please sign in to comment.