mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 16:55:28 +00:00
* Source/OpenTK/Platform/X11/X11GLNative.cs: Refactored empty cursor
creation into its own function. Create one empty cursor for the lifetime of the window.
This commit is contained in:
parent
63b35badee
commit
527cdf8622
|
@ -113,6 +113,8 @@ namespace OpenTK.Platform.X11
|
|||
readonly char[] chars = new char[16];
|
||||
readonly KeyPressEventArgs KPEventArgs = new KeyPressEventArgs('\0');
|
||||
|
||||
readonly IntPtr EmptyCursor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
@ -195,6 +197,8 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
driver = new X11Input(window);
|
||||
|
||||
EmptyCursor = CreateEmptyCursor(window);
|
||||
|
||||
Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle));
|
||||
Debug.Unindent();
|
||||
|
||||
|
@ -677,6 +681,22 @@ namespace OpenTK.Platform.X11
|
|||
}
|
||||
}
|
||||
|
||||
static IntPtr CreateEmptyCursor(X11WindowInfo window)
|
||||
{
|
||||
IntPtr cursor = IntPtr.Zero;
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
XColor black, dummy;
|
||||
IntPtr cmap = Functions.XDefaultColormap(window.Display, window.Screen);
|
||||
Functions.XAllocNamedColor(window.Display, cmap, "black", out black, out dummy);
|
||||
IntPtr bmp_empty = Functions.XCreateBitmapFromData(window.Display,
|
||||
window.WindowHandle, new byte[,] { { 0 } });
|
||||
cursor = Functions.XCreatePixmapCursor(window.Display,
|
||||
bmp_empty, bmp_empty, ref black, ref black, 0, 0);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INativeWindow Members
|
||||
|
@ -1302,7 +1322,7 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
public bool CursorVisible
|
||||
{
|
||||
get { return true; }
|
||||
get { return true; } // Not used
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
|
@ -1316,17 +1336,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
XColor black, dummy;
|
||||
IntPtr cmap = Functions.XDefaultColormap(window.Display, window.Screen);
|
||||
Functions.XAllocNamedColor(window.Display, cmap, "black", out black, out dummy);
|
||||
IntPtr bmp_empty = Functions.XCreateBitmapFromData(window.Display,
|
||||
window.WindowHandle, new byte[,] { { 0 } });
|
||||
IntPtr cursor_empty = Functions.XCreatePixmapCursor(window.Display,
|
||||
bmp_empty, bmp_empty, ref black, ref black, 0, 0);
|
||||
|
||||
Functions.XDefineCursor(window.Display, window.WindowHandle, cursor_empty);
|
||||
|
||||
Functions.XFreeCursor(window.Display, cursor_empty);
|
||||
Functions.XDefineCursor(window.Display, window.WindowHandle, EmptyCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1553,6 +1563,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
using (new XLock(window.Display))
|
||||
{
|
||||
Functions.XFreeCursor(window.Display, EmptyCursor);
|
||||
Functions.XDestroyWindow(window.Display, window.WindowHandle);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue