Update conditionals and formatting

This commit is contained in:
copygirl 2018-01-05 18:43:03 +01:00
parent d86967eb7c
commit 3d9d6d7ee3
4 changed files with 30 additions and 23 deletions

View file

@ -1236,21 +1236,19 @@ namespace OpenTK.Platform.MacOS
public override bool CursorVisible public override bool CursorVisible
{ {
get { return cursorVisible; } get
{
return cursorVisible;
}
set set
{ {
if (value == cursorVisible) return; if (value != cursorVisible)
if (value && !cursorVisible)
{ {
SetCursorVisible(true); SetCursorVisible(value);
}
else if (!value && cursorVisible)
{
SetCursorVisible(false);
}
cursorVisible = value; cursorVisible = value;
} }
} }
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {

View file

@ -933,10 +933,9 @@ namespace OpenTK.Platform.SDL2
} }
set set
{ {
if (value == is_cursor_visible) return;
lock (sync) lock (sync)
{ {
if (Exists) if (Exists && value != is_cursor_visible)
{ {
GrabCursor(!value); GrabCursor(!value);
is_cursor_visible = value; is_cursor_visible = value;

View file

@ -1256,10 +1256,17 @@ namespace OpenTK.Platform.Windows
public override bool CursorVisible public override bool CursorVisible
{ {
get { return cursor_visible_count >= 0; } get
{
return cursor_visible_count >= 0;
}
set set
{ {
if (value && cursor_visible_count < 0) if (value == CursorVisible)
{
return;
}
if (value)
{ {
do do
{ {
@ -1269,7 +1276,7 @@ namespace OpenTK.Platform.Windows
UngrabCursor(); UngrabCursor();
} }
else if (!value && cursor_visible_count >= 0) else
{ {
do do
{ {

View file

@ -1684,12 +1684,19 @@ namespace OpenTK.Platform.X11
public override bool CursorVisible public override bool CursorVisible
{ {
get { return cursor_visible; } get
{
return cursor_visible;
}
set set
{ {
if (value && !cursor_visible) if (value == cursor_visible)
{ {
return;
}
using (new XLock(window.Display)) using (new XLock(window.Display))
{
if (value)
{ {
UngrabMouse(); UngrabMouse();
@ -1699,16 +1706,12 @@ namespace OpenTK.Platform.X11
// Note: if cursorHandle = IntPtr.Zero, this restores the default cursor // Note: if cursorHandle = IntPtr.Zero, this restores the default cursor
// (equivalent to calling XUndefineCursor) // (equivalent to calling XUndefineCursor)
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle); Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
cursor_visible = true;
} }
} else
else if (!value && cursor_visible)
{
using (new XLock(window.Display))
{ {
GrabMouse(); GrabMouse();
cursor_visible = false;
} }
cursor_visible = value;
} }
} }
} }