Fixes an issue on macOS where having unprocessed events on the event queue on startup (mouse movements, etc.) would put the app in a partially-activated state and not take window focus (#732)

This commit is contained in:
Shane Woolcock 2018-02-09 07:51:51 +10:30 committed by Jarl Gullberg
parent f3c545eef1
commit 8ec577b9ca
2 changed files with 4 additions and 0 deletions

View file

@ -100,6 +100,9 @@ namespace OpenTK.Platform.MacOS
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
public extern static void SendVoid(IntPtr receiver, IntPtr selector, uint uint1);
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
public extern static void SendVoid(IntPtr receiver, IntPtr selector, uint uint1, IntPtr intPtr1);
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
public extern static void SendVoid(IntPtr receiver, IntPtr selector, IntPtr intPtr1);

View file

@ -57,6 +57,7 @@ namespace OpenTK.Platform.MacOS
// Setup the application
Cocoa.SendBool(Handle, Selector.Get("setActivationPolicy:"), (int)NSApplicationActivationPolicy.Regular);
Cocoa.SendVoid(Handle, Selector.Get("discardEventsMatchingMask:beforeEvent:"), uint.MaxValue, IntPtr.Zero);
Cocoa.SendVoid(Handle, Selector.Get("activateIgnoringOtherApps:"), true);
if (Cocoa.SendIntPtr(Handle, Selector.Get("mainMenu")) == IntPtr.Zero)