diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs
index dd8d38d9..7b2eb7b7 100644
--- a/Source/OpenTK/GameWindow.cs
+++ b/Source/OpenTK/GameWindow.cs
@@ -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;
-
- ///
- /// Raises the Create event. Override in derived classes to initialize resources.
- ///
- ///
- [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()
///
@@ -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
-
- ///
- /// Raises the Destroy event. Override in derived classes, to modify the shutdown
- /// sequence (e.g. to release resources before shutdown).
- ///
- ///
- 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();
diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs
index 316ff65a..684b8cd9 100644
--- a/Source/OpenTK/Platform/X11/X11GLNative.cs
+++ b/Source/OpenTK/Platform/X11/X11GLNative.cs
@@ -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;
}
}