mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 04:26:57 +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)
|
void glWindow_Destroy(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
glWindow.Destroy -= glWindow_Destroy;
|
glWindow.Destroy -= glWindow_Destroy;
|
||||||
|
this.Exit();
|
||||||
Debug.Print("GameWindow destruction imminent.");
|
|
||||||
this.isExiting = true;
|
|
||||||
//this.OnDestroy(EventArgs.Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -322,27 +319,6 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#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()
|
#region public void DestroyWindow()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -352,37 +328,13 @@ namespace OpenTK
|
||||||
public void DestroyWindow()
|
public void DestroyWindow()
|
||||||
{
|
{
|
||||||
if (Exists)
|
if (Exists)
|
||||||
{
|
|
||||||
glWindow.DestroyWindow();
|
glWindow.DestroyWindow();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
throw new ApplicationException("Tried to destroy non-existent window.");
|
||||||
throw new ApplicationException("Tried to destroy inexistent window.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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
|
#endregion
|
||||||
|
|
||||||
#region --- GameWindow Methods ---
|
#region --- GameWindow Methods ---
|
||||||
|
@ -584,17 +536,19 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
catch (GameWindowExitException)
|
catch (GameWindowExitException)
|
||||||
{
|
{
|
||||||
Trace.WriteLine("GameWindow.Exit() request");
|
Trace.WriteLine("Exiting main loop.");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Debug.Print("Restoring priority.");
|
||||||
Thread.CurrentThread.Priority = ThreadPriority.Normal;
|
Thread.CurrentThread.Priority = ThreadPriority.Normal;
|
||||||
|
|
||||||
OnUnloadInternal(EventArgs.Empty);
|
OnUnloadInternal(EventArgs.Empty);
|
||||||
|
|
||||||
if (this.Exists)
|
if (this.Exists)
|
||||||
{
|
{
|
||||||
glWindow.DestroyWindow();
|
if (Exists)
|
||||||
|
glWindow.DestroyWindow();
|
||||||
while (this.Exists)
|
while (this.Exists)
|
||||||
{
|
{
|
||||||
this.ProcessEvents();
|
this.ProcessEvents();
|
||||||
|
|
|
@ -134,11 +134,12 @@ namespace OpenTK.Platform.X11
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.ClientMessage:
|
case XEventName.ClientMessage:
|
||||||
case XEventName.DestroyNotify:
|
|
||||||
// TODO: Check whether using ClientMessage here is 100% correct.
|
|
||||||
|
|
||||||
this.exists = false;
|
|
||||||
this.OnDestroy(EventArgs.Empty);
|
this.OnDestroy(EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XEventName.DestroyNotify:
|
||||||
|
this.exists = false;
|
||||||
|
//this.OnDestroy(EventArgs.Empty);
|
||||||
isExiting = true;
|
isExiting = true;
|
||||||
Debug.Print("X11 window {0} destroyed.", e.DestroyWindowEvent.window);
|
Debug.Print("X11 window {0} destroyed.", e.DestroyWindowEvent.window);
|
||||||
return;
|
return;
|
||||||
|
@ -476,7 +477,6 @@ namespace OpenTK.Platform.X11
|
||||||
public void DestroyWindow()
|
public void DestroyWindow()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("X11GLNative shutdown sequence initiated.");
|
Debug.WriteLine("X11GLNative shutdown sequence initiated.");
|
||||||
// Functions.XUnmapWindow(window.Display, window.Handle);
|
|
||||||
Functions.XDestroyWindow(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());
|
Debug.Print("Destroy event fired from window: {0}", window.ToString());
|
||||||
if (this.Destroy != null)
|
if (this.Destroy != null)
|
||||||
{
|
|
||||||
this.Destroy(this, e);
|
this.Destroy(this, e);
|
||||||
}
|
|
||||||
|
|
||||||
Functions.XUnmapWindow(window.Display, window.Handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -615,17 +611,19 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
if (!disposed)
|
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 (manuallyCalled)
|
||||||
{
|
{
|
||||||
if (glContext != null)
|
if (glContext != null)
|
||||||
glContext.Dispose();
|
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;
|
disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue