From 8ec577b9ca25117af326a7131a51a11a46ffdf99 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Fri, 9 Feb 2018 07:51:51 +1030 Subject: [PATCH] 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) --- src/OpenTK/Platform/MacOS/Cocoa/Cocoa.cs | 3 +++ src/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/OpenTK/Platform/MacOS/Cocoa/Cocoa.cs b/src/OpenTK/Platform/MacOS/Cocoa/Cocoa.cs index 982f1a23..459117c1 100644 --- a/src/OpenTK/Platform/MacOS/Cocoa/Cocoa.cs +++ b/src/OpenTK/Platform/MacOS/Cocoa/Cocoa.cs @@ -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); diff --git a/src/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs b/src/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs index 6f4bbf01..ba8f4683 100644 --- a/src/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs +++ b/src/OpenTK/Platform/MacOS/Cocoa/NSApplication.cs @@ -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)