mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
[macOS] Replace custom main loop with [NSApp run] and CFRunLoop observer.
This commit is contained in:
@@ -40,6 +40,13 @@
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
class OS_MacOS : public OS_Unix {
|
||||
const char *execpath = nullptr;
|
||||
int argc = 0;
|
||||
char **argv = nullptr;
|
||||
|
||||
id delegate = nullptr;
|
||||
bool should_terminate = false;
|
||||
|
||||
JoypadApple *joypad_apple = nullptr;
|
||||
|
||||
#ifdef COREAUDIO_ENABLED
|
||||
@@ -51,7 +58,7 @@ class OS_MacOS : public OS_Unix {
|
||||
|
||||
CrashHandler crash_handler;
|
||||
|
||||
CFRunLoopObserverRef pre_wait_observer;
|
||||
CFRunLoopObserverRef pre_wait_observer = nil;
|
||||
|
||||
MainLoop *main_loop = nullptr;
|
||||
|
||||
@@ -64,6 +71,8 @@ class OS_MacOS : public OS_Unix {
|
||||
static _FORCE_INLINE_ String get_framework_executable(const String &p_path);
|
||||
static void pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context);
|
||||
|
||||
void terminate();
|
||||
|
||||
protected:
|
||||
virtual void initialize_core() override;
|
||||
virtual void initialize() override;
|
||||
@@ -131,8 +140,13 @@ public:
|
||||
virtual String get_system_ca_certificates() override;
|
||||
virtual OS::PreferredTextureFormat get_preferred_texture_format() const override;
|
||||
|
||||
void run();
|
||||
void run(); // Runs macOS native event loop.
|
||||
void start_main(); // Initializes and runs Godot main loop.
|
||||
void activate();
|
||||
void cleanup();
|
||||
bool os_should_terminate() const { return should_terminate; }
|
||||
int get_cmd_argc() const { return argc; }
|
||||
|
||||
OS_MacOS();
|
||||
OS_MacOS(const char *p_execpath, int p_argc, char **p_argv);
|
||||
~OS_MacOS();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user