Permalink
Browse files

[Win] Only set MouseCursor in client area

This is required according to the windows documentation.
  • Loading branch information...
1 parent 9988a2b commit 9ee728d4fc71052af6252a5dc284ff6587c8a9df @thefiddler thefiddler committed May 1, 2014
Showing with 15 additions and 8 deletions.
  1. +15 −8 Source/OpenTK/Platform/Windows/WinGLNative.cs
View
23 Source/OpenTK/Platform/Windows/WinGLNative.cs
@@ -102,7 +102,7 @@ internal sealed class WinGLNative : INativeWindow, IInputDriver
KeyPressEventArgs key_press = new KeyPressEventArgs((char)0);
MouseCursor cursor = MouseCursor.Default;
- IntPtr curson_handle = IntPtr.Zero;
+ IntPtr cursor_handle = Functions.LoadCursor(CursorName.Arrow);
int cursor_visible_count = 0;
static readonly object SyncRoot = new object();
@@ -392,8 +392,14 @@ void HandleSize(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lPar
{
if (cursor != MouseCursor.Default)
{
- Functions.SetCursor(curson_handle);
- return new IntPtr(1);
+ // Only set the mouse cursor inside the client rectangle
+ // See MSDN "Setting the Cursor Image"
+ const int ht_client = 1;
+ if ((lParam.ToInt64() & 0xffff) == ht_client)
+ {
+ Functions.SetCursor(cursor_handle);
+ return new IntPtr(1);
+ }
}
return null;
@@ -1208,7 +1214,8 @@ public MouseCursor Cursor
if (value == MouseCursor.Default)
{
- oldCursor = Functions.SetCursor(Functions.LoadCursor(CursorName.Arrow));
+ cursor_handle = Functions.LoadCursor(CursorName.Arrow);
+ oldCursor = Functions.SetCursor(cursor_handle);
cursor = value;
}
else
@@ -1245,7 +1252,7 @@ public MouseCursor Cursor
// Currently using a custom cursor so destroy it
// once replaced
cursor = value;
- curson_handle = icon;
+ cursor_handle = icon;
oldCursor = Functions.SetCursor(icon);
}
}
@@ -1639,10 +1646,10 @@ void Dispose(bool calledManually)
{
if (calledManually)
{
- if (Cursor != MouseCursor.Default && curson_handle != IntPtr.Zero)
+ if (Cursor != MouseCursor.Default && cursor_handle != IntPtr.Zero)
{
- Functions.DestroyIcon(curson_handle);
- curson_handle = IntPtr.Zero;
+ Functions.DestroyIcon(cursor_handle);
+ cursor_handle = IntPtr.Zero;
}
// Safe to clean managed resources

0 comments on commit 9ee728d

Please sign in to comment.