On Tue, 17 Nov 2026 18:59:23 GMT, Michael Strauß <[email protected]> wrote:

>> GTK's `PlatformSupport` class only listens to the `gtk-theme-name` signal to 
>> detect theme changes. However, it seems that with KDE, color changes are 
>> posted with a delay after the theme change. Since we only collect platform 
>> preferences when the theme name was changed, we can miss delayed color 
>> changes.
>> 
>> The fix is to also listen to a changed style context. The style context's 
>> `changed` signal can fire multiple times, so we don't collect the new 
>> preferences right away, but schedule them to be collected in an idle 
>> callback.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Michael Strauß has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   use GtkStyleContext instead of GtkStyle

Actually, I think might be a bug.

Indeed, the GTK theme is not up-to-date after switching:

<img width="300" height="229" alt="image" 
src="https://github.com/user-attachments/assets/e3ac0834-77f9-48b9-a4b6-ccb61d773f81";
 />

Now the weird part: Even after restarting the app, it again shows `Breeze-Dark` 
for the `LIGHT` color scheme. No preference listener involved yet. But I can't 
see how this is a bug in JavaFX or this code.

I checked the `xsettings` and probably a bug in KDE, I think:


=== On Breeze Dark ===
> dump_xsettings | grep ThemeName

Gtk/CursorThemeName "breeze_cursors"
Net/IconThemeName "breeze"
Net/SoundThemeName "ocean"
Net/ThemeName "Breeze"

=== On Breeze (lighjt) ===
> dump_xsettings | grep ThemeName

Gtk/CursorThemeName "breeze_cursors"
Net/IconThemeName "breeze-dark"
Net/SoundThemeName "ocean"
Net/ThemeName "Breeze-Dark"


---

This is the listener change sequence without and with this PR:


=== OLD ===

START
SWITCH DARK -> LIGHT
GTK.theme_name=Breeze-Dark, colorScheme=DARK, backgroundColor=0x202326ff
SWITCH LIGHT -> DARK
GTK.theme_name=Breeze, colorScheme=LIGHT, backgroundColor=0xeff0f1ff

=== NEW (THIS PR) ===

START
SWITCH DARK -> LIGHT
GTK.theme_name=Breeze-Dark, colorScheme=DARK, backgroundColor=0x202326ff
GTK.theme_name=Breeze-Dark, colorScheme=LIGHT, backgroundColor=0xeff0f1ff
SWITCH LIGHT -> DARK
GTK.theme_name=Breeze, colorScheme=LIGHT, backgroundColor=0xeff0f1ff
GTK.theme_name=Breeze, colorScheme=DARK, backgroundColor=0x202326ff


In the new sequence, maybe the first notification is meant for the new theme 
name, which for some weird reason does not work as mentioned above. And thats 
why it looks a bit weird that you first get `colorScheme=DARK` followed by 
`colorScheme=LIGHT`.
For me, it's fine -- but I can also test other changes if you think this is 
worth it to change so that e.g. only one listener event is sent.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2372#issuecomment-6986011776

Reply via email to