Skip to content

Commit d14968c

Browse files
committed
Fix/mouse exit windows (#202)
* fixes #198 * fixe weird edge case
1 parent 20288d0 commit d14968c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

application.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ func (a *Application) Run() error {
237237
a.window.SetRefreshCallback(m.glfwRefreshCallback)
238238
a.window.SetPosCallback(m.glfwPosCallback)
239239

240+
// flutter's PlatformMessage handler is registered through the dart:ui.Window
241+
// interface. ui.Window must have at least paint one frame, before any
242+
// platfrom message can be corectly handled by ui.Window.onPlatformMessage.
243+
glfw.WaitEvents()
244+
240245
a.window.SetKeyCallback(
241246
func(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
242247
defaultTextinputPlugin.glfwKeyCallback(window, key, scancode, action, mods)

glfw.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ func (m *windowManager) glfwCursorEnterCallback(window *glfw.Window, entered boo
105105
x, y := window.GetCursorPos()
106106
if entered {
107107
m.sendPointerEvent(window, embedder.PointerPhaseAdd, x, y)
108-
m.pointerPhase = embedder.PointerPhaseHover
108+
// the mouse can enter the windows while having button pressed.
109+
// if so, don't overwrite the phase.
110+
if m.pointerButton == 0 {
111+
m.pointerPhase = embedder.PointerPhaseHover
112+
}
109113
} else {
110-
m.sendPointerEvent(window, embedder.PointerPhaseRemove, x, y)
114+
// if the mouse is still in 'phaseMove' outside the window (click-drag
115+
// outside). Don't remove the cursor.
116+
if m.pointerButton == 0 {
117+
m.sendPointerEvent(window, embedder.PointerPhaseRemove, x, y)
118+
}
111119
}
112120
}
113121

0 commit comments

Comments
 (0)