|
|
@ -34,12 +34,13 @@ public class MacOSDecorationsUtil { |
|
|
|
private static final String FULL_WINDOW_CONTENT_KEY = "apple.awt.fullWindowContent"; |
|
|
|
private static final String FULL_WINDOW_CONTENT_KEY = "apple.awt.fullWindowContent"; |
|
|
|
private static final String TRANSPARENT_TITLE_BAR_KEY = "apple.awt.transparentTitleBar"; |
|
|
|
private static final String TRANSPARENT_TITLE_BAR_KEY = "apple.awt.transparentTitleBar"; |
|
|
|
|
|
|
|
|
|
|
|
protected static DecorationInformation installDecorations(final JRootPane rootPane) { |
|
|
|
protected static DecorationInformation installDecorations(final JRootPane rootPane, |
|
|
|
|
|
|
|
final boolean useColoredTitleBar) { |
|
|
|
if (rootPane == null) return null; |
|
|
|
if (rootPane == null) return null; |
|
|
|
Window window = SwingUtilities.getWindowAncestor(rootPane); |
|
|
|
Window window = SwingUtilities.getWindowAncestor(rootPane); |
|
|
|
long windowHandle = JNIDecorationsMacOS.getComponentPointer(window); |
|
|
|
long windowHandle = JNIDecorationsMacOS.getComponentPointer(window); |
|
|
|
if (windowHandle == 0) { |
|
|
|
if (windowHandle == 0) { |
|
|
|
return new DecorationInformation(0, false, false, false, rootPane, false, 0, 0); |
|
|
|
return new DecorationInformation(0, false, false, false, false, rootPane, false, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
JNIDecorationsMacOS.retainWindow(windowHandle); |
|
|
|
JNIDecorationsMacOS.retainWindow(windowHandle); |
|
|
|
boolean fullWindowContent = isFullWindowContentEnabled(rootPane); |
|
|
|
boolean fullWindowContent = isFullWindowContentEnabled(rootPane); |
|
|
@ -48,29 +49,41 @@ public class MacOSDecorationsUtil { |
|
|
|
int titleBarHeight = (int) JNIDecorationsMacOS.getTitleBarHeight(windowHandle); |
|
|
|
int titleBarHeight = (int) JNIDecorationsMacOS.getTitleBarHeight(windowHandle); |
|
|
|
|
|
|
|
|
|
|
|
boolean jniInstall = !SystemInfo.isJavaVersionAtLeast("12"); |
|
|
|
boolean jniInstall = !SystemInfo.isJavaVersionAtLeast("12"); |
|
|
|
if (!jniInstall) { |
|
|
|
|
|
|
|
setTransparentTitleBarEnabled(rootPane, true); |
|
|
|
if (useColoredTitleBar) { |
|
|
|
setFullWindowContentEnabled(rootPane, true); |
|
|
|
enableFullSizeContent(rootPane, windowHandle, jniInstall); |
|
|
|
} else { |
|
|
|
|
|
|
|
JNIDecorationsMacOS.installDecorations(windowHandle); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean titleVisible = SystemInfo.isMacOSMojave; |
|
|
|
boolean titleVisible = SystemInfo.isMacOSMojave; |
|
|
|
JNIDecorationsMacOS.setTitleEnabled(windowHandle, titleVisible); |
|
|
|
JNIDecorationsMacOS.setTitleEnabled(windowHandle, titleVisible); |
|
|
|
if (titleVisible) { |
|
|
|
if (titleVisible) { |
|
|
|
boolean isDarkTheme = UIManager.getBoolean("Theme.dark"); |
|
|
|
boolean isDarkTheme = UIManager.getBoolean("Theme.dark"); |
|
|
|
JNIDecorationsMacOS.setDarkTheme(windowHandle, isDarkTheme); |
|
|
|
JNIDecorationsMacOS.setDarkTheme(windowHandle, isDarkTheme); |
|
|
|
} |
|
|
|
} |
|
|
|
return new DecorationInformation(windowHandle, fullWindowContent, transparentTitleBar, jniInstall, rootPane, |
|
|
|
return new DecorationInformation(windowHandle, fullWindowContent, transparentTitleBar, useColoredTitleBar, |
|
|
|
|
|
|
|
jniInstall, rootPane, |
|
|
|
titleVisible, titleBarHeight, titleFontSize); |
|
|
|
titleVisible, titleBarHeight, titleFontSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void enableFullSizeContent(final JRootPane rootPane, final long windowHandle, |
|
|
|
|
|
|
|
final boolean jniInstall) { |
|
|
|
|
|
|
|
if (!jniInstall) { |
|
|
|
|
|
|
|
setTransparentTitleBarEnabled(rootPane, true); |
|
|
|
|
|
|
|
setFullWindowContentEnabled(rootPane, true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
JNIDecorationsMacOS.installDecorations(windowHandle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static void uninstallDecorations(final DecorationInformation information) { |
|
|
|
protected static void uninstallDecorations(final DecorationInformation information) { |
|
|
|
if (information == null || information.windowHandle == 0) return; |
|
|
|
if (information == null || information.windowHandle == 0) return; |
|
|
|
if (information.jniInstalled) { |
|
|
|
if (information.useColoredTitleBar) { |
|
|
|
JNIDecorationsMacOS.uninstallDecorations(information.windowHandle); |
|
|
|
if (information.jniInstalled) { |
|
|
|
} else { |
|
|
|
JNIDecorationsMacOS.uninstallDecorations(information.windowHandle); |
|
|
|
setFullWindowContentEnabled(information.rootPane, information.fullWindowContentEnabled); |
|
|
|
} else { |
|
|
|
setTransparentTitleBarEnabled(information.rootPane, information.transparentTitleBarEnabled); |
|
|
|
setFullWindowContentEnabled(information.rootPane, information.fullWindowContentEnabled); |
|
|
|
|
|
|
|
setTransparentTitleBarEnabled(information.rootPane, information.transparentTitleBarEnabled); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
JNIDecorationsMacOS.setTitleEnabled(information.windowHandle, true); |
|
|
|
JNIDecorationsMacOS.setTitleEnabled(information.windowHandle, true); |
|
|
|
JNIDecorationsMacOS.releaseWindow(information.windowHandle); |
|
|
|
JNIDecorationsMacOS.releaseWindow(information.windowHandle); |
|
|
|