mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-23 05:01:12 +00:00
Simplify ProcessEvents implementation
Instead of combining PeekMessage+GetMessage, we can simply call PeekMessage(Remove) to achieve the same effect. This also allows us to remove the IsIdle property, which is no longer used anywhere.
This commit is contained in:
parent
6493ab0188
commit
1edfa8f3de
|
@ -349,7 +349,7 @@ namespace OpenTK.Platform.Windows
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity]
|
[System.Security.SuppressUnmanagedCodeSecurity]
|
||||||
[DllImport("User32.dll"), CLSCompliant(false)]
|
[DllImport("User32.dll"), CLSCompliant(false)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
|
internal static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, PeekMessageFlags flags);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -4028,6 +4028,18 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region PeekMessageFlags
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
enum PeekMessageFlags : uint
|
||||||
|
{
|
||||||
|
NoRemove = 0,
|
||||||
|
Remove = 1,
|
||||||
|
NoYield = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region ShowWindowCommand
|
#region ShowWindowCommand
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -583,19 +583,6 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IsIdle
|
|
||||||
|
|
||||||
bool IsIdle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
MSG message = new MSG();
|
|
||||||
return !Functions.PeekMessage(ref message, window.Handle, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region CreateWindow
|
#region CreateWindow
|
||||||
|
|
||||||
IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
|
IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
|
||||||
|
@ -1217,20 +1204,11 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region public void ProcessEvents()
|
#region public void ProcessEvents()
|
||||||
|
|
||||||
private int ret;
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
public void ProcessEvents()
|
public void ProcessEvents()
|
||||||
{
|
{
|
||||||
while (!IsIdle)
|
while (Functions.PeekMessage(ref msg, window.Handle, 0, 0, PeekMessageFlags.Remove))
|
||||||
{
|
{
|
||||||
ret = Functions.GetMessage(ref msg, window.Handle, 0, 0);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
throw new PlatformException(String.Format(
|
|
||||||
"An error happened while processing the message queue. Windows error: {0}",
|
|
||||||
Marshal.GetLastWin32Error()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Functions.TranslateMessage(ref msg);
|
Functions.TranslateMessage(ref msg);
|
||||||
Functions.DispatchMessage(ref msg);
|
Functions.DispatchMessage(ref msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue