commit 5f2ed0625c0e3da1916f3b3c422523a66f87137f
parent 2d5dd370c6c9f7528e29ebee8c686da9a909773d
Author: falkTX <falktx@falktx.com>
Date: Tue, 2 Aug 2022 13:45:47 +0100
Hook into macOS CF runloop for standalones
Diffstat:
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/dgl/src/Application.cpp b/dgl/src/Application.cpp
@@ -16,8 +16,10 @@
#include "ApplicationPrivateData.hpp"
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__)
# include <emscripten/emscripten.h>
+#elif defined(DISTRHO_OS_MAC)
+# include <CoreFoundation/CoreFoundation.h>
#endif
START_NAMESPACE_DGL
@@ -48,8 +50,18 @@ void Application::exec(const uint idleTimeInMs)
{
DISTRHO_SAFE_ASSERT_RETURN(pData->isStandalone,);
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__)
emscripten_set_main_loop_arg(app_idle, this, 0, true);
+#elif defined(DISTRHO_OS_MAC)
+ const CFTimeInterval idleTimeInSecs = static_cast<CFTimeInterval>(idleTimeInMs) / 1000;
+
+ while (! pData->isQuitting)
+ {
+ pData->idle(0);
+
+ if (CFRunLoopRunInMode(kCFRunLoopDefaultMode, idleTimeInSecs, true) == kCFRunLoopRunFinished)
+ break;
+ }
#else
while (! pData->isQuitting)
pData->idle(idleTimeInMs);