Skip to content

Commit 69292dd

Browse files
committed
Always send a PointerPhaseMove event before PointerPhaseUp to fix missing mouse clicks in MacOS
Fixes #180
1 parent 1a612d1 commit 69292dd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

glfw.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,19 @@ func (m *windowManager) handleButtonPhase(window *glfw.Window, action glfw.Actio
131131
}
132132

133133
if action == glfw.Release {
134+
// Always send a pointer event with PhaseMove before an eventual
135+
// PhaseUp. Even if the last button was released. If x/y on the last
136+
// move doesn't equal x/y on the PhaseUp, the click is canceled in
137+
// Flutter. On MacOS, the Release event always has y-1 of the last move
138+
// event. By sending a PhaseMove here (after the release) we avoid a
139+
// difference in x/y.
140+
m.sendPointerEventButton(window, embedder.PointerPhaseMove)
141+
134142
m.pointerButton ^= buttons
135143
// If all button are released then m.pointerButton is cleared
136144
if m.pointerButton == 0 {
137145
m.sendPointerEventButton(window, embedder.PointerPhaseUp)
138146
m.pointerPhase = embedder.PointerPhaseHover
139-
} else {
140-
// if any other buttons are still pressed when one button is released
141-
// the engine is expecting a Move phase instead of a Up phase.
142-
m.sendPointerEventButton(window, embedder.PointerPhaseMove)
143147
}
144148
}
145149
}

0 commit comments

Comments
 (0)