mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-07 16:40:39 +00:00
Partial implementation of Windows MouseCursor.
Very buggy, but starting to show results.
This commit is contained in:
parent
0dd82e1485
commit
8f9311ec8d
|
@ -102,6 +102,7 @@ namespace OpenTK.Platform.Windows
|
||||||
KeyPressEventArgs key_press = new KeyPressEventArgs((char)0);
|
KeyPressEventArgs key_press = new KeyPressEventArgs((char)0);
|
||||||
|
|
||||||
MouseCursor cursor = MouseCursor.Default;
|
MouseCursor cursor = MouseCursor.Default;
|
||||||
|
IntPtr curson_handle = IntPtr.Zero;
|
||||||
int cursor_visible_count = 0;
|
int cursor_visible_count = 0;
|
||||||
|
|
||||||
static readonly object SyncRoot = new object();
|
static readonly object SyncRoot = new object();
|
||||||
|
@ -485,6 +486,11 @@ namespace OpenTK.Platform.Windows
|
||||||
mouse_last_timestamp = timestamp;
|
mouse_last_timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cursor != MouseCursor.Default)
|
||||||
|
{
|
||||||
|
Functions.SetCursor(curson_handle);
|
||||||
|
}
|
||||||
|
|
||||||
if (mouse_outside_window)
|
if (mouse_outside_window)
|
||||||
{
|
{
|
||||||
// Once we receive a mouse move event, it means that the mouse has
|
// Once we receive a mouse move event, it means that the mouse has
|
||||||
|
@ -1176,7 +1182,51 @@ namespace OpenTK.Platform.Windows
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Debug.Print("[Warning] WinGLNative.Cursor property not implemented");
|
if (value != cursor)
|
||||||
|
{
|
||||||
|
var stride = value.Width *
|
||||||
|
(Bitmap.GetPixelFormatSize(System.Drawing.Imaging.PixelFormat.Format32bppArgb) / 8);
|
||||||
|
|
||||||
|
Bitmap bmp;
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
fixed (byte* pixels = value.Rgba)
|
||||||
|
{
|
||||||
|
bmp = new Bitmap(value.Width, value.Height, stride,
|
||||||
|
System.Drawing.Imaging.PixelFormat.Format32bppArgb,
|
||||||
|
new IntPtr(pixels));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var iconInfo = new IconInfo();
|
||||||
|
var bmpIcon = bmp.GetHicon();
|
||||||
|
var success = Functions.GetIconInfo(bmpIcon, out iconInfo);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
iconInfo.xHotspot = value.X;
|
||||||
|
iconInfo.yHotspot = value.Y;
|
||||||
|
iconInfo.fIcon = false;
|
||||||
|
|
||||||
|
var icon = Functions.CreateIconIndirect(ref iconInfo);
|
||||||
|
|
||||||
|
if (icon != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
// Currently using a custom cursor so destroy it
|
||||||
|
// once replaced
|
||||||
|
bool destoryOld = cursor != MouseCursor.Default;
|
||||||
|
|
||||||
|
cursor = value;
|
||||||
|
curson_handle = icon;
|
||||||
|
var oldCursor = Functions.SetCursor(icon);
|
||||||
|
|
||||||
|
if (destoryOld)
|
||||||
|
{
|
||||||
|
Functions.DestroyIcon(oldCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue