Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-dev] Display.getSystemColor() returns different color in Dark Theme depending on when it is called

Hi,

I hope I'm at the right place for my question.

I'm working on the Eclipse 4diac project and there we have an RCP utilizing the org.eclipse.ui.ide.workbench as main application. Once in a while I'm
experimenting with switching it int dark mode. However certain widgets always got not the correct color even after restart. I may have to add here that we are
using a lot GEF3 which is not visible in the E4 model and therefore to my knowledge currently not to address from CSS.

What I somehow noticed is that in these editors I also use the Display.getSystemColor() as an easy way to get to certain widget colors. And that when an editor
was open and Eclipse is restarted I get from getSystemColor() the color from the light (default) theme. However when I closed the editor and reopend it I
suddenly got the dark theme's color and everything looked right.

So this got me curios and I dug deeper. I could find out that initializeSystemColors() is called twice. The first time it sets up the system colors with the
default (light) theme's colors. the second time with the dark theme.
  - the first time happens when the Display is created by the Workbench a part of the IDEApplications start up procedure
  - the second time when the workbench is created and run and there the renderer is created

The problem now is that the second time happens when all views are already created. Therefore older code like GEF3 based code will have at that time already the
colors from the first invocation. While for my code I could rather easy manage to get the right colors it is harder for the GEF3 code. Because there the colors
are stored as static final fields once and these colors are then used all over the place. This would be a major refactor which I'm currently not sure if this is
even easily possible.

Therefore I'm asking if there is a possibility to get the renderer created earlier or that the system colors are only set once in the beginning. This would not
only help to better support the dark theme for Eclipse 4diac but for any GEF3 and with that GMF, Sirius, and Graphiti based RCP.

Thanks in advance,
Alois



Back to the top