Skip to content

Commit 92c8597

Browse files
committed
fix(desktop, windows): restore drag and drop after recomposition #77
1 parent f211a95 commit 92c8597

File tree

1 file changed

+5
-15
lines changed
  • core/shared-ui/src/desktopMain/kotlin/com/neoutils/neoregex/core/sharedui/component

1 file changed

+5
-15
lines changed

core/shared-ui/src/desktopMain/kotlin/com/neoutils/neoregex/core/sharedui/component/NeoHeader.kt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fun FrameWindowScope.NeoHeader(
6464
val focus = rememberWindowFocus()
6565
val state = rememberNeoWindowState()
6666

67-
val dragHandler = remember { DragHandler(window) }
67+
val dragHandler = remember(window) { DragHandler(window) }
6868

6969
// only macOS and Windows supports
7070
val customTitleBar = remember {
@@ -90,29 +90,18 @@ fun FrameWindowScope.NeoHeader(
9090
customTitleBar?.height = it.height.toFloat()
9191
}.run {
9292
customTitleBar?.let {
93-
pointerInput(colorTheme) {
94-
95-
var inUserControl = false
96-
93+
pointerInput(customTitleBar) {
9794
awaitEachGesture {
9895
awaitPointerEvent(PointerEventPass.Main).let { event ->
9996
event.changes.forEach {
100-
if (!it.isConsumed && !inUserControl) {
97+
if (!it.isConsumed) {
10198
customTitleBar.forceHitTest(false)
102-
} else {
103-
if (event.type == PointerEventType.Press) {
104-
inUserControl = true
105-
}
106-
if (event.type == PointerEventType.Release) {
107-
inUserControl = false
108-
}
109-
customTitleBar.forceHitTest(true)
11099
}
111100
}
112101
}
113102
}
114103
}
115-
} ?: pointerInput(state) {
104+
} ?: pointerInput(dragHandler, state) {
116105
detectTapGestures(
117106
onDoubleTap = {
118107
when (state) {
@@ -134,6 +123,7 @@ fun FrameWindowScope.NeoHeader(
134123
window,
135124
MouseEvent.BUTTON1
136125
) ?: run {
126+
// No Runtime of JetBrains
137127
dragHandler.onDragStarted()
138128
}
139129
}

0 commit comments

Comments
 (0)