Refactored timer installation/removal into their own methods.
This commit is contained in:
parent
c2d92f5aca
commit
2cec4c1696
1 changed files with 26 additions and 13 deletions
|
@ -168,27 +168,20 @@ namespace OpenTK.Platform.Windows
|
||||||
if (new_focused_state != Focused && FocusedChanged != null)
|
if (new_focused_state != Focused && FocusedChanged != null)
|
||||||
FocusedChanged(this, EventArgs.Empty);
|
FocusedChanged(this, EventArgs.Empty);
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
case WindowMessage.ENTERMENULOOP:
|
case WindowMessage.ENTERMENULOOP:
|
||||||
case WindowMessage.ENTERSIZEMOVE:
|
case WindowMessage.ENTERSIZEMOVE:
|
||||||
// Entering the modal size/move loop: we don't want rendering to
|
// Entering the modal size/move loop: we don't want rendering to
|
||||||
// stop during this time, so we register a timer callback to continue
|
// stop during this time, so we register a timer callback to continue
|
||||||
// processing from time to time.
|
// processing from time to time.
|
||||||
timer_handle = Functions.SetTimer(handle, ModalLoopTimerId, ModalLoopTimerPeriod, ModalLoopCallback);
|
StartTimer(handle);
|
||||||
if (timer_handle == UIntPtr.Zero)
|
|
||||||
Debug.Print("[Warning] Failed to set modal loop timer callback ({0}:{1}->{2}).",
|
|
||||||
GetType().Name, handle, Marshal.GetLastWin32Error());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WindowMessage.EXITMENULOOP:
|
case WindowMessage.EXITMENULOOP:
|
||||||
case WindowMessage.EXITSIZEMOVE:
|
case WindowMessage.EXITSIZEMOVE:
|
||||||
// ExitingmModal size/move loop: the timer callback is no longer
|
// ExitingmModal size/move loop: the timer callback is no longer
|
||||||
// necessary.
|
// necessary.
|
||||||
if (!Functions.KillTimer(handle, timer_handle))
|
StopTimer(handle);
|
||||||
Debug.Print("[Warning] Failed to kill modal loop timer callback ({0}:{1}->{2}).",
|
|
||||||
GetType().Name, handle, Marshal.GetLastWin32Error());
|
|
||||||
timer_handle = UIntPtr.Zero;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WindowMessage.NCCALCSIZE:
|
case WindowMessage.NCCALCSIZE:
|
||||||
|
@ -304,9 +297,7 @@ namespace OpenTK.Platform.Windows
|
||||||
(int)(lParam.ToInt32() & 0xFFFF0000) >> 16);
|
(int)(lParam.ToInt32() & 0xFFFF0000) >> 16);
|
||||||
mouse.Position = point;
|
mouse.Position = point;
|
||||||
{
|
{
|
||||||
Win32Rectangle rect;
|
if (!ClientRectangle.Contains(point))
|
||||||
Functions.GetClientRect(window.WindowHandle, out rect);
|
|
||||||
if (!rect.ToRectangle().Contains(point))
|
|
||||||
{
|
{
|
||||||
Functions.ReleaseCapture();
|
Functions.ReleaseCapture();
|
||||||
if (MouseLeave != null)
|
if (MouseLeave != null)
|
||||||
|
@ -502,6 +493,28 @@ namespace OpenTK.Platform.Windows
|
||||||
return Functions.DefWindowProc(handle, message, wParam, lParam);
|
return Functions.DefWindowProc(handle, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StartTimer(IntPtr handle)
|
||||||
|
{
|
||||||
|
if (timer_handle == UIntPtr.Zero)
|
||||||
|
{
|
||||||
|
timer_handle = Functions.SetTimer(handle, ModalLoopTimerId, ModalLoopTimerPeriod, ModalLoopCallback);
|
||||||
|
if (timer_handle == UIntPtr.Zero)
|
||||||
|
Debug.Print("[Warning] Failed to set modal loop timer callback ({0}:{1}->{2}).",
|
||||||
|
GetType().Name, handle, Marshal.GetLastWin32Error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopTimer(IntPtr handle)
|
||||||
|
{
|
||||||
|
if (timer_handle != UIntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (!Functions.KillTimer(handle, timer_handle))
|
||||||
|
Debug.Print("[Warning] Failed to kill modal loop timer callback ({0}:{1}->{2}).",
|
||||||
|
GetType().Name, handle, Marshal.GetLastWin32Error());
|
||||||
|
timer_handle = UIntPtr.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IsIdle
|
#region IsIdle
|
||||||
|
|
Loading…
Reference in a new issue