Skip to content

Fix/mouse exit windows #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down