Skip to content

Commit 89eea09

Browse files
vadymeng0liamg
authored andcommitted
Bug: mouse cursors leaks (liamg#136)
1 parent 84c0069 commit 89eea09

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

gui/gui.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type GUI struct {
3636
showDebugInfo bool
3737
keyboardShortcuts map[config.UserAction]*config.KeyCombination
3838
resizeLock *sync.Mutex
39+
handCursor *glfw.Cursor
40+
arrowCursor *glfw.Cursor
3941
}
4042

4143
func Min(x, y int) int {

gui/mouse.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ func (gui *GUI) glfwScrollCallback(w *glfw.Window, xoff float64, yoff float64) {
1717
}
1818
}
1919

20+
func (gui *GUI) getHandCursor() *glfw.Cursor {
21+
if gui.handCursor == nil {
22+
gui.handCursor = glfw.CreateStandardCursor(glfw.HandCursor)
23+
}
24+
25+
return gui.handCursor
26+
}
27+
28+
func (gui *GUI) getArrowCursor() *glfw.Cursor {
29+
if gui.arrowCursor == nil {
30+
gui.arrowCursor = glfw.CreateStandardCursor(glfw.ArrowCursor)
31+
}
32+
33+
return gui.arrowCursor
34+
}
35+
2036
func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) {
2137

2238
scale := gui.scale()
@@ -40,9 +56,9 @@ func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) {
4056
}
4157

4258
if url := gui.terminal.ActiveBuffer().GetURLAtPosition(x, y); url != "" {
43-
w.SetCursor(glfw.CreateStandardCursor(glfw.HandCursor))
59+
w.SetCursor(gui.getHandCursor())
4460
} else {
45-
w.SetCursor(glfw.CreateStandardCursor(glfw.ArrowCursor))
61+
w.SetCursor(gui.getArrowCursor())
4662
}
4763
}
4864

0 commit comments

Comments
 (0)