Bug: mouse cursors leaks (#136)

This commit is contained in:
nikitar020 2019-01-11 01:58:30 +07:00 committed by Liam Galvin
parent 84c0069785
commit 89eea0921d
2 changed files with 20 additions and 2 deletions

View File

@ -36,6 +36,8 @@ type GUI struct {
showDebugInfo bool
keyboardShortcuts map[config.UserAction]*config.KeyCombination
resizeLock *sync.Mutex
handCursor *glfw.Cursor
arrowCursor *glfw.Cursor
}
func Min(x, y int) int {

View File

@ -17,6 +17,22 @@ func (gui *GUI) glfwScrollCallback(w *glfw.Window, xoff float64, yoff float64) {
}
}
func (gui *GUI) getHandCursor() *glfw.Cursor {
if gui.handCursor == nil {
gui.handCursor = glfw.CreateStandardCursor(glfw.HandCursor)
}
return gui.handCursor
}
func (gui *GUI) getArrowCursor() *glfw.Cursor {
if gui.arrowCursor == nil {
gui.arrowCursor = glfw.CreateStandardCursor(glfw.ArrowCursor)
}
return gui.arrowCursor
}
func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) {
scale := gui.scale()
@ -40,9 +56,9 @@ func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) {
}
if url := gui.terminal.ActiveBuffer().GetURLAtPosition(x, y); url != "" {
w.SetCursor(glfw.CreateStandardCursor(glfw.HandCursor))
w.SetCursor(gui.getHandCursor())
} else {
w.SetCursor(glfw.CreateStandardCursor(glfw.ArrowCursor))
w.SetCursor(gui.getArrowCursor())
}
}