diff --git a/src/OpenTK/Platform/MacOS/CocoaNativeWindow.cs b/src/OpenTK/Platform/MacOS/CocoaNativeWindow.cs index a0d52817..4cae30fe 100644 --- a/src/OpenTK/Platform/MacOS/CocoaNativeWindow.cs +++ b/src/OpenTK/Platform/MacOS/CocoaNativeWindow.cs @@ -1236,19 +1236,17 @@ namespace OpenTK.Platform.MacOS public override bool CursorVisible { - get { return cursorVisible; } + get + { + return cursorVisible; + } set { - if (value == cursorVisible) return; - if (value && !cursorVisible) + if (value != cursorVisible) { - SetCursorVisible(true); + SetCursorVisible(value); + cursorVisible = value; } - else if (!value && cursorVisible) - { - SetCursorVisible(false); - } - cursorVisible = value; } } diff --git a/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index d4a7b224..b9e51cf7 100644 --- a/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -933,10 +933,9 @@ namespace OpenTK.Platform.SDL2 } set { - if (value == is_cursor_visible) return; lock (sync) { - if (Exists) + if (Exists && value != is_cursor_visible) { GrabCursor(!value); is_cursor_visible = value; diff --git a/src/OpenTK/Platform/Windows/WinGLNative.cs b/src/OpenTK/Platform/Windows/WinGLNative.cs index 44b66999..a5714c27 100644 --- a/src/OpenTK/Platform/Windows/WinGLNative.cs +++ b/src/OpenTK/Platform/Windows/WinGLNative.cs @@ -1256,10 +1256,17 @@ namespace OpenTK.Platform.Windows public override bool CursorVisible { - get { return cursor_visible_count >= 0; } + get + { + return cursor_visible_count >= 0; + } set { - if (value && cursor_visible_count < 0) + if (value == CursorVisible) + { + return; + } + if (value) { do { @@ -1269,7 +1276,7 @@ namespace OpenTK.Platform.Windows UngrabCursor(); } - else if (!value && cursor_visible_count >= 0) + else { do { diff --git a/src/OpenTK/Platform/X11/X11GLNative.cs b/src/OpenTK/Platform/X11/X11GLNative.cs index ac4a13a8..4de9eb85 100644 --- a/src/OpenTK/Platform/X11/X11GLNative.cs +++ b/src/OpenTK/Platform/X11/X11GLNative.cs @@ -1684,12 +1684,19 @@ namespace OpenTK.Platform.X11 public override bool CursorVisible { - get { return cursor_visible; } + get + { + return cursor_visible; + } set { - if (value && !cursor_visible) + if (value == cursor_visible) { - using (new XLock(window.Display)) + return; + } + using (new XLock(window.Display)) + { + if (value) { UngrabMouse(); @@ -1699,16 +1706,12 @@ namespace OpenTK.Platform.X11 // Note: if cursorHandle = IntPtr.Zero, this restores the default cursor // (equivalent to calling XUndefineCursor) Functions.XDefineCursor(window.Display, window.Handle, cursorHandle); - cursor_visible = true; } - } - else if (!value && cursor_visible) - { - using (new XLock(window.Display)) + else { GrabMouse(); - cursor_visible = false; } + cursor_visible = value; } } }