mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 10:29:58 +02:00
Polish native shell navigation
This commit is contained in:
@@ -22,6 +22,7 @@ internal object DesktopSystemAppearance {
|
||||
if (!isMacOs()) return
|
||||
System.setProperty(MAC_APPEARANCE_PROPERTY, macOsAppearanceName(isDarkTheme))
|
||||
EventQueue.invokeLater {
|
||||
DesktopAppearanceBridge.applyNativeAppearance?.invoke(isDarkTheme)
|
||||
Window.getWindows().forEach { window ->
|
||||
applyWindowChrome(window, isDarkTheme)
|
||||
}
|
||||
@@ -31,6 +32,8 @@ internal object DesktopSystemAppearance {
|
||||
internal fun macOsAppearanceName(isDarkTheme: Boolean): String =
|
||||
if (isDarkTheme) "NSAppearanceNameDarkAqua" else "NSAppearanceNameAqua"
|
||||
|
||||
internal fun usesTransparentTitlebar(): Boolean = true
|
||||
|
||||
internal fun titlebarBackground(isDarkTheme: Boolean): Color =
|
||||
if (isDarkTheme) Color(0x12, 0x12, 0x12) else Color(0xF8, 0xF8, 0xF8)
|
||||
|
||||
@@ -38,9 +41,9 @@ internal object DesktopSystemAppearance {
|
||||
val background = titlebarBackground(isDarkTheme)
|
||||
window.background = background
|
||||
(window as? JFrame)?.rootPane?.let { rootPane ->
|
||||
// Keep the native macOS controls and drag behavior, but let the
|
||||
// decorated titlebar blend with the app's resolved light/dark surface.
|
||||
rootPane.putClientProperty(TRANSPARENT_TITLE_BAR_PROPERTY, true)
|
||||
// The titlebar stays native, but AppKit receives the resolved app
|
||||
// appearance so title text and controls switch contrast at runtime.
|
||||
rootPane.putClientProperty(TRANSPARENT_TITLE_BAR_PROPERTY, usesTransparentTitlebar())
|
||||
rootPane.background = background
|
||||
rootPane.contentPane.background = background
|
||||
}
|
||||
@@ -49,3 +52,8 @@ internal object DesktopSystemAppearance {
|
||||
private fun isMacOs(): Boolean =
|
||||
System.getProperty("os.name").startsWith("Mac", ignoreCase = true)
|
||||
}
|
||||
|
||||
object DesktopAppearanceBridge {
|
||||
@Volatile
|
||||
var applyNativeAppearance: ((Boolean) -> Unit)? = null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user