mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 04:06:49 +00:00
Fixed shutdown sequence on Linux. GameWindow.Exit() and clicking the 'close' button now produce the same result.
This commit is contained in:
parent
b4f044b293
commit
6dc133d9eb
|
@ -133,10 +133,7 @@ namespace OpenTK
|
|||
void glWindow_Destroy(object sender, EventArgs e)
|
||||
{
|
||||
glWindow.Destroy -= glWindow_Destroy;
|
||||
|
||||
Debug.Print("GameWindow destruction imminent.");
|
||||
this.isExiting = true;
|
||||
//this.OnDestroy(EventArgs.Empty);
|
||||
this.Exit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -322,27 +319,6 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region OnCreate
|
||||
|
||||
[Obsolete("The Create event is obsolete and will be removed on later versions. Use the Load event instead.")]
|
||||
public event CreateEvent Create;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Create event. Override in derived classes to initialize resources.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
[Obsolete("The OnCreate method is obsolete and will be removed on later versions. Use the OnLoad method instead.")]
|
||||
public virtual void OnCreate(EventArgs e)
|
||||
{
|
||||
Debug.WriteLine("Firing GameWindow.Create event");
|
||||
if (this.Create != null)
|
||||
{
|
||||
this.Create(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public void DestroyWindow()
|
||||
|
||||
/// <summary>
|
||||
|
@ -352,37 +328,13 @@ namespace OpenTK
|
|||
public void DestroyWindow()
|
||||
{
|
||||
if (Exists)
|
||||
{
|
||||
glWindow.DestroyWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException("Tried to destroy inexistent window.");
|
||||
}
|
||||
throw new ApplicationException("Tried to destroy non-existent window.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnDestroy
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Destroy event. Override in derived classes, to modify the shutdown
|
||||
/// sequence (e.g. to release resources before shutdown).
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public virtual void OnDestroy(EventArgs e)
|
||||
{
|
||||
Debug.WriteLine("Firing GameWindow.Destroy event");
|
||||
if (this.Destroy != null)
|
||||
{
|
||||
this.Destroy(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
public event DestroyEvent Destroy;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- GameWindow Methods ---
|
||||
|
@ -584,17 +536,19 @@ namespace OpenTK
|
|||
}
|
||||
catch (GameWindowExitException)
|
||||
{
|
||||
Trace.WriteLine("GameWindow.Exit() request");
|
||||
Trace.WriteLine("Exiting main loop.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Debug.Print("Restoring priority.");
|
||||
Thread.CurrentThread.Priority = ThreadPriority.Normal;
|
||||
|
||||
OnUnloadInternal(EventArgs.Empty);
|
||||
|
||||
if (this.Exists)
|
||||
{
|
||||
glWindow.DestroyWindow();
|
||||
if (Exists)
|
||||
glWindow.DestroyWindow();
|
||||
while (this.Exists)
|
||||
{
|
||||
this.ProcessEvents();
|
||||
|
|
|
@ -134,11 +134,12 @@ namespace OpenTK.Platform.X11
|
|||
break;
|
||||
|
||||
case XEventName.ClientMessage:
|
||||
case XEventName.DestroyNotify:
|
||||
// TODO: Check whether using ClientMessage here is 100% correct.
|
||||
|
||||
this.exists = false;
|
||||
this.OnDestroy(EventArgs.Empty);
|
||||
break;
|
||||
|
||||
case XEventName.DestroyNotify:
|
||||
this.exists = false;
|
||||
//this.OnDestroy(EventArgs.Empty);
|
||||
isExiting = true;
|
||||
Debug.Print("X11 window {0} destroyed.", e.DestroyWindowEvent.window);
|
||||
return;
|
||||
|
@ -476,7 +477,6 @@ namespace OpenTK.Platform.X11
|
|||
public void DestroyWindow()
|
||||
{
|
||||
Debug.WriteLine("X11GLNative shutdown sequence initiated.");
|
||||
// Functions.XUnmapWindow(window.Display, window.Handle);
|
||||
Functions.XDestroyWindow(window.Display, window.Handle);
|
||||
}
|
||||
|
||||
|
@ -490,11 +490,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
Debug.Print("Destroy event fired from window: {0}", window.ToString());
|
||||
if (this.Destroy != null)
|
||||
{
|
||||
this.Destroy(this, e);
|
||||
}
|
||||
|
||||
Functions.XUnmapWindow(window.Display, window.Handle);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -615,17 +611,19 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (Exists)
|
||||
Functions.XDestroyWindow(window.Display, window.Handle);
|
||||
// Kills connection to the X-Server. We don't want that,
|
||||
// 'cause it kills the ExampleLauncher too.
|
||||
//API.CloseDisplay(display);
|
||||
|
||||
if (manuallyCalled)
|
||||
{
|
||||
if (glContext != null)
|
||||
glContext.Dispose();
|
||||
|
||||
// Kills connection to the X-Server. We don't want that,
|
||||
// 'cause it kills the ExampleLauncher too.
|
||||
//Functions.XCloseDisplay(window.Display);
|
||||
}
|
||||
|
||||
Functions.XUnmapWindow(window.Display, window.Handle);
|
||||
Functions.XDestroyWindow(window.Display, window.Handle);
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue