summaryrefslogtreecommitdiffstats
path: root/platform/macos
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos')
-rw-r--r--platform/macos/detect.py8
-rw-r--r--platform/macos/display_server_macos.h3
-rw-r--r--platform/macos/display_server_macos.mm62
-rw-r--r--platform/macos/doc_classes/EditorExportPlatformMacOS.xml2
-rw-r--r--platform/macos/export/export_plugin.cpp56
-rw-r--r--platform/macos/export/export_plugin.h8
-rw-r--r--platform/macos/export/macho.cpp20
-rw-r--r--platform/macos/export/macho.h1
-rw-r--r--platform/macos/gl_manager_macos_legacy.h1
-rw-r--r--platform/macos/gl_manager_macos_legacy.mm13
-rw-r--r--platform/macos/godot_content_view.mm2
-rw-r--r--platform/macos/godot_main_macos.mm19
-rw-r--r--platform/macos/godot_open_save_delegate.mm8
-rw-r--r--platform/macos/godot_window_delegate.mm4
-rw-r--r--platform/macos/native_menu_macos.h2
-rw-r--r--platform/macos/native_menu_macos.mm5
-rw-r--r--platform/macos/os_macos.h2
-rw-r--r--platform/macos/os_macos.mm6
18 files changed, 141 insertions, 81 deletions
diff --git a/platform/macos/detect.py b/platform/macos/detect.py
index 3c8b1ebee1..a5ef29e34f 100644
--- a/platform/macos/detect.py
+++ b/platform/macos/detect.py
@@ -1,6 +1,6 @@
import os
import sys
-from methods import detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang
+from methods import print_error, detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang
from platform_methods import detect_arch, detect_mvk
from typing import TYPE_CHECKING
@@ -64,11 +64,11 @@ def configure(env: "SConsEnvironment"):
# Validate arch.
supported_arches = ["x86_64", "arm64"]
if env["arch"] not in supported_arches:
- print(
+ print_error(
'Unsupported CPU architecture "%s" for macOS. Supported architectures are: %s.'
% (env["arch"], ", ".join(supported_arches))
)
- sys.exit()
+ sys.exit(255)
## Build type
@@ -254,7 +254,7 @@ def configure(env: "SConsEnvironment"):
if mvk_path != "":
env.Append(LINKFLAGS=["-L" + mvk_path])
else:
- print(
+ print_error(
"MoltenVK SDK installation directory not found, use 'vulkan_sdk_path' SCons parameter to specify SDK path."
)
sys.exit(255)
diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h
index 1b0787c2d9..083e9731c9 100644
--- a/platform/macos/display_server_macos.h
+++ b/platform/macos/display_server_macos.h
@@ -241,6 +241,8 @@ public:
NSImage *_convert_to_nsimg(Ref<Image> &p_image) const;
Point2i _get_screens_origin() const;
+ void set_menu_delegate(NSMenu *p_menu);
+
void send_event(NSEvent *p_event);
void send_window_event(const WindowData &p_wd, WindowEvent p_event);
void release_pressed_events();
@@ -424,7 +426,6 @@ public:
virtual void force_process_and_drop_events() override;
virtual void release_rendering_thread() override;
- virtual void make_rendering_thread() override;
virtual void swap_buffers() override;
virtual void set_native_icon(const String &p_filename) override;
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm
index 23b5a03baa..5e48602da4 100644
--- a/platform/macos/display_server_macos.mm
+++ b/platform/macos/display_server_macos.mm
@@ -83,8 +83,7 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod
Rect2i srect = screen_get_usable_rect(rq_screen);
Point2i wpos = p_rect.position;
if (srect != Rect2i()) {
- wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - p_rect.size.width / 3);
- wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - p_rect.size.height / 3);
+ wpos = wpos.clamp(srect.position, srect.position + srect.size - p_rect.size / 3);
}
// macOS native y-coordinate relative to _get_screens_origin() is negative,
// Godot passes a positive value.
@@ -291,6 +290,10 @@ void DisplayServerMacOS::_update_displays_arrangement() {
displays_arrangement_dirty = false;
}
+void DisplayServerMacOS::set_menu_delegate(NSMenu *p_menu) {
+ [p_menu setDelegate:menu_delegate];
+}
+
Point2i DisplayServerMacOS::_get_screens_origin() const {
// Returns the native top-left screen coordinate of the smallest rectangle
// that encompasses all screens. Needed in get_screen_position(),
@@ -355,7 +358,6 @@ void DisplayServerMacOS::_dispatch_input_events(const Ref<InputEvent> &p_event)
}
void DisplayServerMacOS::_dispatch_input_event(const Ref<InputEvent> &p_event) {
- _THREAD_SAFE_METHOD_
if (!in_dispatch_input_event) {
in_dispatch_input_event = true;
@@ -756,6 +758,8 @@ bool DisplayServerMacOS::has_feature(Feature p_feature) const {
case FEATURE_CURSOR_SHAPE:
case FEATURE_CUSTOM_CURSOR_SHAPE:
case FEATURE_NATIVE_DIALOG:
+ case FEATURE_NATIVE_DIALOG_INPUT:
+ case FEATURE_NATIVE_DIALOG_FILE:
case FEATURE_IME:
case FEATURE_WINDOW_TRANSPARENCY:
case FEATURE_HIDPI:
@@ -934,7 +938,7 @@ Error DisplayServerMacOS::dialog_show(String p_title, String p_description, Vect
button_pressed = int64_t(2 + (ret - NSAlertThirdButtonReturn));
}
- if (!p_callback.is_null()) {
+ if (p_callback.is_valid()) {
Variant ret;
Callable::CallError ce;
const Variant *args[1] = { &button_pressed };
@@ -1014,7 +1018,7 @@ Error DisplayServerMacOS::_file_dialog_with_options_show(const String &p_title,
String url;
url.parse_utf8([[[panel URL] path] UTF8String]);
files.push_back(url);
- if (!callback.is_null()) {
+ if (callback.is_valid()) {
if (p_options_in_cb) {
Variant v_result = true;
Variant v_files = files;
@@ -1043,7 +1047,7 @@ Error DisplayServerMacOS::_file_dialog_with_options_show(const String &p_title,
}
}
} else {
- if (!callback.is_null()) {
+ if (callback.is_valid()) {
if (p_options_in_cb) {
Variant v_result = false;
Variant v_files = Vector<String>();
@@ -1130,7 +1134,7 @@ Error DisplayServerMacOS::_file_dialog_with_options_show(const String &p_title,
url.parse_utf8([[[urls objectAtIndex:i] path] UTF8String]);
files.push_back(url);
}
- if (!callback.is_null()) {
+ if (callback.is_valid()) {
if (p_options_in_cb) {
Variant v_result = true;
Variant v_files = files;
@@ -1159,7 +1163,7 @@ Error DisplayServerMacOS::_file_dialog_with_options_show(const String &p_title,
}
}
} else {
- if (!callback.is_null()) {
+ if (callback.is_valid()) {
if (p_options_in_cb) {
Variant v_result = false;
Variant v_files = Vector<String>();
@@ -1218,7 +1222,7 @@ Error DisplayServerMacOS::dialog_input_text(String p_title, String p_description
String ret;
ret.parse_utf8([[input stringValue] UTF8String]);
- if (!p_callback.is_null()) {
+ if (p_callback.is_valid()) {
Variant v_result = ret;
Variant ret;
Callable::CallError ce;
@@ -1877,8 +1881,7 @@ void DisplayServerMacOS::window_set_current_screen(int p_screen, WindowID p_wind
Size2i wsize = window_get_size(p_window);
wpos += srect.position;
- wpos.x = CLAMP(wpos.x, srect.position.x, srect.position.x + srect.size.width - wsize.width / 3);
- wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3);
+ wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
window_set_position(wpos, p_window);
if (was_fullscreen) {
@@ -1991,7 +1994,7 @@ void DisplayServerMacOS::window_set_position(const Point2i &p_position, WindowID
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
- if (NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
+ if (wd.fullscreen) {
return;
}
@@ -2080,12 +2083,21 @@ Size2i DisplayServerMacOS::window_get_max_size(WindowID p_window) const {
}
void DisplayServerMacOS::update_presentation_mode() {
+ bool has_fs_windows = false;
for (const KeyValue<WindowID, WindowData> &wd : windows) {
- if (wd.value.fullscreen && wd.value.exclusive_fullscreen) {
- return;
+ if (wd.value.fullscreen) {
+ if (wd.value.exclusive_fullscreen) {
+ return;
+ } else {
+ has_fs_windows = true;
+ }
}
}
- [NSApp setPresentationOptions:NSApplicationPresentationDefault];
+ if (has_fs_windows) {
+ [NSApp setPresentationOptions:NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock | NSApplicationPresentationFullScreen];
+ } else {
+ [NSApp setPresentationOptions:NSApplicationPresentationDefault];
+ }
}
void DisplayServerMacOS::window_set_min_size(const Size2i p_size, WindowID p_window) {
@@ -2309,8 +2321,7 @@ void DisplayServerMacOS::window_set_window_buttons_offset(const Vector2i &p_offs
WindowData &wd = windows[p_window];
float scale = screen_get_max_scale();
wd.wb_offset = p_offset / scale;
- wd.wb_offset.x = MAX(wd.wb_offset.x, 12);
- wd.wb_offset.y = MAX(wd.wb_offset.y, 12);
+ wd.wb_offset = wd.wb_offset.max(Vector2i(12, 12));
if (wd.window_button_view) {
[wd.window_button_view setOffset:NSMakePoint(wd.wb_offset.x, wd.wb_offset.y)];
}
@@ -2974,7 +2985,7 @@ Key DisplayServerMacOS::keyboard_get_label_from_physical(Key p_keycode) const {
}
void DisplayServerMacOS::process_events() {
- _THREAD_SAFE_METHOD_
+ _THREAD_SAFE_LOCK_
while (true) {
NSEvent *event = [NSApp
@@ -3007,7 +3018,9 @@ void DisplayServerMacOS::process_events() {
if (!drop_events) {
_process_key_events();
+ _THREAD_SAFE_UNLOCK_
Input::get_singleton()->flush_buffered_events();
+ _THREAD_SAFE_LOCK_
}
for (KeyValue<WindowID, WindowData> &E : windows) {
@@ -3033,6 +3046,8 @@ void DisplayServerMacOS::process_events() {
}
}
}
+
+ _THREAD_SAFE_UNLOCK_
}
void DisplayServerMacOS::force_process_and_drop_events() {
@@ -3044,9 +3059,14 @@ void DisplayServerMacOS::force_process_and_drop_events() {
}
void DisplayServerMacOS::release_rendering_thread() {
-}
-
-void DisplayServerMacOS::make_rendering_thread() {
+#if defined(GLES3_ENABLED)
+ if (gl_manager_angle) {
+ gl_manager_angle->release_current();
+ }
+ if (gl_manager_legacy) {
+ gl_manager_legacy->release_current();
+ }
+#endif
}
void DisplayServerMacOS::swap_buffers() {
diff --git a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
index 506b0dffb8..7355042a48 100644
--- a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
+++ b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
@@ -12,7 +12,7 @@
<members>
<member name="application/additional_plist_content" type="String" setter="" getter="">
Additional data added to the root [code]&lt;dict&gt;[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/information_property_list]Info.plist[/url] file. The value should be an XML section with pairs of key-value elements, e.g.:
- [codeblock]
+ [codeblock lang=text]
&lt;key&gt;key_name&lt;/key&gt;
&lt;string&gt;value&lt;/string&gt;
[/codeblock]
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 05ae4a74c9..5f52d33318 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -333,6 +333,12 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportP
return false;
}
}
+
+ // Hide unsupported .NET embedding option.
+ if (p_option == "dotnet/embed_build_outputs") {
+ return false;
+ }
+
return true;
}
@@ -903,7 +909,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
return OK;
}
-Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn) {
+Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn, bool p_set_id) {
int codesign_tool = p_preset->get("codesign/codesign");
switch (codesign_tool) {
case 1: { // built-in ad-hoc
@@ -947,6 +953,12 @@ Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_pre
args.push_back("--code-signature-flags");
args.push_back("runtime");
+ if (p_set_id) {
+ String app_id = p_preset->get("application/bundle_identifier");
+ args.push_back("--binary-identifier");
+ args.push_back(app_id);
+ }
+
args.push_back("-v"); /* provide some more feedback */
args.push_back(p_path);
@@ -1006,6 +1018,12 @@ Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_pre
args.push_back(p_preset->get("codesign/identity"));
}
+ if (p_set_id) {
+ String app_id = p_preset->get("application/bundle_identifier");
+ args.push_back("-i");
+ args.push_back(app_id);
+ }
+
args.push_back("-v"); /* provide some more feedback */
args.push_back("-f");
@@ -1037,7 +1055,7 @@ Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_pre
}
Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path,
- const String &p_ent_path, bool p_should_error_on_non_code) {
+ const String &p_ent_path, const String &p_helper_ent_path, bool p_should_error_on_non_code) {
static Vector<String> extensions_to_sign;
if (extensions_to_sign.is_empty()) {
@@ -1064,7 +1082,8 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres
}
if (extensions_to_sign.find(current_file.get_extension()) > -1) {
- Error code_sign_error{ _code_sign(p_preset, current_file_path, p_ent_path, false) };
+ int ftype = MachO::get_filetype(current_file_path);
+ Error code_sign_error{ _code_sign(p_preset, current_file_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)) };
if (code_sign_error != OK) {
return code_sign_error;
}
@@ -1073,7 +1092,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres
FileAccess::set_unix_permissions(current_file_path, 0755);
}
} else if (dir_access->current_is_dir()) {
- Error code_sign_error{ _code_sign_directory(p_preset, current_file_path, p_ent_path, p_should_error_on_non_code) };
+ Error code_sign_error{ _code_sign_directory(p_preset, current_file_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code) };
if (code_sign_error != OK) {
return code_sign_error;
}
@@ -1091,6 +1110,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres
Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path,
const String &p_in_app_path, bool p_sign_enabled,
const Ref<EditorExportPreset> &p_preset, const String &p_ent_path,
+ const String &p_helper_ent_path,
bool p_should_error_on_non_code_sign) {
static Vector<String> extensions_to_sign;
@@ -1180,10 +1200,11 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access
if (err == OK && p_sign_enabled) {
if (dir_access->dir_exists(p_src_path) && p_src_path.get_extension().is_empty()) {
// If it is a directory, find and sign all dynamic libraries.
- err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_should_error_on_non_code_sign);
+ err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign);
} else {
if (extensions_to_sign.find(p_in_app_path.get_extension()) > -1) {
- err = _code_sign(p_preset, p_in_app_path, p_ent_path, false);
+ int ftype = MachO::get_filetype(p_in_app_path);
+ err = _code_sign(p_preset, p_in_app_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5));
}
if (dir_access->file_exists(p_in_app_path) && is_executable(p_in_app_path)) {
// chmod with 0755 if the file is executable.
@@ -1197,13 +1218,13 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access
Error EditorExportPlatformMacOS::_export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin,
const String &p_app_path_name, Ref<DirAccess> &dir_access,
bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
- const String &p_ent_path) {
+ const String &p_ent_path, const String &p_helper_ent_path) {
Error error{ OK };
const Vector<String> &macos_plugins{ p_editor_export_plugin->get_macos_plugin_files() };
for (int i = 0; i < macos_plugins.size(); ++i) {
String src_path{ ProjectSettings::get_singleton()->globalize_path(macos_plugins[i]) };
String path_in_app{ p_app_path_name + "/Contents/PlugIns/" + src_path.get_file() };
- error = _copy_and_sign_files(dir_access, src_path, path_in_app, p_sign_enabled, p_preset, p_ent_path, false);
+ error = _copy_and_sign_files(dir_access, src_path, path_in_app, p_sign_enabled, p_preset, p_ent_path, p_helper_ent_path, false);
if (error != OK) {
break;
}
@@ -1768,7 +1789,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
Vector<SharedObject> shared_objects;
- err = save_pack(true, p_preset, p_debug, pack_path, &shared_objects);
+ err = save_pack(p_preset, p_debug, pack_path, &shared_objects);
bool lib_validation = p_preset->get("codesign/entitlements/disable_library_validation");
if (!shared_objects.is_empty() && sign_enabled && ad_hoc && !lib_validation) {
@@ -1780,8 +1801,9 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("'rcodesign' doesn't support signing applications with embedded dynamic libraries."));
}
+ bool sandbox = p_preset->get("codesign/entitlements/app_sandbox/enabled");
String ent_path = p_preset->get("codesign/entitlements/custom_file");
- String hlp_ent_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name + "_helper.entitlements");
+ String hlp_ent_path = sandbox ? EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name + "_helper.entitlements") : ent_path;
if (sign_enabled && (ent_path.is_empty())) {
ent_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name + ".entitlements");
@@ -1933,7 +1955,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
err = ERR_CANT_CREATE;
}
- if ((err == OK) && helpers.size() > 0) {
+ if ((err == OK) && sandbox && (helpers.size() > 0 || shared_objects.size() > 0)) {
ent_f = FileAccess::open(hlp_ent_path, FileAccess::WRITE);
if (ent_f.is_valid()) {
ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
@@ -1959,7 +1981,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
String hlp_path = helpers[i];
err = da->copy(hlp_path, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file());
if (err == OK && sign_enabled) {
- err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), hlp_ent_path, false);
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), hlp_ent_path, false, true);
}
FileAccess::set_unix_permissions(tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), 0755);
}
@@ -1971,11 +1993,11 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
String src_path = ProjectSettings::get_singleton()->globalize_path(shared_objects[i].path);
if (shared_objects[i].target.is_empty()) {
String path_in_app = tmp_app_path_name + "/Contents/Frameworks/" + src_path.get_file();
- err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, true);
+ err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, hlp_ent_path, true);
} else {
String path_in_app = tmp_app_path_name.path_join(shared_objects[i].target);
tmp_app_dir->make_dir_recursive(path_in_app);
- err = _copy_and_sign_files(da, src_path, path_in_app.path_join(src_path.get_file()), sign_enabled, p_preset, ent_path, false);
+ err = _copy_and_sign_files(da, src_path, path_in_app.path_join(src_path.get_file()), sign_enabled, p_preset, ent_path, hlp_ent_path, false);
}
if (err != OK) {
break;
@@ -1984,7 +2006,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
Vector<Ref<EditorExportPlugin>> export_plugins{ EditorExport::get_singleton()->get_export_plugins() };
for (int i = 0; i < export_plugins.size(); ++i) {
- err = _export_macos_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path);
+ err = _export_macos_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path, hlp_ent_path);
if (err != OK) {
break;
}
@@ -2004,7 +2026,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
if (ep.step(TTR("Code signing bundle"), 2)) {
return ERR_SKIP;
}
- err = _code_sign(p_preset, tmp_app_path_name, ent_path);
+ err = _code_sign(p_preset, tmp_app_path_name, ent_path, true, false);
}
String noto_path = p_path;
@@ -2022,7 +2044,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
if (ep.step(TTR("Code signing DMG"), 3)) {
return ERR_SKIP;
}
- err = _code_sign(p_preset, p_path, ent_path, false);
+ err = _code_sign(p_preset, p_path, ent_path, false, false);
}
} else if (export_format == "pkg") {
// Create a Installer.
diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h
index 0764b63e8c..2d615abede 100644
--- a/platform/macos/export/export_plugin.h
+++ b/platform/macos/export/export_plugin.h
@@ -89,14 +89,14 @@ class EditorExportPlatformMacOS : public EditorExportPlatform {
void _make_icon(const Ref<EditorExportPreset> &p_preset, const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);
- Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true);
- Error _code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_should_error_on_non_code = true);
+ Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true, bool p_set_id = false);
+ Error _code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, const String &p_helper_ent_path, bool p_should_error_on_non_code = true);
Error _copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path,
- bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path,
+ bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path, const String &p_helper_ent_path,
bool p_should_error_on_non_code_sign);
Error _export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name,
Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
- const String &p_ent_path);
+ const String &p_ent_path, const String &p_helper_ent_path);
Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);
Error _create_pkg(const Ref<EditorExportPreset> &p_preset, const String &p_pkg_path, const String &p_app_path_name);
Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);
diff --git a/platform/macos/export/macho.cpp b/platform/macos/export/macho.cpp
index c7556c1964..a829774a88 100644
--- a/platform/macos/export/macho.cpp
+++ b/platform/macos/export/macho.cpp
@@ -105,6 +105,26 @@ bool MachO::is_macho(const String &p_path) {
return (magic == 0xcefaedfe || magic == 0xfeedface || magic == 0xcffaedfe || magic == 0xfeedfacf);
}
+uint32_t MachO::get_filetype(const String &p_path) {
+ Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(fa.is_null(), 0, vformat("MachO: Can't open file: \"%s\".", p_path));
+ uint32_t magic = fa->get_32();
+ MachHeader mach_header;
+
+ // Read MachO header.
+ if (magic == 0xcefaedfe || magic == 0xfeedface) {
+ // Thin 32-bit binary.
+ fa->get_buffer((uint8_t *)&mach_header, sizeof(MachHeader));
+ } else if (magic == 0xcffaedfe || magic == 0xfeedfacf) {
+ // Thin 64-bit binary.
+ fa->get_buffer((uint8_t *)&mach_header, sizeof(MachHeader));
+ fa->get_32(); // Skip extra reserved field.
+ } else {
+ ERR_FAIL_V_MSG(0, vformat("MachO: File is not a valid MachO binary: \"%s\".", p_path));
+ }
+ return mach_header.filetype;
+}
+
bool MachO::open_file(const String &p_path) {
fa = FileAccess::open(p_path, FileAccess::READ_WRITE);
ERR_FAIL_COND_V_MSG(fa.is_null(), false, vformat("MachO: Can't open file: \"%s\".", p_path));
diff --git a/platform/macos/export/macho.h b/platform/macos/export/macho.h
index 37975f0820..a84de7de60 100644
--- a/platform/macos/export/macho.h
+++ b/platform/macos/export/macho.h
@@ -181,6 +181,7 @@ class MachO : public RefCounted {
public:
static bool is_macho(const String &p_path);
+ static uint32_t get_filetype(const String &p_path);
bool open_file(const String &p_path);
diff --git a/platform/macos/gl_manager_macos_legacy.h b/platform/macos/gl_manager_macos_legacy.h
index bafe825efb..af9be8f5ba 100644
--- a/platform/macos/gl_manager_macos_legacy.h
+++ b/platform/macos/gl_manager_macos_legacy.h
@@ -73,7 +73,6 @@ public:
void window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height);
void release_current();
- void make_current();
void swap_buffers();
void window_make_current(DisplayServer::WindowID p_window_id);
diff --git a/platform/macos/gl_manager_macos_legacy.mm b/platform/macos/gl_manager_macos_legacy.mm
index 701de6df78..6ce3831d9c 100644
--- a/platform/macos/gl_manager_macos_legacy.mm
+++ b/platform/macos/gl_manager_macos_legacy.mm
@@ -117,6 +117,7 @@ void GLManagerLegacy_MacOS::release_current() {
}
[NSOpenGLContext clearCurrentContext];
+ current_window = DisplayServer::INVALID_WINDOW_ID;
}
void GLManagerLegacy_MacOS::window_make_current(DisplayServer::WindowID p_window_id) {
@@ -133,18 +134,6 @@ void GLManagerLegacy_MacOS::window_make_current(DisplayServer::WindowID p_window
current_window = p_window_id;
}
-void GLManagerLegacy_MacOS::make_current() {
- if (current_window == DisplayServer::INVALID_WINDOW_ID) {
- return;
- }
- if (!windows.has(current_window)) {
- return;
- }
-
- GLWindow &win = windows[current_window];
- [win.context makeCurrentContext];
-}
-
void GLManagerLegacy_MacOS::swap_buffers() {
GLWindow &win = windows[current_window];
[win.context flushBuffer];
diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm
index 93bba84783..68a7288ad4 100644
--- a/platform/macos/godot_content_view.mm
+++ b/platform/macos/godot_content_view.mm
@@ -313,7 +313,7 @@
}
DisplayServerMacOS::WindowData &wd = ds->get_window(window_id);
- if (!wd.drop_files_callback.is_null()) {
+ if (wd.drop_files_callback.is_valid()) {
Vector<String> files;
NSPasteboard *pboard = [sender draggingPasteboard];
diff --git a/platform/macos/godot_main_macos.mm b/platform/macos/godot_main_macos.mm
index 3959fb686c..942c351ac0 100644
--- a/platform/macos/godot_main_macos.mm
+++ b/platform/macos/godot_main_macos.mm
@@ -69,18 +69,21 @@ int main(int argc, char **argv) {
err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
}
- if (err == ERR_HELP) { // Returned by --help and --version, so success.
- return 0;
- } else if (err != OK) {
- return 255;
+ if (err != OK) {
+ if (err == ERR_HELP) { // Returned by --help and --version, so success.
+ return EXIT_SUCCESS;
+ }
+ return EXIT_FAILURE;
}
- bool ok;
+ int ret;
@autoreleasepool {
- ok = Main::start();
+ ret = Main::start();
}
- if (ok) {
- os.run(); // It is actually the OS that decides how to run.
+ if (ret == EXIT_SUCCESS) {
+ os.run();
+ } else {
+ os.set_exit_code(EXIT_FAILURE);
}
@autoreleasepool {
diff --git a/platform/macos/godot_open_save_delegate.mm b/platform/macos/godot_open_save_delegate.mm
index 6b55b70629..6ffd939545 100644
--- a/platform/macos/godot_open_save_delegate.mm
+++ b/platform/macos/godot_open_save_delegate.mm
@@ -177,14 +177,14 @@
if ([new_allowed_types count] > 0) {
NSMutableArray *type_filters = [new_allowed_types objectAtIndex:0];
if (type_filters && [type_filters count] == 1 && [[type_filters objectAtIndex:0] isEqualToString:@"*"]) {
- [p_panel setAllowedFileTypes:@[]];
+ [p_panel setAllowedFileTypes:nil];
[p_panel setAllowsOtherFileTypes:true];
} else {
[p_panel setAllowsOtherFileTypes:false];
[p_panel setAllowedFileTypes:type_filters];
}
} else {
- [p_panel setAllowedFileTypes:@[]];
+ [p_panel setAllowedFileTypes:nil];
[p_panel setAllowsOtherFileTypes:true];
}
}
@@ -248,7 +248,7 @@
if (allowed_types && index < [allowed_types count]) {
NSMutableArray *type_filters = [allowed_types objectAtIndex:index];
if (type_filters && [type_filters count] == 1 && [[type_filters objectAtIndex:0] isEqualToString:@"*"]) {
- [dialog setAllowedFileTypes:@[]];
+ [dialog setAllowedFileTypes:nil];
[dialog setAllowsOtherFileTypes:true];
} else {
[dialog setAllowsOtherFileTypes:false];
@@ -256,7 +256,7 @@
}
cur_index = index;
} else {
- [dialog setAllowedFileTypes:@[]];
+ [dialog setAllowedFileTypes:nil];
[dialog setAllowsOtherFileTypes:true];
cur_index = -1;
}
diff --git a/platform/macos/godot_window_delegate.mm b/platform/macos/godot_window_delegate.mm
index 2d83b46007..7749debfd6 100644
--- a/platform/macos/godot_window_delegate.mm
+++ b/platform/macos/godot_window_delegate.mm
@@ -268,7 +268,7 @@
ds->window_resize(window_id, wd.size.width, wd.size.height);
- if (!wd.rect_changed_callback.is_null()) {
+ if (wd.rect_changed_callback.is_valid()) {
wd.rect_changed_callback.call(Rect2i(ds->window_get_position(window_id), ds->window_get_size(window_id)));
}
}
@@ -291,7 +291,7 @@
DisplayServerMacOS::WindowData &wd = ds->get_window(window_id);
ds->release_pressed_events();
- if (!wd.rect_changed_callback.is_null()) {
+ if (wd.rect_changed_callback.is_valid()) {
wd.rect_changed_callback.call(Rect2i(ds->window_get_position(window_id), ds->window_get_size(window_id)));
}
}
diff --git a/platform/macos/native_menu_macos.h b/platform/macos/native_menu_macos.h
index 894f6912b5..b5dbb8b9b0 100644
--- a/platform/macos/native_menu_macos.h
+++ b/platform/macos/native_menu_macos.h
@@ -33,7 +33,7 @@
#include "core/templates/hash_map.h"
#include "core/templates/rid_owner.h"
-#include "servers/native_menu.h"
+#include "servers/display/native_menu.h"
#import <AppKit/AppKit.h>
#import <ApplicationServices/ApplicationServices.h>
diff --git a/platform/macos/native_menu_macos.mm b/platform/macos/native_menu_macos.mm
index 27ad5209c4..1cf13a2d69 100644
--- a/platform/macos/native_menu_macos.mm
+++ b/platform/macos/native_menu_macos.mm
@@ -223,6 +223,11 @@ RID NativeMenuMacOS::get_system_menu(SystemMenus p_menu_id) const {
RID NativeMenuMacOS::create_menu() {
MenuData *md = memnew(MenuData);
md->menu = [[NSMenu alloc] initWithTitle:@""];
+ [md->menu setAutoenablesItems:NO];
+ DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
+ if (ds) {
+ ds->set_menu_delegate(md->menu);
+ }
RID rid = menus.make_rid(md);
menu_lookup[md->menu] = rid;
return rid;
diff --git a/platform/macos/os_macos.h b/platform/macos/os_macos.h
index 8088c3431c..912a682a6b 100644
--- a/platform/macos/os_macos.h
+++ b/platform/macos/os_macos.h
@@ -85,7 +85,7 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
- virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override;
+ virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override;
virtual MainLoop *get_main_loop() const override;
diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm
index d9ad8f937a..9f0bea5951 100644
--- a/platform/macos/os_macos.mm
+++ b/platform/macos/os_macos.mm
@@ -217,7 +217,7 @@ _FORCE_INLINE_ String OS_MacOS::get_framework_executable(const String &p_path) {
return p_path;
}
-Error OS_MacOS::open_dynamic_library(const String &p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) {
+Error OS_MacOS::open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data) {
String path = get_framework_executable(p_path);
if (!FileAccess::exists(path)) {
@@ -235,8 +235,8 @@ Error OS_MacOS::open_dynamic_library(const String &p_path, void *&p_library_hand
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror()));
- if (r_resolved_path != nullptr) {
- *r_resolved_path = path;
+ if (p_data != nullptr && p_data->r_resolved_path != nullptr) {
+ *p_data->r_resolved_path = path;
}
return OK;