[X11] Fixed Cursor when CursorVisible = false
Setting Cursor will no longer override CursorVisible.
This commit is contained in:
parent
290cc91275
commit
fc718026fd
1 changed files with 23 additions and 2 deletions
|
@ -1441,11 +1441,18 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
if (value == cursor)
|
||||||
|
return;
|
||||||
|
|
||||||
using (new XLock(window.Display))
|
using (new XLock(window.Display))
|
||||||
{
|
{
|
||||||
if (value == MouseCursor.Default)
|
if (value == MouseCursor.Default)
|
||||||
{
|
{
|
||||||
Functions.XUndefineCursor(window.Display, window.Handle);
|
cursorHandle = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
else if (value == MouseCursor.Empty)
|
||||||
|
{
|
||||||
|
cursorHandle = EmptyCursor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1457,16 +1464,28 @@ namespace OpenTK.Platform.X11
|
||||||
xcursorimage->pixels = (uint*)pixels;
|
xcursorimage->pixels = (uint*)pixels;
|
||||||
xcursorimage->delay = 0;
|
xcursorimage->delay = 0;
|
||||||
cursorHandle = Functions.XcursorImageLoadCursor(window.Display, xcursorimage);
|
cursorHandle = Functions.XcursorImageLoadCursor(window.Display, xcursorimage);
|
||||||
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
|
||||||
Functions.XcursorImageDestroy(xcursorimage);
|
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;
|
cursor = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCursor(IntPtr handle)
|
||||||
|
{
|
||||||
|
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region CursorVisible
|
#region CursorVisible
|
||||||
|
@ -1480,6 +1499,8 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
using (new XLock(window.Display))
|
using (new XLock(window.Display))
|
||||||
{
|
{
|
||||||
|
// Note: if cursorHandle = IntPtr.Zero, this function
|
||||||
|
// is equivalent to XUndefineCursor.
|
||||||
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
||||||
cursor_visible = true;
|
cursor_visible = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue