diff --git a/application.go b/application.go index 42daaff5..8fdb40d9 100644 --- a/application.go +++ b/application.go @@ -237,6 +237,11 @@ func (a *Application) Run() error { a.window.SetRefreshCallback(m.glfwRefreshCallback) a.window.SetPosCallback(m.glfwPosCallback) + // flutter's PlatformMessage handler is registered through the dart:ui.Window + // interface. ui.Window must have at least paint one frame, before any + // platfrom message can be corectly handled by ui.Window.onPlatformMessage. + glfw.WaitEvents() + a.window.SetKeyCallback( func(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) { defaultTextinputPlugin.glfwKeyCallback(window, key, scancode, action, mods) diff --git a/glfw.go b/glfw.go index 3ccdb108..0e73fda1 100644 --- a/glfw.go +++ b/glfw.go @@ -105,9 +105,17 @@ func (m *windowManager) glfwCursorEnterCallback(window *glfw.Window, entered boo x, y := window.GetCursorPos() if entered { m.sendPointerEvent(window, embedder.PointerPhaseAdd, x, y) - m.pointerPhase = embedder.PointerPhaseHover + // the mouse can enter the windows while having button pressed. + // if so, don't overwrite the phase. + if m.pointerButton == 0 { + m.pointerPhase = embedder.PointerPhaseHover + } } else { - m.sendPointerEvent(window, embedder.PointerPhaseRemove, x, y) + // if the mouse is still in 'phaseMove' outside the window (click-drag + // outside). Don't remove the cursor. + if m.pointerButton == 0 { + m.sendPointerEvent(window, embedder.PointerPhaseRemove, x, y) + } } }