On some systems with the GNOME desktop environment, the dark theme does not
automatically apply to the GTK look and feel.
This issue has been observed on Oracle Linux 10 (Gnome 47) and Fedora 42 (Gnome
48). However, Ubuntu with the same Gnome versions is not affected.
To get it working, we should manually set the
`gtk-application-prefer-dark-theme` setting on affected systems. These changes
work fine on Ubuntu, too.
---
However, with this fix, the JDK will not detect a color scheme change on the
fly (e.g., from light to dark when GTK LaF is active). The theme change will
only apply if you switch to a different LaF and then back to GTK.
Normally we would subscribe to `changed::color-scheme` signal to detect this
change:
static void on_color_scheme_changed(GSettings *settings, gchar *key, gpointer
user_data) {
gchar *value = g_settings_get_string(settings, key);
g_print("Color scheme changed: %s\n", value);
g_free(value);
}
...
GSettings *settings = g_settings_new("org.gnome.desktop.interface");
g_signal_connect(settings, "changed::color-scheme",
G_CALLBACK(on_color_scheme_changed), NULL);
...
g_object_unref(settings);
However, it requires a running GTK loop, which we do not have.
As a workaround, we could try finding a place in our code where we can check
for a color scheme change to avoid introducing the GTK loop.
This issue is filed as
[JDK-8376605](https://bugs.openjdk.org/browse/JDK-8376605)
---
Testing looks good.
-------------
Commit messages:
- init
Changes: https://git.openjdk.org/jdk/pull/29469/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29469&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8365313
Stats: 74 lines in 5 files changed: 74 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/29469.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29469/head:pull/29469
PR: https://git.openjdk.org/jdk/pull/29469