From ec0dbe4fc462de22ada1751d262ec44f2ffd4ac8 Mon Sep 17 00:00:00 2001 From: theGeekPirate Date: Fri, 27 Oct 2017 13:19:59 -0700 Subject: [PATCH] Replaced SetCursorMode() with SetCursorDisabled() --- pixelgl/window.go | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/pixelgl/window.go b/pixelgl/window.go index 9f81ab1..f05c0db 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -318,41 +318,14 @@ func (w *Window) VSync() bool { return w.vsync } -// cursorMode uses magic numbers from https://github.com/glfw/glfw/blob/32e78aeb2edb5cb5add36ae575fc914f6c4fc7e5/include/GLFW/glfw3.h#L966 -type cursorMode int - -const ( - // CursorNormal displays the regular cursor (or another set with glfw.SetCursor()), and - // does not limit cursor motion. - CursorNormal cursorMode = 0x00034001 - // CursorHidden hides the cursor, and does not limit cursor motion. - CursorHidden cursorMode = 0x00034002 - // CursorDisabled both hides the cursor, as well as limits cursor movement to the window. - CursorDisabled cursorMode = 0x00034003 -) - -// SetCursorMode determines how the mouse cursor appears and behaves. -func (w *Window) SetCursorMode(cm cursorMode) { +// SetCursorDisabled both hides the cursor, as well as limits cursor movement to the Window client area. +func (w *Window) SetCursorDisabled(disabled bool) { + w.cursorVisible = false mainthread.Call(func() { - switch cm { - case CursorNormal: - w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) - case CursorHidden: - w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden) - case CursorDisabled: + if disabled { w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled) - } - }) -} - -// SetCursorVisible sets the visibility of the mouse cursor inside the Window client area. -func (w *Window) SetCursorVisible(visible bool) { - w.cursorVisible = visible - mainthread.Call(func() { - if visible { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) } else { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden) + w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) } }) }