mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 00:25:26 +00:00
Refactored timer installation/removal into their own methods.
This commit is contained in:
parent
bf8e2c695a
commit
b36e6c64d7
|
@ -174,21 +174,14 @@ namespace OpenTK.Platform.Windows
|
|||
// Entering the modal size/move loop: we don't want rendering to
|
||||
// stop during this time, so we register a timer callback to continue
|
||||
// processing from time to time.
|
||||
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());
|
||||
|
||||
StartTimer(handle);
|
||||
break;
|
||||
|
||||
case WindowMessage.EXITMENULOOP:
|
||||
case WindowMessage.EXITSIZEMOVE:
|
||||
// ExitingmModal size/move loop: the timer callback is no longer
|
||||
// necessary.
|
||||
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;
|
||||
StopTimer(handle);
|
||||
break;
|
||||
|
||||
case WindowMessage.NCCALCSIZE:
|
||||
|
@ -304,9 +297,7 @@ namespace OpenTK.Platform.Windows
|
|||
(int)(lParam.ToInt32() & 0xFFFF0000) >> 16);
|
||||
mouse.Position = point;
|
||||
{
|
||||
Win32Rectangle rect;
|
||||
Functions.GetClientRect(window.WindowHandle, out rect);
|
||||
if (!rect.ToRectangle().Contains(point))
|
||||
if (!ClientRectangle.Contains(point))
|
||||
{
|
||||
Functions.ReleaseCapture();
|
||||
if (MouseLeave != null)
|
||||
|
@ -502,6 +493,28 @@ namespace OpenTK.Platform.Windows
|
|||
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
|
||||
|
||||
#region IsIdle
|
||||
|
|
Loading…
Reference in a new issue