Skip to content

Use new SWT Display.setDarkThemePreferred() API for dark theme#3874

Draft
vogella wants to merge 3 commits intoeclipse-platform:masterfrom
vogella:use-swt-dark-theme-api
Draft

Use new SWT Display.setDarkThemePreferred() API for dark theme#3874
vogella wants to merge 3 commits intoeclipse-platform:masterfrom
vogella:use-swt-dark-theme-api

Conversation

@vogella
Copy link
Copy Markdown
Contributor

@vogella vogella commented Apr 8, 2026

Summary

Replace platform-specific dark theme processors (Win32, GTK, Cocoa) with the new cross-platform SWT API Display.setDarkThemePreferred(boolean) from eclipse-platform/eclipse.platform.swt#3184.

Changes

ThemeEngine (cross-platform)

  • Calls display.setDarkThemePreferred(isDark) directly in setTheme(), signaling the OS dark mode preference whenever the CSS theme changes.
  • Bumped SWT dependency to [3.134.0,4.0.0) for the new API.

IDEApplication (startup simplification)

  • Replaced manual dark styling (hardcoded colors, SWT.Show listeners, recursive style application on splash/workspace dialog) with a single display.setDarkThemePreferred(true) call during early startup.
  • Removed applyDarkStyles(), applyStylesRecursive(), and the isDark field.

Removed dark theme processor code from (bundles kept for later retirement):

  • org.eclipse.e4.ui.swt.win32DarkThemeProcessor using internal OS.setTheme()
  • org.eclipse.e4.ui.swt.gtkDarkThemeProcessor using internal OS.setDarkThemePreferred()
  • org.eclipse.e4.ui.workbench.renderers.swt.cocoaCocoaDarkThemeProcessor using internal OS.setTheme()

Cleaned up MANIFEST.MF imports, fragment.xml extensions, and removed the now-unnecessary Require-Bundle on org.eclipse.e4.ui.css.swt.theme from the cocoa bundle.

Note

⚠️ Will not compile yet as SWT 3.134 is not available via p2 repos. The platform-specific bundles are intentionally kept (with empty fragments) for later retirement.

Fixes #3857

vogella added 2 commits April 8, 2026 09:43
Replace platform-specific dark theme processors (Win32, GTK, Cocoa) with
the new cross-platform SWT API Display.setDarkThemePreferred(boolean).

The ThemeEngine now calls display.setDarkThemePreferred() directly when
a theme is set, signaling the dark mode preference to the OS for native
components like title bars, scrollbars, and native dialogs.

In IDEApplication, the manual dark styling (hardcoded colors, SWT.Show
listeners, recursive style application) is replaced with a single call
to display.setDarkThemePreferred(true) during early startup.

Dark theme processor code removed from:
- org.eclipse.e4.ui.swt.win32 (DarkThemeProcessor using OS.setTheme)
- org.eclipse.e4.ui.swt.gtk (DarkThemeProcessor using OS.setDarkThemePreferred)
- org.eclipse.e4.ui.workbench.renderers.swt.cocoa (CocoaDarkThemeProcessor using OS.setTheme)

The bundles themselves are kept for later retirement.

Fixes eclipse-platform#3857
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Test Results

0 files   -    852  0 suites   - 852   0s ⏱️ - 54m 54s
0 tests  -  7 894  0 ✅  -  7 651  0 💤  - 243  0 ❌ ±0 
0 runs   - 20 184  0 ✅  - 19 529  0 💤  - 655  0 ❌ ±0 

Results for commit 5de56c3. ± Comparison against base commit 06b47e7.

♻️ This comment has been updated with latest results.

@eclipse-platform-bot
Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.e4.ui.swt.gtk/META-INF/MANIFEST.MF
bundles/org.eclipse.e4.ui.swt.win32/META-INF/MANIFEST.MF
bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From ed7044275425e262fa4a238938edfaaeb04e3ad8 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Wed, 8 Apr 2026 10:31:54 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/bundles/org.eclipse.e4.ui.swt.gtk/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.swt.gtk/META-INF/MANIFEST.MF
index e6e792c72f..68fd639f3a 100644
--- a/bundles/org.eclipse.e4.ui.swt.gtk/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.swt.gtk/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %fragmentName
 Bundle-SymbolicName: org.eclipse.e4.ui.swt.gtk;singleton:=true
-Bundle-Version: 1.2.200.qualifier
+Bundle-Version: 1.2.300.qualifier
 Fragment-Host: org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-17
 Bundle-Localization: fragment-gtk
diff --git a/bundles/org.eclipse.e4.ui.swt.win32/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.swt.win32/META-INF/MANIFEST.MF
index 9795fd9215..2a570b89b4 100644
--- a/bundles/org.eclipse.e4.ui.swt.win32/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.swt.win32/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %fragmentName
 Bundle-SymbolicName: org.eclipse.e4.ui.swt.win32;singleton:=true
-Bundle-Version: 1.2.300.qualifier
+Bundle-Version: 1.2.400.qualifier
 Fragment-Host: org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-17
 Bundle-Localization: fragment-win32
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/META-INF/MANIFEST.MF
index e9ca00ec3b..7c8b35b838 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Eclipse-PlatformFilter: (osgi.ws=cocoa)
 Bundle-SymbolicName: org.eclipse.e4.ui.workbench.renderers.swt.cocoa;singleton:=true
-Bundle-Version: 0.14.600.qualifier
+Bundle-Version: 0.14.700.qualifier
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Fragment-Host: org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="[0.10.0,1.0.0)"
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Use new SWT API for native dark mode preference to simplify startup styling

2 participants