From 03ccd2cc7727d4fb6b26bbd0029374e2323950f1 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Sun, 19 May 2024 02:12:32 +0200 Subject: [PATCH] chore: Tweak appearance, title and allow full screen --- .../github/bric3/fireplace/FireplaceMain.kt | 13 ++++++++++-- .../fireplace/ui/toolkit/AppearanceControl.kt | 20 +++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/FireplaceMain.kt b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/FireplaceMain.kt index 0b8b62cd..10db3d14 100644 --- a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/FireplaceMain.kt +++ b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/FireplaceMain.kt @@ -11,6 +11,7 @@ package io.github.bric3.fireplace import com.formdev.flatlaf.extras.FlatInspector +import com.github.weisj.darklaf.platform.SystemInfo import io.github.bric3.fireplace.jfr.ProfileContentPanel import io.github.bric3.fireplace.jfr.support.JFRLoaderBinder import io.github.bric3.fireplace.jfr.support.JfrFilesDropHandler @@ -49,6 +50,8 @@ fun main(args: Array) { initUI(jfrBinder, paths) } +private const val APP_NAME = "FirePlace" + private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List) { if (Utils.isFireplaceSwingDebug) { if (System.getProperty("fireplace.swing.debug.thread.violation.checker") == "IJ") { @@ -59,6 +62,12 @@ private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List) { EventDispatchThreadHangMonitor.initMonitoring() } + if (SystemInfo.isMac) { + // This call has to happen before the Desktop toolkit is even initialized + // application name used in the screen menu bar + System.setProperty("apple.awt.application.name", APP_NAME) + } + with(Desktop.getDesktop()) { if (isSupported(Desktop.Action.APP_ABOUT)) { setAboutHandler { @@ -66,7 +75,7 @@ private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List) { null, """ - Fireplace | a JFR viewer + $APP_NAME | a JFR viewer

Version: 0.0.1
@@ -123,7 +132,7 @@ private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List) { hud.dnDTarget ) - JFrame("FirePlace").run { + JFrame(APP_NAME).run { defaultCloseOperation = JFrame.EXIT_ON_CLOSE size = Dimension(1400, 800) contentPane.add(hud.component) diff --git a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/AppearanceControl.kt b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/AppearanceControl.kt index 0a02367d..8e5ee0d8 100644 --- a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/AppearanceControl.kt +++ b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/AppearanceControl.kt @@ -31,15 +31,7 @@ import java.awt.Rectangle import java.awt.Taskbar import java.awt.Toolkit import java.awt.Window -import javax.swing.JButton -import javax.swing.JCheckBox -import javax.swing.JComponent -import javax.swing.JFrame -import javax.swing.JPanel -import javax.swing.JRootPane -import javax.swing.RootPaneContainer -import javax.swing.SwingUtilities -import javax.swing.UIManager +import javax.swing.* @Suppress("unused") internal object AppearanceControl { @@ -85,12 +77,14 @@ internal object AppearanceControl { // configure frame for transparency if (SystemInfo.isMac) { frame.rootPane.apply { - // allows to place swing components on the whole window + // Allow placing swing components on the whole window putClientProperty("apple.awt.fullWindowContent", true) - // makes the title bar transparent + // Makes the title bar transparent putClientProperty("apple.awt.transparentTitleBar", true) - // hide window title + // Hide window title putClientProperty(DecorationsConstants.KEY_HIDE_TITLE, true) + // Allow to enter full screen when pressing Alt + putClientProperty("apple.awt.fullscreenable", true) } } ExternalLafDecorator.instance().install() @@ -148,7 +142,7 @@ internal object AppearanceControl { System.setProperty( "apple.laf.useScreenMenuBar", "true" - ) // moves menu bar from JFrame window to top of screen + ) // moves menu bar from JFrame window to top of the screen System.setProperty("apple.awt.application.name", title) // application name used in screen menu bar // appearance of window title bars // possible values: