Permalink
Browse files

[X11] Fixed Cursor when CursorVisible = false

Setting Cursor will no longer override CursorVisible.
  • Loading branch information...
1 parent 290cc91 commit fc718026fd84576425578c7b6d0cc34755ea36d1 @thefiddler thefiddler committed May 13, 2014
Showing with 23 additions and 2 deletions.
  1. +23 −2 Source/OpenTK/Platform/X11/X11GLNative.cs
View
25 Source/OpenTK/Platform/X11/X11GLNative.cs
@@ -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
{
@@ -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
@@ -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;
}

0 comments on commit fc71802

Please sign in to comment.