From c605a05ffba380e69b73372306696277d8e054d7 Mon Sep 17 00:00:00 2001 From: kanato Date: Mon, 9 Nov 2009 07:18:54 +0000 Subject: [PATCH] MacOS: Fix event from user clicking close box to properly report that window doesn't exist anymore. --- .../Platform/MacOS/CarbonBindings/CarbonAPI.cs | 14 +++++++------- Source/OpenTK/Platform/MacOS/CarbonGLNative.cs | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index d54bd404..1e7bc61a 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -700,18 +700,18 @@ namespace OpenTK.Platform.MacOS.Carbon { IntPtr windowTarget = GetWindowEventTarget(windowRef); - Debug.Print("Window: {0}", windowRef); - Debug.Print("Window Target: {0}", windowTarget); - Debug.Print("Handler: {0}", uppHandlerProc); - Debug.Print("Num Events: {0}", eventTypes.Length); - Debug.Print("User Data: {0}", userData); - Debug.Print("Handler Ref: {0}", handlerRef); + //Debug.Print("Window: {0}", windowRef); + //Debug.Print("Window Target: {0}", windowTarget); + //Debug.Print("Handler: {0}", uppHandlerProc); + //Debug.Print("Num Events: {0}", eventTypes.Length); + //Debug.Print("User Data: {0}", userData); + //Debug.Print("Handler Ref: {0}", handlerRef); OSStatus error = _InstallEventHandler(windowTarget, uppHandlerProc, eventTypes.Length, eventTypes, userData, handlerRef); - Debug.Print("Status: {0}", error); + //Debug.Print("Status: {0}", error); if (error != OSStatus.NoError) { diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 7af5aa2d..d4c65a92 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -52,6 +52,7 @@ namespace OpenTK.Platform.MacOS string title = "OpenTK Window"; Rectangle bounds, windowedBounds, clientRectangle; bool mIsDisposed = false; + bool mExists = true; WindowAttributes mWindowAttrib; WindowClass mWindowClass; @@ -112,6 +113,7 @@ namespace OpenTK.Platform.MacOS Debug.Print("Disposing of CarbonGLNative window."); mIsDisposed = true; + mExists = false; if (disposing) { @@ -289,8 +291,8 @@ namespace OpenTK.Platform.MacOS return OSStatus.EventNotHandled; } - EventInfo evt = new EventInfo(inEvent); - CarbonGLNative window = (CarbonGLNative)reference.Target; + CarbonGLNative window = (CarbonGLNative)reference.Target; + EventInfo evt = new EventInfo(inEvent); //Debug.Print("Processing {0} event for {1}.", evt, window.window); @@ -366,7 +368,8 @@ namespace OpenTK.Platform.MacOS return OSStatus.EventNotHandled; case WindowEventKind.WindowClosed: - OnClosed(); + mExists = false; + OnClosed(); return OSStatus.NoError; @@ -639,7 +642,7 @@ namespace OpenTK.Platform.MacOS public bool Exists { - get { return !mIsDisposed; } + get { return mExists; } } public IWindowInfo WindowInfo