mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 08:35:39 +00:00
Respond to WM_SETCURSOR messages.
Calling SetCursor on mouse moves is not enough, we need to respond to SETCURSOR messages. If we have a custom cursor we need to call SetCursor and then NOT call DefWindowProc, otherwise we just call DefWindowProc for the forms default cursor.
This commit is contained in:
parent
251a6e813e
commit
10112da976
|
@ -388,6 +388,17 @@ namespace OpenTK.Platform.Windows
|
|||
}
|
||||
}
|
||||
|
||||
private bool HandleSetCursor(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (cursor != MouseCursor.Default)
|
||||
{
|
||||
Functions.SetCursor(curson_handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandleChar(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
char c;
|
||||
|
@ -486,11 +497,6 @@ namespace OpenTK.Platform.Windows
|
|||
mouse_last_timestamp = timestamp;
|
||||
}
|
||||
|
||||
if (cursor != MouseCursor.Default)
|
||||
{
|
||||
Functions.SetCursor(curson_handle);
|
||||
}
|
||||
|
||||
if (mouse_outside_window)
|
||||
{
|
||||
// Once we receive a mouse move event, it means that the mouse has
|
||||
|
@ -660,6 +666,8 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
#region Size / Move / Style events
|
||||
|
@ -693,6 +701,10 @@ namespace OpenTK.Platform.Windows
|
|||
HandleSize(handle, message, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WindowMessage.SETCURSOR:
|
||||
result = HandleSetCursor(handle, message, wParam, lParam);
|
||||
break;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Input events
|
||||
|
@ -779,7 +791,15 @@ namespace OpenTK.Platform.Windows
|
|||
#endregion
|
||||
}
|
||||
|
||||
return Functions.DefWindowProc(handle, message, wParam, lParam);
|
||||
if (result)
|
||||
{
|
||||
// Return TRUE
|
||||
return new IntPtr(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Functions.DefWindowProc(handle, message, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableMouseTracking()
|
||||
|
|
Loading…
Reference in a new issue