Skip to content

Commit

Permalink
[X11] Fixed Cursor when CursorVisible = false
Browse files Browse the repository at this point in the history
Setting Cursor will no longer override CursorVisible.
  • Loading branch information
thefiddler committed May 13, 2014
1 parent 290cc91 commit fc71802
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Source/OpenTK/Platform/X11/X11GLNative.cs
Expand Up @@ -1441,11 +1441,18 @@ public override MouseCursor Cursor
{
unsafe
{
if (value == cursor)
return;

using (new XLock(window.Display))
{
if (value == MouseCursor.Default)
{
Functions.XUndefineCursor(window.Display, window.Handle);
cursorHandle = IntPtr.Zero;
}
else if (value == MouseCursor.Empty)
{
cursorHandle = EmptyCursor;
}
else
{
Expand All @@ -1457,16 +1464,28 @@ public override MouseCursor Cursor
xcursorimage->pixels = (uint*)pixels;
xcursorimage->delay = 0;
cursorHandle = Functions.XcursorImageLoadCursor(window.Display, xcursorimage);
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
Functions.XcursorImageDestroy(xcursorimage);
}
}

// If the cursor is visible set it now.
// Otherwise, it will be set in CursorVisible = true.
if (CursorVisible)
{
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
}

cursor = value;
}
}
}
}

void SetCursor(IntPtr handle)
{
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
}

#endregion

#region CursorVisible
Expand All @@ -1480,6 +1499,8 @@ public override bool CursorVisible
{
using (new XLock(window.Display))
{
// Note: if cursorHandle = IntPtr.Zero, this function
// is equivalent to XUndefineCursor.
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
cursor_visible = true;
}
Expand Down

0 comments on commit fc71802

Please sign in to comment.