MacOS: Fix event from user clicking close box to properly report that window doesn't exist anymore.

This commit is contained in:
kanato 2009-11-09 07:18:54 +00:00
parent 8bd20009b2
commit dad798d41d
2 changed files with 14 additions and 11 deletions

View file

@ -700,18 +700,18 @@ namespace OpenTK.Platform.MacOS.Carbon
{ {
IntPtr windowTarget = GetWindowEventTarget(windowRef); IntPtr windowTarget = GetWindowEventTarget(windowRef);
Debug.Print("Window: {0}", windowRef); //Debug.Print("Window: {0}", windowRef);
Debug.Print("Window Target: {0}", windowTarget); //Debug.Print("Window Target: {0}", windowTarget);
Debug.Print("Handler: {0}", uppHandlerProc); //Debug.Print("Handler: {0}", uppHandlerProc);
Debug.Print("Num Events: {0}", eventTypes.Length); //Debug.Print("Num Events: {0}", eventTypes.Length);
Debug.Print("User Data: {0}", userData); //Debug.Print("User Data: {0}", userData);
Debug.Print("Handler Ref: {0}", handlerRef); //Debug.Print("Handler Ref: {0}", handlerRef);
OSStatus error = _InstallEventHandler(windowTarget, uppHandlerProc, OSStatus error = _InstallEventHandler(windowTarget, uppHandlerProc,
eventTypes.Length, eventTypes, eventTypes.Length, eventTypes,
userData, handlerRef); userData, handlerRef);
Debug.Print("Status: {0}", error); //Debug.Print("Status: {0}", error);
if (error != OSStatus.NoError) if (error != OSStatus.NoError)
{ {

View file

@ -52,6 +52,7 @@ namespace OpenTK.Platform.MacOS
string title = "OpenTK Window"; string title = "OpenTK Window";
Rectangle bounds, windowedBounds, clientRectangle; Rectangle bounds, windowedBounds, clientRectangle;
bool mIsDisposed = false; bool mIsDisposed = false;
bool mExists = true;
WindowAttributes mWindowAttrib; WindowAttributes mWindowAttrib;
WindowClass mWindowClass; WindowClass mWindowClass;
@ -112,6 +113,7 @@ namespace OpenTK.Platform.MacOS
Debug.Print("Disposing of CarbonGLNative window."); Debug.Print("Disposing of CarbonGLNative window.");
mIsDisposed = true; mIsDisposed = true;
mExists = false;
if (disposing) if (disposing)
{ {
@ -289,8 +291,8 @@ namespace OpenTK.Platform.MacOS
return OSStatus.EventNotHandled; 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); //Debug.Print("Processing {0} event for {1}.", evt, window.window);
@ -366,7 +368,8 @@ namespace OpenTK.Platform.MacOS
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
case WindowEventKind.WindowClosed: case WindowEventKind.WindowClosed:
OnClosed(); mExists = false;
OnClosed();
return OSStatus.NoError; return OSStatus.NoError;
@ -639,7 +642,7 @@ namespace OpenTK.Platform.MacOS
public bool Exists public bool Exists
{ {
get { return !mIsDisposed; } get { return mExists; }
} }
public IWindowInfo WindowInfo public IWindowInfo WindowInfo