os_osx.mm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /*************************************************************************/
  2. /* os_osx.mm */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "os_osx.h"
  31. #include "core/version_generated.gen.h"
  32. #include "dir_access_osx.h"
  33. #include "display_server_osx.h"
  34. #include "main/main.h"
  35. #include <dlfcn.h>
  36. #include <libproc.h>
  37. #include <mach-o/dyld.h>
  38. #include <os/log.h>
  39. #define DS_OSX ((DisplayServerOSX *)(DisplayServerOSX::get_singleton()))
  40. /*************************************************************************/
  41. /* GodotApplication */
  42. /*************************************************************************/
  43. @interface GodotApplication : NSApplication
  44. @end
  45. @implementation GodotApplication
  46. - (void)sendEvent:(NSEvent *)event {
  47. if (DS_OSX) {
  48. DS_OSX->_send_event(event);
  49. }
  50. // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
  51. // This works around an AppKit bug, where key up events while holding
  52. // down the command key don't get sent to the key window.
  53. if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand)) {
  54. [[self keyWindow] sendEvent:event];
  55. } else {
  56. [super sendEvent:event];
  57. }
  58. }
  59. @end
  60. /*************************************************************************/
  61. /* GodotApplicationDelegate */
  62. /*************************************************************************/
  63. @interface GodotApplicationDelegate : NSObject
  64. - (void)forceUnbundledWindowActivationHackStep1;
  65. - (void)forceUnbundledWindowActivationHackStep2;
  66. - (void)forceUnbundledWindowActivationHackStep3;
  67. @end
  68. @implementation GodotApplicationDelegate
  69. - (void)forceUnbundledWindowActivationHackStep1 {
  70. // Step1: Switch focus to macOS Dock.
  71. // Required to perform step 2, TransformProcessType will fail if app is already the in focus.
  72. for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
  73. [app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
  74. break;
  75. }
  76. [self performSelector:@selector(forceUnbundledWindowActivationHackStep2)
  77. withObject:nil
  78. afterDelay:0.02];
  79. }
  80. - (void)forceUnbundledWindowActivationHackStep2 {
  81. // Step 2: Register app as foreground process.
  82. ProcessSerialNumber psn = { 0, kCurrentProcess };
  83. (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication);
  84. [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02];
  85. }
  86. - (void)forceUnbundledWindowActivationHackStep3 {
  87. // Step 3: Switch focus back to app window.
  88. [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
  89. }
  90. - (void)applicationDidFinishLaunching:(NSNotification *)notice {
  91. NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
  92. if (nsappname == nil) {
  93. // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored).
  94. [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02];
  95. }
  96. }
  97. - (void)applicationDidResignActive:(NSNotification *)notification {
  98. if (OS::get_singleton()->get_main_loop()) {
  99. OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
  100. }
  101. }
  102. - (void)applicationDidBecomeActive:(NSNotification *)notification {
  103. if (OS::get_singleton()->get_main_loop()) {
  104. OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN);
  105. }
  106. }
  107. - (void)globalMenuCallback:(id)sender {
  108. if (DS_OSX) {
  109. return DS_OSX->_menu_callback(sender);
  110. }
  111. }
  112. - (NSMenu *)applicationDockMenu:(NSApplication *)sender {
  113. if (DS_OSX) {
  114. return DS_OSX->_get_dock_menu();
  115. } else {
  116. return nullptr;
  117. }
  118. }
  119. - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
  120. // Note: may be called called before main loop init!
  121. char *utfs = strdup([filename UTF8String]);
  122. ((OS_OSX *)OS_OSX::get_singleton())->open_with_filename.parse_utf8(utfs);
  123. free(utfs);
  124. #ifdef TOOLS_ENABLED
  125. // Open new instance
  126. if (OS_OSX::get_singleton()->get_main_loop()) {
  127. List<String> args;
  128. args.push_back(((OS_OSX *)OS_OSX::get_singleton())->open_with_filename);
  129. String exec = OS_OSX::get_singleton()->get_executable_path();
  130. OS_OSX::get_singleton()->create_process(exec, args);
  131. }
  132. #endif
  133. return YES;
  134. }
  135. - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
  136. if (DS_OSX) {
  137. DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
  138. }
  139. return NSTerminateCancel;
  140. }
  141. - (void)showAbout:(id)sender {
  142. if (OS_OSX::get_singleton()->get_main_loop()) {
  143. OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT);
  144. }
  145. }
  146. @end
  147. /*************************************************************************/
  148. /* OSXTerminalLogger */
  149. /*************************************************************************/
  150. class OSXTerminalLogger : public StdLogger {
  151. public:
  152. virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) {
  153. if (!should_log(true)) {
  154. return;
  155. }
  156. const char *err_details;
  157. if (p_rationale && p_rationale[0])
  158. err_details = p_rationale;
  159. else
  160. err_details = p_code;
  161. switch (p_type) {
  162. case ERR_WARNING:
  163. os_log_info(OS_LOG_DEFAULT,
  164. "WARNING: %{public}s\nat: %{public}s (%{public}s:%i)",
  165. err_details, p_function, p_file, p_line);
  166. logf_error("\E[1;33mWARNING:\E[0;93m %s\n", err_details);
  167. logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
  168. break;
  169. case ERR_SCRIPT:
  170. os_log_error(OS_LOG_DEFAULT,
  171. "SCRIPT ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
  172. err_details, p_function, p_file, p_line);
  173. logf_error("\E[1;35mSCRIPT ERROR:\E[0;95m %s\n", err_details);
  174. logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
  175. break;
  176. case ERR_SHADER:
  177. os_log_error(OS_LOG_DEFAULT,
  178. "SHADER ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
  179. err_details, p_function, p_file, p_line);
  180. logf_error("\E[1;36mSHADER ERROR:\E[0;96m %s\n", err_details);
  181. logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
  182. break;
  183. case ERR_ERROR:
  184. default:
  185. os_log_error(OS_LOG_DEFAULT,
  186. "ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
  187. err_details, p_function, p_file, p_line);
  188. logf_error("\E[1;31mERROR:\E[0;91m %s\n", err_details);
  189. logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
  190. break;
  191. }
  192. }
  193. };
  194. /*************************************************************************/
  195. /* OS_OSX */
  196. /*************************************************************************/
  197. String OS_OSX::get_unique_id() const {
  198. static String serial_number;
  199. if (serial_number.is_empty()) {
  200. io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
  201. CFStringRef serialNumberAsCFString = nullptr;
  202. if (platformExpert) {
  203. serialNumberAsCFString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
  204. IOObjectRelease(platformExpert);
  205. }
  206. NSString *serialNumberAsNSString = nil;
  207. if (serialNumberAsCFString) {
  208. serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString];
  209. CFRelease(serialNumberAsCFString);
  210. }
  211. serial_number = [serialNumberAsNSString UTF8String];
  212. }
  213. return serial_number;
  214. }
  215. void OS_OSX::alert(const String &p_alert, const String &p_title) {
  216. NSAlert *window = [[NSAlert alloc] init];
  217. NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
  218. NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()];
  219. [window addButtonWithTitle:@"OK"];
  220. [window setMessageText:ns_title];
  221. [window setInformativeText:ns_alert];
  222. [window setAlertStyle:NSAlertStyleWarning];
  223. id key_window = [[NSApplication sharedApplication] keyWindow];
  224. [window runModal];
  225. [window release];
  226. if (key_window) {
  227. [key_window makeKeyAndOrderFront:nil];
  228. }
  229. }
  230. void OS_OSX::initialize_core() {
  231. OS_Unix::initialize_core();
  232. DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES);
  233. DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA);
  234. DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
  235. }
  236. void OS_OSX::initialize_joypads() {
  237. joypad_osx = memnew(JoypadOSX(Input::get_singleton()));
  238. }
  239. void OS_OSX::initialize() {
  240. crash_handler.initialize();
  241. initialize_core();
  242. //ensure_user_data_dir();
  243. }
  244. void OS_OSX::finalize() {
  245. #ifdef COREMIDI_ENABLED
  246. midi_driver.close();
  247. #endif
  248. delete_main_loop();
  249. if (joypad_osx) {
  250. memdelete(joypad_osx);
  251. }
  252. }
  253. void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
  254. main_loop = p_main_loop;
  255. }
  256. void OS_OSX::delete_main_loop() {
  257. if (!main_loop)
  258. return;
  259. memdelete(main_loop);
  260. main_loop = nullptr;
  261. }
  262. String OS_OSX::get_name() const {
  263. return "macOS";
  264. }
  265. _FORCE_INLINE_ String _get_framework_executable(const String p_path) {
  266. // Append framework executable name, or return as is if p_path is not a framework.
  267. DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  268. if (da->dir_exists(p_path) && da->file_exists(p_path.plus_file(p_path.get_file().get_basename()))) {
  269. return p_path.plus_file(p_path.get_file().get_basename());
  270. } else {
  271. return p_path;
  272. }
  273. }
  274. Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
  275. String path = _get_framework_executable(p_path);
  276. if (!FileAccess::exists(path)) {
  277. // This code exists so gdnative can load .dylib files from within the executable path.
  278. path = _get_framework_executable(get_executable_path().get_base_dir().plus_file(p_path.get_file()));
  279. }
  280. if (!FileAccess::exists(path)) {
  281. // This code exists so gdnative can load .dylib files from a standard macOS location.
  282. path = _get_framework_executable(get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file()));
  283. }
  284. p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
  285. ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + dlerror() + ".");
  286. return OK;
  287. }
  288. MainLoop *OS_OSX::get_main_loop() const {
  289. return main_loop;
  290. }
  291. String OS_OSX::get_config_path() const {
  292. // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well.
  293. if (has_environment("XDG_CONFIG_HOME")) {
  294. if (get_environment("XDG_CONFIG_HOME").is_absolute_path()) {
  295. return get_environment("XDG_CONFIG_HOME");
  296. } else {
  297. WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Application Support` or `.` per the XDG Base Directory specification.");
  298. }
  299. }
  300. if (has_environment("HOME")) {
  301. return get_environment("HOME").plus_file("Library/Application Support");
  302. }
  303. return ".";
  304. }
  305. String OS_OSX::get_data_path() const {
  306. // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well.
  307. if (has_environment("XDG_DATA_HOME")) {
  308. if (get_environment("XDG_DATA_HOME").is_absolute_path()) {
  309. return get_environment("XDG_DATA_HOME");
  310. } else {
  311. WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification.");
  312. }
  313. }
  314. return get_config_path();
  315. }
  316. String OS_OSX::get_cache_path() const {
  317. // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well.
  318. if (has_environment("XDG_CACHE_HOME")) {
  319. if (get_environment("XDG_CACHE_HOME").is_absolute_path()) {
  320. return get_environment("XDG_CACHE_HOME");
  321. } else {
  322. WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Caches` or `get_config_path()` per the XDG Base Directory specification.");
  323. }
  324. }
  325. if (has_environment("HOME")) {
  326. return get_environment("HOME").plus_file("Library/Caches");
  327. }
  328. return get_config_path();
  329. }
  330. String OS_OSX::get_bundle_resource_dir() const {
  331. String ret;
  332. NSBundle *main = [NSBundle mainBundle];
  333. if (main) {
  334. NSString *resourcePath = [main resourcePath];
  335. ret.parse_utf8([resourcePath UTF8String]);
  336. }
  337. return ret;
  338. }
  339. String OS_OSX::get_bundle_icon_path() const {
  340. String ret;
  341. NSBundle *main = [NSBundle mainBundle];
  342. if (main) {
  343. NSString *iconPath = [[main infoDictionary] objectForKey:@"CFBundleIconFile"];
  344. if (iconPath) {
  345. ret.parse_utf8([iconPath UTF8String]);
  346. }
  347. }
  348. return ret;
  349. }
  350. // Get properly capitalized engine name for system paths
  351. String OS_OSX::get_godot_dir_name() const {
  352. return String(VERSION_SHORT_NAME).capitalize();
  353. }
  354. String OS_OSX::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
  355. NSSearchPathDirectory id;
  356. bool found = true;
  357. switch (p_dir) {
  358. case SYSTEM_DIR_DESKTOP: {
  359. id = NSDesktopDirectory;
  360. } break;
  361. case SYSTEM_DIR_DOCUMENTS: {
  362. id = NSDocumentDirectory;
  363. } break;
  364. case SYSTEM_DIR_DOWNLOADS: {
  365. id = NSDownloadsDirectory;
  366. } break;
  367. case SYSTEM_DIR_MOVIES: {
  368. id = NSMoviesDirectory;
  369. } break;
  370. case SYSTEM_DIR_MUSIC: {
  371. id = NSMusicDirectory;
  372. } break;
  373. case SYSTEM_DIR_PICTURES: {
  374. id = NSPicturesDirectory;
  375. } break;
  376. default: {
  377. found = false;
  378. }
  379. }
  380. String ret;
  381. if (found) {
  382. NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES);
  383. if (paths && [paths count] >= 1) {
  384. char *utfs = strdup([[paths firstObject] UTF8String]);
  385. ret.parse_utf8(utfs);
  386. free(utfs);
  387. }
  388. }
  389. return ret;
  390. }
  391. Error OS_OSX::shell_open(String p_uri) {
  392. NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
  393. NSURL *uri = [[NSURL alloc] initWithString:string];
  394. // Escape special characters in filenames
  395. if (!uri || !uri.scheme || [uri.scheme isEqual:@"file"]) {
  396. uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
  397. }
  398. [[NSWorkspace sharedWorkspace] openURL:uri];
  399. return OK;
  400. }
  401. String OS_OSX::get_locale() const {
  402. NSString *locale_code = [[NSLocale preferredLanguages] objectAtIndex:0];
  403. return String([locale_code UTF8String]).replace("-", "_");
  404. }
  405. String OS_OSX::get_executable_path() const {
  406. int ret;
  407. pid_t pid;
  408. char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
  409. pid = getpid();
  410. ret = proc_pidpath(pid, pathbuf, sizeof(pathbuf));
  411. if (ret <= 0) {
  412. return OS::get_executable_path();
  413. } else {
  414. String path;
  415. path.parse_utf8(pathbuf);
  416. return path;
  417. }
  418. }
  419. void OS_OSX::run() {
  420. force_quit = false;
  421. if (!main_loop)
  422. return;
  423. main_loop->initialize();
  424. bool quit = false;
  425. while (!force_quit && !quit) {
  426. @try {
  427. if (DisplayServer::get_singleton()) {
  428. DisplayServer::get_singleton()->process_events(); // get rid of pending events
  429. }
  430. joypad_osx->process_joypads();
  431. if (Main::iteration()) {
  432. quit = true;
  433. }
  434. } @catch (NSException *exception) {
  435. ERR_PRINT("NSException: " + String([exception reason].UTF8String));
  436. }
  437. };
  438. main_loop->finalize();
  439. }
  440. Error OS_OSX::move_to_trash(const String &p_path) {
  441. NSFileManager *fm = [NSFileManager defaultManager];
  442. NSURL *url = [NSURL fileURLWithPath:@(p_path.utf8().get_data())];
  443. NSError *err;
  444. if (![fm trashItemAtURL:url resultingItemURL:nil error:&err]) {
  445. ERR_PRINT("trashItemAtURL error: " + String(err.localizedDescription.UTF8String));
  446. return FAILED;
  447. }
  448. return OK;
  449. }
  450. OS_OSX::OS_OSX() {
  451. main_loop = nullptr;
  452. force_quit = false;
  453. Vector<Logger *> loggers;
  454. loggers.push_back(memnew(OSXTerminalLogger));
  455. _set_logger(memnew(CompositeLogger(loggers)));
  456. #ifdef COREAUDIO_ENABLED
  457. AudioDriverManager::add_driver(&audio_driver);
  458. #endif
  459. DisplayServerOSX::register_osx_driver();
  460. // Implicitly create shared NSApplication instance
  461. [GodotApplication sharedApplication];
  462. // In case we are unbundled, make us a proper UI application
  463. [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
  464. // Menu bar setup must go between sharedApplication above and
  465. // finishLaunching below, in order to properly emulate the behavior
  466. // of NSApplicationMain
  467. NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
  468. [NSApp setMainMenu:main_menu];
  469. [NSApp finishLaunching];
  470. id delegate = [[GodotApplicationDelegate alloc] init];
  471. ERR_FAIL_COND(!delegate);
  472. [NSApp setDelegate:delegate];
  473. //process application:openFile: event
  474. while (true) {
  475. NSEvent *event = [NSApp
  476. nextEventMatchingMask:NSEventMaskAny
  477. untilDate:[NSDate distantPast]
  478. inMode:NSDefaultRunLoopMode
  479. dequeue:YES];
  480. if (event == nil) {
  481. break;
  482. }
  483. [NSApp sendEvent:event];
  484. }
  485. [NSApp activateIgnoringOtherApps:YES];
  486. }
  487. bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
  488. return p_feature == "pc";
  489. }
  490. void OS_OSX::disable_crash_handler() {
  491. crash_handler.disable();
  492. }
  493. bool OS_OSX::is_disable_crash_handler() const {
  494. return crash_handler.is_disabled();
  495. }