Fix a bug in X11 CursorVisble with custom cursors.
CursorVisible reset to the default cursor when showing the cursor, it should instead show the custom cursor if it's defined (else the default cursor).
This commit is contained in:
parent
9ed32e4445
commit
2207144aec
1 changed files with 22 additions and 10 deletions
|
@ -117,6 +117,7 @@ namespace OpenTK.Platform.X11
|
|||
bool _decorations_hidden = false;
|
||||
|
||||
MouseCursor cursor = MouseCursor.Default;
|
||||
IntPtr cursorHandle;
|
||||
bool cursor_visible = true;
|
||||
int mouse_rel_x, mouse_rel_y;
|
||||
|
||||
|
@ -1475,6 +1476,12 @@ namespace OpenTK.Platform.X11
|
|||
unsafe
|
||||
{
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
if (value == MouseCursor.Default)
|
||||
{
|
||||
Functions.XUndefineCursor(window.Display, window.Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
fixed(byte* pixels = value.Rgba)
|
||||
{
|
||||
|
@ -1483,14 +1490,15 @@ namespace OpenTK.Platform.X11
|
|||
xcursorimage->yhot = (uint)value.Y;
|
||||
xcursorimage->pixels = (uint*)pixels;
|
||||
xcursorimage->delay = 0;
|
||||
var xcursor = Functions.XcursorImageLoadCursor(window.Display, xcursorimage);
|
||||
Functions.XDefineCursor(window.Display, window.Handle, xcursor);
|
||||
cursorHandle = Functions.XcursorImageLoadCursor(window.Display, xcursorimage);
|
||||
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
||||
Functions.XcursorImageDestroy(xcursorimage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -1505,7 +1513,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
Functions.XUndefineCursor(window.Display, window.Handle);
|
||||
Functions.XDefineCursor(window.Display, window.Handle, cursorHandle);
|
||||
cursor_visible = true;
|
||||
}
|
||||
}
|
||||
|
@ -1742,6 +1750,10 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
if(cursorHandle != IntPtr.Zero)
|
||||
{
|
||||
Functions.XFreeCursor(window.Display, cursorHandle);
|
||||
}
|
||||
Functions.XFreeCursor(window.Display, EmptyCursor);
|
||||
Functions.XDestroyWindow(window.Display, window.Handle);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue