Skip to content

Conversation

@Christopher-Hermann
Copy link
Contributor

@Christopher-Hermann Christopher-Hermann commented Jan 12, 2026

Resumption of #1690

Highlighting problem when using the dark theme on Windows eclipse-platform/eclipse.platform.swt#811

JFace viewer are using OS selection color to highlight the selected item. On some OS this is not accessible. In particular when the eclipse is used with dark theme and the OS is used with light theme, this can cause really bad UI/UX experience. With this change, the selection color can be changed via color preference in the settings of eclipse.

Example
Selection color on Windows Server in dark theme looks really bad:
272533915-9b63234a-6644-4174-9f2a-42b610eb5d66

Testing
On start up of eclipse, the selection colors in column viewers (table and tree viewer) should look like before.
On Windows, the dark theme should predefine the selection colors to fix the bad coloring on some Windows platforms.

In the preferences (Preferences > General > Appearance > Colors and Fonts), there are 4 new properties for the coloring of the viewer selection:

  • Basic > Viewer selection background (focused)
  • Basic > Viewer selection background (no focus)
  • Basic > Viewer selection foreground (focused)
  • Basic > Viewer selection foreground (no focus)
    Changing these colors should affect the coloring of the selection in viewers. The coloring should immediately be applied as soon as the apply button is confirmed. The reset button should reset the coloring to the OS specific highlight coloring, expect for Windows dark theme, where the predefined colors should be restored.

Fixes:
eclipse-platform/eclipse.platform.swt#811
#1688
#1956
#2780
#3570

See:
#1690
#2793

