Permalink
Browse files

Closing should occur in ProcessEvents.

  • Loading branch information...
1 parent ed87814 commit 46856dc21dcff1faf3dff072ab9794170b71df8c @Ollhax Ollhax committed with thefiddler Apr 21, 2014
Showing with 26 additions and 17 deletions.
  1. +26 −17 Source/OpenTK/Platform/MacOS/CocoaNativeWindow.cs
@@ -100,11 +100,12 @@ static CocoaNativeWindow()
private MacOSKeyMap keyMap = new MacOSKeyMap();
private OpenTK.Input.KeyboardKeyEventArgs keyArgs = new OpenTK.Input.KeyboardKeyEventArgs();
private KeyPressEventArgs keyPressArgs = new KeyPressEventArgs((char)0);
- string title;
- RectangleF normalBounds;
- int normalLevel;
+ private string title;
+ private RectangleF normalBounds;
+ private int normalLevel;
+ private bool shouldClose;
- const bool exclusiveFullscreen = true;
+ private const bool exclusiveFullscreen = false;
public CocoaNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{
@@ -280,19 +281,7 @@ private void ResetTrackingArea()
public void Close()
{
- // PerformClose is equivalent to pressing the close-button, which
- // does not work in a borderless window. Handle this special case.
- if (GetStyleMask() == NSWindowStyle.Borderless)
- {
- if (WindowShouldClose(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
- {
- Cocoa.SendVoid(windowInfo.Handle, selClose);
- }
- }
- else
- {
- Cocoa.SendVoid(windowInfo.Handle, selPerformClose, windowInfo.Handle);
- }
+ shouldClose = true;
}
private KeyModifiers GetModifiers(NSEventModifierMask mask)
@@ -462,6 +451,26 @@ public void ProcessEvents()
Cocoa.SendVoid(NSApplication.Handle, selSendEvent, e);
}
+
+ // Handle closing
+ if (shouldClose)
+ {
+ shouldClose = false;
+
+ // PerformClose is equivalent to pressing the close-button, which
+ // does not work in a borderless window. Handle this special case.
+ if (GetStyleMask() == NSWindowStyle.Borderless)
+ {
+ if (WindowShouldClose(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
+ {
+ Cocoa.SendVoid(windowInfo.Handle, selClose);
+ }
+ }
+ else
+ {
+ Cocoa.SendVoid(windowInfo.Handle, selPerformClose, windowInfo.Handle);
+ }
+ }
}
public System.Drawing.Point PointToClient(System.Drawing.Point point)

0 comments on commit 46856dc

Please sign in to comment.