[X11] Fixed Cursor when CursorVisible = false

Setting Cursor will no longer override CursorVisible.
This commit is contained in:
thefiddler 2014-05-13 09:27:21 +02:00
parent 290cc91275
commit fc718026fd

View file

@ -1441,11 +1441,18 @@ namespace OpenTK.Platform.X11
{
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 @@ namespace OpenTK.Platform.X11
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 @@ namespace OpenTK.Platform.X11
{
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;
}