mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-26 03:01:05 +00:00
Generate Update/ResizeFrame events whenever the window is moved or resized. Partially fix for issue [#1218]: "[NativeWindow] Avoid modal loop during window resize/movement".
This commit is contained in:
parent
c0528707c3
commit
e441e9d067
|
@ -372,7 +372,6 @@ namespace OpenTK
|
||||||
|
|
||||||
Stopwatch update_watch = new Stopwatch(), render_watch = new Stopwatch();
|
Stopwatch update_watch = new Stopwatch(), render_watch = new Stopwatch();
|
||||||
double next_render = 0.0, next_update = 0.0;
|
double next_render = 0.0, next_update = 0.0;
|
||||||
int num_updates = 0;
|
|
||||||
FrameEventArgs update_args = new FrameEventArgs();
|
FrameEventArgs update_args = new FrameEventArgs();
|
||||||
FrameEventArgs render_args = new FrameEventArgs();
|
FrameEventArgs render_args = new FrameEventArgs();
|
||||||
|
|
||||||
|
@ -382,13 +381,24 @@ namespace OpenTK
|
||||||
Visible = true; // Make sure the GameWindow is visible.
|
Visible = true; // Make sure the GameWindow is visible.
|
||||||
OnLoadInternal(EventArgs.Empty);
|
OnLoadInternal(EventArgs.Empty);
|
||||||
|
|
||||||
|
// On some platforms, ProcessEvents() does not return while the user is resizing or moving
|
||||||
|
// the window. We can avoid this issue by raising UpdateFrame and RenderFrame events
|
||||||
|
// whenever we encounter a size or move event.
|
||||||
|
EventHandler<EventArgs> DispatchUpdateAndRenderFrame = delegate(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RaiseUpdateFrame(update_watch, ref next_update, update_args);
|
||||||
|
RaiseRenderFrame(render_watch, ref next_render, render_args);
|
||||||
|
};
|
||||||
|
|
||||||
|
Move += DispatchUpdateAndRenderFrame;
|
||||||
|
Resize += DispatchUpdateAndRenderFrame;
|
||||||
|
|
||||||
Debug.Print("Entering main loop.");
|
Debug.Print("Entering main loop.");
|
||||||
while (!IsExiting && Exists)
|
while (!IsExiting && Exists)
|
||||||
{
|
{
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
|
|
||||||
RaiseUpdateFrame(update_watch, ref next_update, update_args);
|
DispatchUpdateAndRenderFrame(this, EventArgs.Empty);
|
||||||
RaiseRenderFrame(render_watch, ref next_render, render_args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -53,10 +53,7 @@ namespace OpenTK.Platform.Windows
|
||||||
readonly UIntPtr ModalLoopTimerId = new UIntPtr(1);
|
readonly UIntPtr ModalLoopTimerId = new UIntPtr(1);
|
||||||
readonly uint ModalLoopTimerPeriod = 1;
|
readonly uint ModalLoopTimerPeriod = 1;
|
||||||
UIntPtr timer_handle;
|
UIntPtr timer_handle;
|
||||||
readonly Functions.TimerProc ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time)
|
readonly Functions.TimerProc ModalLoopCallback;
|
||||||
{
|
|
||||||
// Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events.
|
|
||||||
};
|
|
||||||
|
|
||||||
bool class_registered;
|
bool class_registered;
|
||||||
bool disposed;
|
bool disposed;
|
||||||
|
@ -99,6 +96,14 @@ namespace OpenTK.Platform.Windows
|
||||||
// don't move it below the CreateWindow calls.
|
// don't move it below the CreateWindow calls.
|
||||||
WindowProcedureDelegate = WindowProcedure;
|
WindowProcedureDelegate = WindowProcedure;
|
||||||
|
|
||||||
|
// This timer callback is called periodically when the window enters a sizing / moving modal loop.
|
||||||
|
ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time)
|
||||||
|
{
|
||||||
|
// Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events.
|
||||||
|
if (Move != null)
|
||||||
|
Move(this, EventArgs.Empty);
|
||||||
|
};
|
||||||
|
|
||||||
// To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be
|
// To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be
|
||||||
// bound to the top-level window, but rather to a child window docked in the parent.
|
// bound to the top-level window, but rather to a child window docked in the parent.
|
||||||
window = new WinWindowInfo(
|
window = new WinWindowInfo(
|
||||||
|
|
Loading…
Reference in a new issue