Skip to content

Commit 60469a3

Browse files
authored
Merge pull request #215 from kdroidFilter/fix/titlebar-focus-windows-linux
fix(decorated-window): restore title bar focus block on Windows/Linux
2 parents 8f6bbc4 + 9459ffc commit 60469a3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • decorated-window-core/src/main/kotlin/io/github/kdroidfilter/nucleus/window

decorated-window-core/src/main/kotlin/io/github/kdroidfilter/nucleus/window/TitleBarCore.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.compose.runtime.remember
1414
import androidx.compose.runtime.staticCompositionLocalOf
1515
import androidx.compose.ui.Alignment
1616
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.focus.focusProperties
1718
import androidx.compose.ui.graphics.Brush
1819
import androidx.compose.ui.graphics.Color
1920
import androidx.compose.ui.graphics.SolidColor
@@ -40,6 +41,7 @@ import androidx.compose.ui.unit.Density
4041
import androidx.compose.ui.unit.Dp
4142
import androidx.compose.ui.unit.LayoutDirection
4243
import androidx.compose.ui.unit.offset
44+
import io.github.kdroidfilter.nucleus.core.runtime.Platform
4345
import io.github.kdroidfilter.nucleus.window.styling.LocalTitleBarStyle
4446
import io.github.kdroidfilter.nucleus.window.styling.TitleBarStyle
4547
import kotlinx.coroutines.currentCoroutineContext
@@ -100,7 +102,17 @@ fun GenericTitleBarImpl(
100102
modifier =
101103
modifier
102104
.background(backgroundBrush)
103-
.layoutId(TITLE_BAR_LAYOUT_ID)
105+
.then(
106+
// Block focus on Windows/Linux so Tab navigation cannot enter the Compose-driven
107+
// title bar drag area. On macOS the traffic-light buttons are native (outside the
108+
// Compose hit-test area), and focus must remain enabled so TextField/TextArea
109+
// children in the title bar can receive keyboard input (issue #206 / PR #208).
110+
if (Platform.Current == Platform.MacOS) {
111+
Modifier
112+
} else {
113+
Modifier.focusProperties { canFocus = false }
114+
},
115+
).layoutId(TITLE_BAR_LAYOUT_ID)
104116
.height(style.metrics.height)
105117
.onSizeChanged { with(density) { applyTitleBar(it.height.toDp(), state) } }
106118
.fillMaxWidth(),

0 commit comments

Comments
 (0)