@Christopher-Hermann Christopher-Hermann marked this pull request as draft January 12, 2026 08:01
@Christopher-Hermann Christopher-Hermann changed the title Selection coloring [WIP] Selection coloring Jan 12, 2026
int customListenerCount = 0;
for (Listener listener : listeners) {
if (listener != this && listener != ownerDrawListener) {
customListenerCount++;
Copy link
Contributor

Choose a reason for hiding this comment

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

You could return immediately without counting all of them...

Copy link
Member

Choose a reason for hiding this comment

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

... or even rewrite it to use a more declarative idiom like:

return Arrays.stream(listeners).anyMatch(l -> l != this && l != ownerDrawListener);

@eclipse-platform-bot
Copy link
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.ui.themes/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 5392d25fa9fcd2a878559e10634aaca219731dc3 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Mon, 12 Jan 2026 08:07:38 +0000
Subject: [PATCH] Version bump(s) for 4.39 stream


diff --git a/bundles/org.eclipse.ui.themes/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.themes/META-INF/MANIFEST.MF
index a1a0eafd86..f9d231a384 100644
--- a/bundles/org.eclipse.ui.themes/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.themes/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.ui.themes;singleton:=true
-Bundle-Version: 1.2.2900.qualifier
+Bundle-Version: 1.2.3000.qualifier
 Bundle-Vendor: %Plugin.providerName
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.e4.ui.css.swt.theme
-- 
2.52.0

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

Test Results

0 files   -  3 015  0 suites   - 3 015   0s ⏱️ - 2h 7m 6s
0 tests  -  8 258  0 ✅  -  8 010  0 💤  - 248  0 ❌ ±0 
0 runs   - 23 598  0 ✅  - 22 807  0 💤  - 791  0 ❌ ±0 

Results for commit 606ad8c. ± Comparison against base commit e81ba1c.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Contributor

laeubi commented Jan 12, 2026

@Christopher-Hermann please use descriptive title and PR description and also adapt the commit message. It is impossible to understand without looking at the code what is actually done here.

Beside that, its always good to show before/after screenshot for visual changes.

@Christopher-Hermann
Copy link
Contributor Author

Added PR title & description. In the current state there are most probably some things left that needs to be cleaned up, tests are missing, etc.

But in the first place I wanted to share the coding with @fedejeanne to get the fix running on all operating systems.
In the last try there were a lot of issue especially for Linux that we need to solve...

@Christopher-Hermann Christopher-Hermann changed the title [WIP] Selection coloring [WIP] Proper selection coloring in JFace Structured Viewers Jan 12, 2026
@fedejeanne
Copy link
Member

@Christopher-Hermann thank you for retrying this!

As agreed, I tested on Linux and I found some of the problems that were already mentioned in #1956, namely:

  1. The Viewer selection foreground (no focus) does not apply in the package explorer (MANIFEST.MF) and in the Preferences (Colors and Fonts item)
Screenshot from 2026-01-13 13-45-24

This situation is worse with the default values since it's then white over white for non-focused elements (MANIFEST.MF in the package explorer)

image
  1. Icons go missing, both for the focused (orange) and the non-focused (light blue) elements
Screenshot from 2026-01-13 13-56-43

Comment on lines +47 to +49
* @see org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter
*/
public class ColumnViewerSelectionColorListener implements Listener {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @see org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter
*/
public class ColumnViewerSelectionColorListener implements Listener {
* @see org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter
* @since 3.39
*/
public class ColumnViewerSelectionColorListener implements Listener {

* to provide custom styling.
* </p>
*
* @since 3.32
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @since 3.32
* @since 3.39

});
handler.addPostSelectionListener(widgetSelectedAdapter(this::handlePostSelect));
handler.addOpenListener(StructuredViewer.this::handleOpen);
ColumnViewerSelectionColorListener.addListenerToViewer(this);
Copy link
Member

Choose a reason for hiding this comment

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

This line is causing the missing icons (problem Nr. 2 in my review)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mh damn, no clue why this is happening on Linux :(
This line is needed to get the ColumnViewerSelectionColorListener linked to the viewer. This listener is handling the drawing of the selection colors, so this is needed.

A really bad option would be to register the listener only on Windows. This would at least solve the issue on Windows and I guess on Linux we don't have the issue.

But I will have a look if I can figure out why the icons are missing on Linux

Copy link
Contributor Author

@Christopher-Hermann Christopher-Hermann Jan 13, 2026

Choose a reason for hiding this comment

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

@fedejeanne I adjusted the bounds of the back ground for better debugging. The background is now drawn with a offset of some pixel.
Maybe the fillBackground is drawing over the icons.
In case you have time, could you post a new screenshot?

Copy link
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

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

@Christopher-Hermann I now have some other odd behavior: I see half painted selections :-\

EDIT: I see the icons though, so that's good :-)

Here I changed the Viewer selection background (focused) from orange to green and Viewer selection background (no focus) to yellow and you can see that the selections still have a half-orange part, both the focused and the non-focused ones.

Image

// Remove SELECTED and BACKGROUND flags to prevent native drawing from overwriting our custom colors
event.detail &= ~(SWT.SELECTED | SWT.BACKGROUND);
// Note: On Linux/GTK, we must keep the SELECTED flag so that icons are still drawn
// We only remove BACKGROUND to prevent the native background from overwriting our custom colors
Copy link
Member

Choose a reason for hiding this comment

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

The comment is confusing, you are removing SELECTED in the line below

Comment on lines +184 to +187
int x = 0;
if (width > 50) {
x = 50;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why 50? Magic number?

Copy link
Member

Choose a reason for hiding this comment

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

Ach,silly me, it was right in the commit-text: Debugging: Draw background with offset. So yes, it's a magic "debug" number.

btw. I played with it and reducing it to 15 produces a half painted selection without icon so this is the problematic code spot:

image

int customListenerCount = 0;
for (Listener listener : listeners) {
if (listener != this && listener != ownerDrawListener) {
customListenerCount++;
Copy link
Member

Choose a reason for hiding this comment

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

... or even rewrite it to use a more declarative idiom like:

return Arrays.stream(listeners).anyMatch(l -> l != this && l != ownerDrawListener);

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.

5 participants