Skip to content

Commit d883546

Browse files
author
Michael Strauß
committed
8362091: Window title bar should reflect scene color scheme
Reviewed-by: kcr, angorya
1 parent 52e3d63 commit d883546

File tree

17 files changed

+183
-12
lines changed

17 files changed

+183
-12
lines changed

buildSrc/win.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ WIN.glass.rcFlags = [
326326
WIN.glass.ccFlags = [ccFlags].flatten()
327327
WIN.glass.linker = linker
328328
WIN.glass.linkFlags = (IS_STATIC_BUILD ? [linkFlags] : [linkFlags, "delayimp.lib", "gdi32.lib", "urlmon.lib", "Comdlg32.lib",
329-
"winmm.lib", "imm32.lib", "shell32.lib", "Uiautomationcore.lib", "dwmapi.lib",
329+
"winmm.lib", "imm32.lib", "shell32.lib", "Uiautomationcore.lib", "dwmapi.lib", "version.lib",
330330
"/DELAYLOAD:user32.dll", "/DELAYLOAD:urlmon.dll", "/DELAYLOAD:winmm.dll", "/DELAYLOAD:shell32.dll",
331-
"/DELAYLOAD:Uiautomationcore.dll", "/DELAYLOAD:dwmapi.dll"]).flatten()
331+
"/DELAYLOAD:Uiautomationcore.dll", "/DELAYLOAD:dwmapi.dll", "/DELAYLOAD:version.dll"]).flatten()
332332
WIN.glass.lib = "glass"
333333

