Skip to content

Conversation

mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Jul 13, 2025

Currently, the color scheme of a system-decorated stage is as follows:

  • On Windows, the title bar is always light (even if the OS color scheme is dark).
  • On macOS and Linux, the title bar is light or dark depending on the OS color scheme.

The expected behavior is that the title bar matches the color scheme of the Scene.
If an application doesn't specify a color scheme, the title bar color should match the OS color scheme.

This PR fixes the behavior for Windows and macOS, but not for Linux (there's no good way to do that).
Depending on how you look at it, this is either a bug fix or an enhancement.

/reviewers 2


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8362091: Window title bar should reflect scene color scheme (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1845/head:pull/1845
$ git checkout pull/1845

Update a local copy of the PR:
$ git checkout pull/1845
$ git pull https://git.openjdk.org/jfx.git pull/1845/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1845

View PR using the GUI difftool:
$ git pr show -t 1845

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1845.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 13, 2025

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 13, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Ready for review label Jul 13, 2025
@openjdk
Copy link

openjdk bot commented Jul 13, 2025

@mstr2
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@mlbridge
Copy link

mlbridge bot commented Jul 13, 2025

Webrevs

@kevinrushforth kevinrushforth self-requested a review July 24, 2025 19:24
# Conflicts:
#	modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m
// We are going to query the file version of dwmapi.dll to make sure we use the right constant, or the
// value 0 to indicate that we don't support this feature.
// See: https://github.com/MicrosoftDocs/sdk-api/commit/c19f1c8a148b930444dce998d3c717c8fb7751e1
static const DWORD DWMWA_USE_IMMERSIVE_DARK_MODE = []() {
Copy link
Member

Choose a reason for hiding this comment

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

This implementation looks correct. For comparison, I checked out the implementation in Godot.

Version check: https://github.com/godotengine/godot/blob/master/platform/windows/display_server_windows.cpp#L6853
Set the attribute: https://github.com/godotengine/godot/blob/master/platform/windows/display_server_windows.cpp#L4708

Note that the build numbers differ a little bit from here. But checking your linked commit, your numbers seem to be the right one! Will do some testing later (on Windows 11).

@bundgaard
Copy link

bundgaard commented Aug 24, 2025

Hi @bundgaard, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user bundgaard" for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

@mstr2
Copy link
Collaborator Author

mstr2 commented Aug 24, 2025

Is the extra code (beside looking at the version) so that I can toggle the darkbar from Java?

We have two places in JavaFX that are relevant to dark mode:

  1. Platform.Preferences.colorScheme, which tells you the color scheme of the operating system (i.e. what you select in PC settings)
  2. Scene.Preferences.colorScheme, which defaults to the OS color scheme, but is overridable for each scene.

This PR proposes to match the OS-provided title bar color to the value of Scene.Preferences.colorScheme, which allows developers to choose how their application should be presented:

  • If you don't override the scene color scheme, the window title bar will match the OS by default (light or dark).
  • However, if your application uses a fixed light or dark theme (i.e. it doesn't adapt its control theme colors to dark mode), then overriding the scene color scheme ensures consistent presentation independent of OS settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Ready for review
Development

Successfully merging this pull request may close these issues.

3 participants