Revert "Fix issue #19"

This reverts commit 2c14ec5f80.
This commit is contained in:
Stefanos A 2013-12-21 00:41:55 +01:00
parent 2c14ec5f80
commit e1619a8ad3

View file

@ -257,7 +257,7 @@ namespace OpenTK.Platform.Windows
if (new_focused_state != Focused) if (new_focused_state != Focused)
FocusedChanged(this, EventArgs.Empty); FocusedChanged(this, EventArgs.Empty);
return IntPtr.Zero; break;
case WindowMessage.ENTERMENULOOP: case WindowMessage.ENTERMENULOOP:
case WindowMessage.ENTERSIZEMOVE: case WindowMessage.ENTERSIZEMOVE:
@ -269,7 +269,7 @@ namespace OpenTK.Platform.Windows
if (!CursorVisible) if (!CursorVisible)
UngrabCursor(); UngrabCursor();
return IntPtr.Zero; break;
case WindowMessage.EXITMENULOOP: case WindowMessage.EXITMENULOOP:
case WindowMessage.EXITSIZEMOVE: case WindowMessage.EXITSIZEMOVE:
@ -327,7 +327,7 @@ namespace OpenTK.Platform.Windows
} }
} }
} }
return IntPtr.Zero; break;
case WindowMessage.STYLECHANGED: case WindowMessage.STYLECHANGED:
unsafe unsafe
@ -348,7 +348,7 @@ namespace OpenTK.Platform.Windows
if (!CursorVisible) if (!CursorVisible)
GrabCursor(); GrabCursor();
return IntPtr.Zero; break;
case WindowMessage.SIZE: case WindowMessage.SIZE:
SizeMessage state = (SizeMessage)wParam.ToInt64(); SizeMessage state = (SizeMessage)wParam.ToInt64();
@ -373,7 +373,7 @@ namespace OpenTK.Platform.Windows
GrabCursor(); GrabCursor();
} }
return IntPtr.Zero; break;
#endregion #endregion
@ -386,7 +386,7 @@ namespace OpenTK.Platform.Windows
key_press.KeyChar = (char)wParam.ToInt64(); key_press.KeyChar = (char)wParam.ToInt64();
KeyPress(this, key_press); KeyPress(this, key_press);
return IntPtr.Zero; break;
case WindowMessage.MOUSEMOVE: case WindowMessage.MOUSEMOVE:
Point point = new Point( Point point = new Point(
@ -403,62 +403,62 @@ namespace OpenTK.Platform.Windows
MouseEnter(this, EventArgs.Empty); MouseEnter(this, EventArgs.Empty);
} }
return IntPtr.Zero; break;
case WindowMessage.MOUSELEAVE: case WindowMessage.MOUSELEAVE:
mouse_outside_window = true; mouse_outside_window = true;
// Mouse tracking is disabled automatically by the OS // Mouse tracking is disabled automatically by the OS
MouseLeave(this, EventArgs.Empty); MouseLeave(this, EventArgs.Empty);
return IntPtr.Zero; break;
case WindowMessage.MOUSEWHEEL: case WindowMessage.MOUSEWHEEL:
// This is due to inconsistent behavior of the WParam value on 64bit arch, whese // This is due to inconsistent behavior of the WParam value on 64bit arch, whese
// wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f; mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f;
return IntPtr.Zero; break;
case WindowMessage.LBUTTONDOWN: case WindowMessage.LBUTTONDOWN:
Functions.SetCapture(window.Handle); Functions.SetCapture(window.Handle);
mouse[MouseButton.Left] = true; mouse[MouseButton.Left] = true;
return IntPtr.Zero; break;
case WindowMessage.MBUTTONDOWN: case WindowMessage.MBUTTONDOWN:
Functions.SetCapture(window.Handle); Functions.SetCapture(window.Handle);
mouse[MouseButton.Middle] = true; mouse[MouseButton.Middle] = true;
return IntPtr.Zero; break;
case WindowMessage.RBUTTONDOWN: case WindowMessage.RBUTTONDOWN:
Functions.SetCapture(window.Handle); Functions.SetCapture(window.Handle);
mouse[MouseButton.Right] = true; mouse[MouseButton.Right] = true;
return IntPtr.Zero; break;
case WindowMessage.XBUTTONDOWN: case WindowMessage.XBUTTONDOWN:
Functions.SetCapture(window.Handle); Functions.SetCapture(window.Handle);
mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) !=
(int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true; (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true;
return IntPtr.Zero; break;
case WindowMessage.LBUTTONUP: case WindowMessage.LBUTTONUP:
Functions.ReleaseCapture(); Functions.ReleaseCapture();
mouse[MouseButton.Left] = false; mouse[MouseButton.Left] = false;
return IntPtr.Zero; break;
case WindowMessage.MBUTTONUP: case WindowMessage.MBUTTONUP:
Functions.ReleaseCapture(); Functions.ReleaseCapture();
mouse[MouseButton.Middle] = false; mouse[MouseButton.Middle] = false;
return IntPtr.Zero; break;
case WindowMessage.RBUTTONUP: case WindowMessage.RBUTTONUP:
Functions.ReleaseCapture(); Functions.ReleaseCapture();
mouse[MouseButton.Right] = false; mouse[MouseButton.Right] = false;
return IntPtr.Zero; break;
case WindowMessage.XBUTTONUP: case WindowMessage.XBUTTONUP:
Functions.ReleaseCapture(); Functions.ReleaseCapture();
mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) !=
(int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false; (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false;
return IntPtr.Zero; break;
// Keyboard events: // Keyboard events:
case WindowMessage.KEYDOWN: case WindowMessage.KEYDOWN:
@ -494,7 +494,7 @@ namespace OpenTK.Platform.Windows
case WindowMessage.KILLFOCUS: case WindowMessage.KILLFOCUS:
keyboard.ClearKeys(); keyboard.ClearKeys();
return IntPtr.Zero; break;
#endregion #endregion
@ -515,7 +515,7 @@ namespace OpenTK.Platform.Windows
invisible_since_creation = true; invisible_since_creation = true;
} }
return IntPtr.Zero; break;
case WindowMessage.CLOSE: case WindowMessage.CLOSE:
System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();
@ -532,16 +532,18 @@ namespace OpenTK.Platform.Windows
case WindowMessage.DESTROY: case WindowMessage.DESTROY:
exists = false; exists = false;
Closed(this, EventArgs.Empty);
return IntPtr.Zero;
case WindowMessage.GETICON: Functions.UnregisterClass(ClassName, Instance);
window.Dispose();
child_window.Dispose();
Closed(this, EventArgs.Empty);
break; break;
#endregion #endregion
} }
Debug.Print(message.ToString());
return Functions.DefWindowProc(handle, message, wParam, lParam); return Functions.DefWindowProc(handle, message, wParam, lParam);
} }
@ -852,8 +854,8 @@ namespace OpenTK.Platform.Windows
icon = value; icon = value;
if (window.Handle != IntPtr.Zero) if (window.Handle != IntPtr.Zero)
{ {
Functions.PostMessage(window.Handle, WindowMessage.SETICON, (IntPtr)0, icon == null ? IntPtr.Zero : value.Handle); Functions.SendMessage(window.Handle, WindowMessage.SETICON, (IntPtr)0, icon == null ? IntPtr.Zero : value.Handle);
Functions.PostMessage(window.Handle, WindowMessage.SETICON, (IntPtr)1, icon == null ? IntPtr.Zero : value.Handle); Functions.SendMessage(window.Handle, WindowMessage.SETICON, (IntPtr)1, icon == null ? IntPtr.Zero : value.Handle);
} }
IconChanged(this, EventArgs.Empty); IconChanged(this, EventArgs.Empty);
} }
@ -1205,7 +1207,7 @@ namespace OpenTK.Platform.Windows
MSG msg; MSG msg;
public void ProcessEvents() public void ProcessEvents()
{ {
while (Functions.PeekMessage(ref msg, IntPtr.Zero, 0, 0, PeekMessageFlags.Remove)) while (Functions.PeekMessage(ref msg, window.Handle, 0, 0, PeekMessageFlags.Remove))
{ {
Functions.TranslateMessage(ref msg); Functions.TranslateMessage(ref msg);
Functions.DispatchMessage(ref msg); Functions.DispatchMessage(ref msg);
@ -1296,14 +1298,8 @@ namespace OpenTK.Platform.Windows
{ {
// Safe to clean managed resources // Safe to clean managed resources
DestroyWindow(); DestroyWindow();
Functions.UnregisterClass(ClassName, Instance);
window.Dispose();
child_window.Dispose();
if (Icon != null) if (Icon != null)
Icon.Dispose(); Icon.Dispose();
if (ClassName != IntPtr.Zero)
Marshal.FreeHGlobal(ClassName);
} }
else else
{ {