Re: RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-29 Thread Alexander Zuev
On Wed, 28 Jan 2026 18:44:21 GMT, Alexander Zvegintsev  
wrote:

> 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.

Looks good

-

Marked as reviewed by kizune (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29469#pullrequestreview-3723803543


Re: RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-29 Thread Alexander Zvegintsev
On Thu, 29 Jan 2026 00:24:01 GMT, Sergey Bylokhov  wrote:

> maybe we should provide a way to set this by the application? similar to how 
> we did on macOS?

In another fix - maybe.

Currently, setting the `gtk-application-prefer-dark-theme` is not enough to 
override the theme on Ubuntu 25.04 with Gnome 48, it still uses the system 
theme.
This differs from Fedora 42 with Gnome 48, where it is sufficient.

More research is required, but not in this PR.

-

PR Comment: https://git.openjdk.org/jdk/pull/29469#issuecomment-3818208261


Re: RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-29 Thread Maxim Kartashev
On Wed, 28 Jan 2026 18:44:21 GMT, Alexander Zvegintsev  
wrote:

> 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.

Marked as reviewed by mkartashev (Committer).

-

PR Review: https://git.openjdk.org/jdk/pull/29469#pullrequestreview-3721275310


Re: RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-28 Thread Sergey Bylokhov
On Wed, 28 Jan 2026 18:44:21 GMT, Alexander Zvegintsev  
wrote:

> 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.

maybe we should provide a way to set this by the application? similar to how we 
did on macOS?

-

PR Comment: https://git.openjdk.org/jdk/pull/29469#issuecomment-3814636643


Re: RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-28 Thread Phil Race
On Wed, 28 Jan 2026 18:44:21 GMT, Alexander Zvegintsev  
wrote:

> 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.

Marked as reviewed by prr (Reviewer).

-

PR Review: https://git.openjdk.org/jdk/pull/29469#pullrequestreview-3718904912


RFR: 8365313: GTK LaF does not respect system color scheme with Gnome

2026-01-28 Thread Alexander Zvegintsev
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