334334
WIN.decora = [:]

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Window.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ static protected void remove(Window window) {
173173
*/
174174
@Native public static final int MODAL = 1 << 10;
175175

176+
/**
177+
* Indicates that the window should use a dark window frame.
178+
*/
179+
@Native public static final int DARK_FRAME = 1 << 11;
180+
176181
final static public class State {
177182
@Native public static final int NORMAL = 1;
178183
@Native public static final int MINIMIZED = 2;
@@ -988,6 +993,8 @@ public boolean setBackground(final float r, final float g, final float b) {
988993
return _setBackground(this.ptr, r, g, b);
989994
}
990995

996+
public void setDarkFrame(boolean value) {}
997+
991998
public boolean isEnabled() {
992999
Application.checkEventThread();
9931000
return this.disableCount == 0;

modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacWindow.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ protected MacWindow(Window owner, Screen screen, int styleMask) {
113113

114114
private native void _setIcon(long ptr, Object iconBuffer, int width, int height);
115115

116+
@Override
117+
public void setDarkFrame(boolean value) {
118+
_setDarkFrame(getRawHandle(), value);
119+
}
120+
121+
private native void _setDarkFrame(long ptr, boolean value);
122+
116123
@Override native protected void _toFront(long ptr);
117124
@Override native protected void _toBack(long ptr);
118125

modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ protected boolean _setBackground(long ptr, float r, float g, float b) {
265265
return true;
266266
}
267267

268+
private native void _setDarkFrame(long ptr, boolean value);
269+
270+
@Override
271+
public void setDarkFrame(boolean value) {
272+
_setDarkFrame(getRawHandle(), value);
273+
}
274+
268275
native private long _getInsets(long ptr);
269276
native private long _getAnchor(long ptr);
270277
native private void _showSystemMenu(long ptr, int x, int y);

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,8 @@ public void exitAllNestedEventLoops() {
101101
}
102102

103103
@Override
104-
public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl) {
104+
public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary,
105+
Modality modality, TKStage owner, boolean rtl, boolean darkFrame) {
105106
throw new UnsupportedOperationException("Not supported yet.");
106107
}
107108

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/TKStage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public void setBounds(float x, float y, boolean xSet, boolean ySet,
124124

125125
public void setPrefHeaderButtonHeight(double height);
126126

127+
public void setDarkFrame(boolean value);
128+
127129
// =================================================================================================================
128130
// Functions
129131

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/Toolkit.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ protected Toolkit() {
360360

361361
public abstract boolean isNestedLoopRunning();
362362

363-
public abstract TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl);
363+
public abstract TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary,
364+
Modality modality, TKStage owner, boolean rtl, boolean darkFrame);
364365

365366
public abstract TKStage createTKPopupStage(Window peerWindow, StageStyle popupStyle, TKStage owner);
366367
public abstract TKStage createTKEmbeddedStage(HostInterface host);

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassStage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ protected GlassStage() {
7777
@Override
7878
public void setPrefHeaderButtonHeight(double height) {}
7979

80+
@Override
81+
public void setDarkFrame(boolean value) {}
82+
8083
protected final GlassScene getScene() {
8184
return scene;
8285
}

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,10 @@ void vsyncHint() {
608608
}
609609
}
610610

611-
@Override public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl) {
611+
@Override public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary,
612+
Modality modality, TKStage owner, boolean rtl, boolean darkFrame) {
612613
assertToolkitRunning();
613-
WindowStage stage = new WindowStage(peerWindow, stageStyle, modality, owner);
614+
WindowStage stage = new WindowStage(peerWindow, stageStyle, modality, owner, darkFrame);
614615
if (primary) {
615616
stage.setIsPrimary();
616617
}
@@ -693,7 +694,7 @@ private boolean maxNestedEventLoopsHit() {
693694

694695
@Override public TKStage createTKPopupStage(Window peerWindow, StageStyle popupStyle, TKStage owner) {
695696
assertToolkitRunning();
696-
WindowStage stage = new WindowStage(peerWindow, popupStyle, null, owner);
697+
WindowStage stage = new WindowStage(peerWindow, popupStyle, null, owner, false);
697698
stage.setIsPopup();
698699
stage.init(systemMenu);
699700
return stage;

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class WindowStage extends GlassStage {
6666
private OverlayWarning warning = null;
6767
private boolean rtl = false;
6868
private boolean transparent = false;
69+
private boolean darkFrame = false;
6970
private boolean isPrimaryStage = false;
7071
private boolean isPopupStage = false;
7172
private boolean isInFullScreen = false;
@@ -85,11 +86,12 @@ public class WindowStage extends GlassStage {
8586
ResourceBundle.getBundle(WindowStage.class.getPackage().getName() +
8687
".QuantumMessagesBundle", LOCALE);
8788

88-
89-
public WindowStage(javafx.stage.Window peerWindow, final StageStyle stageStyle, Modality modality, TKStage owner) {
89+
public WindowStage(javafx.stage.Window peerWindow, final StageStyle stageStyle, Modality modality,
90+
TKStage owner, boolean darkFrame) {
9091
this.style = stageStyle;
9192
this.owner = (GlassStage)owner;
9293
this.modality = modality;
94+
this.darkFrame = darkFrame;
9395

9496
if (peerWindow instanceof javafx.stage.Stage) {
9597
fxStage = (Stage)peerWindow;
@@ -177,6 +179,10 @@ private void initPlatformWindow() {
177179
windowMask |= Window.MODAL;
178180
}
179181

182+
if (darkFrame) {
183+
windowMask |= Window.DARK_FRAME;
184+
}
185+
180186
platformWindow = app.createWindow(ownerWindow, Screen.getMainScreen(), windowMask);
181187
platformWindow.setResizable(resizable);
182188
platformWindow.setFocusable(focusable);
@@ -904,4 +910,13 @@ public void setPrefHeaderButtonHeight(double height) {
904910
platformWindow.setPrefHeaderButtonHeight(height);
905911
}
906912
}
913+
914+
@Override
915+
public void setDarkFrame(boolean value) {
916+
darkFrame = value;
917+
918+
if (platformWindow != null) {
919+
platformWindow.setDarkFrame(value);
920+
}
921+
}
907922
}

0 commit comments

Comments
 (0)