feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -144,6 +144,4 @@ if env["debug_symbols"] and env["separate_debug_symbols"]:
|
|||
env.AddPostAction(prog, env.Run(platform_macos_builders.make_debug_macos))
|
||||
|
||||
if env["generate_bundle"]:
|
||||
generate_bundle_command = env.Command("generate_bundle", [], generate_bundle)
|
||||
command = env.AlwaysBuild(generate_bundle_command)
|
||||
env.Depends(command, [prog])
|
||||
env.AlwaysBuild(env.CommandNoCache("generate_bundle", prog, env.Run(generate_bundle)))
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CRASH_HANDLER_MACOS_H
|
||||
#define CRASH_HANDLER_MACOS_H
|
||||
#pragma once
|
||||
|
||||
class CrashHandler {
|
||||
bool disabled;
|
||||
|
|
@ -43,5 +42,3 @@ public:
|
|||
CrashHandler();
|
||||
~CrashHandler();
|
||||
};
|
||||
|
||||
#endif // CRASH_HANDLER_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "crash_handler_macos.h"
|
||||
#import "crash_handler_macos.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/os.h"
|
||||
|
|
@ -50,8 +50,8 @@
|
|||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/getsect.h>
|
||||
#import <mach-o/dyld.h>
|
||||
#import <mach-o/getsect.h>
|
||||
|
||||
static uint64_t load_address() {
|
||||
const struct segment_command_64 *cmd = getsegbyname("__TEXT");
|
||||
|
|
@ -105,10 +105,10 @@ static void handle_crash(int sig) {
|
|||
print_error(vformat("%s: Program crashed with signal %d", __FUNCTION__, sig));
|
||||
|
||||
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
|
||||
if (String(VERSION_HASH).is_empty()) {
|
||||
print_error(vformat("Engine version: %s", VERSION_FULL_NAME));
|
||||
if (String(GODOT_VERSION_HASH).is_empty()) {
|
||||
print_error(vformat("Engine version: %s", GODOT_VERSION_FULL_NAME));
|
||||
} else {
|
||||
print_error(vformat("Engine version: %s (%s)", VERSION_FULL_NAME, VERSION_HASH));
|
||||
print_error(vformat("Engine version: %s (%s)", GODOT_VERSION_FULL_NAME, GODOT_VERSION_HASH));
|
||||
}
|
||||
print_error(vformat("Dumping the backtrace. %s", msg));
|
||||
char **strings = backtrace_symbols(bt_buffer, size);
|
||||
|
|
|
|||
|
|
@ -182,6 +182,18 @@ def configure(env: "SConsEnvironment"):
|
|||
|
||||
## Dependencies
|
||||
|
||||
if env["accesskit"]:
|
||||
if env["accesskit_sdk_path"] != "":
|
||||
env.Prepend(CPPPATH=[env["accesskit_sdk_path"] + "/include"])
|
||||
if env["arch"] == "arm64" or env["arch"] == "universal":
|
||||
env.Append(LINKFLAGS=["-L" + env["accesskit_sdk_path"] + "/lib/macos/arm64/static/"])
|
||||
if env["arch"] == "x86_64" or env["arch"] == "universal":
|
||||
env.Append(LINKFLAGS=["-L" + env["accesskit_sdk_path"] + "/lib/macos/x86_64/static/"])
|
||||
env.Append(LINKFLAGS=["-laccesskit"])
|
||||
else:
|
||||
env.Append(CPPDEFINES=["ACCESSKIT_DYNAMIC"])
|
||||
env.Append(CPPDEFINES=["ACCESSKIT_ENABLED"])
|
||||
|
||||
if env["builtin_libtheora"] and env["arch"] == "x86_64":
|
||||
env["x86_libtheora_opt_gcc"] = True
|
||||
|
||||
|
|
@ -231,7 +243,7 @@ def configure(env: "SConsEnvironment"):
|
|||
env.Append(LINKFLAGS=["-lANGLE.macos." + env["arch"]])
|
||||
env.Append(LINKFLAGS=["-lEGL.macos." + env["arch"]])
|
||||
env.Append(LINKFLAGS=["-lGLES.macos." + env["arch"]])
|
||||
env.Prepend(CPPPATH=["#thirdparty/angle/include"])
|
||||
env.Prepend(CPPEXTPATH=["#thirdparty/angle/include"])
|
||||
|
||||
env.Append(LINKFLAGS=["-rpath", "@executable_path/../Frameworks", "-rpath", "@executable_path"])
|
||||
|
||||
|
|
@ -246,7 +258,7 @@ def configure(env: "SConsEnvironment"):
|
|||
extra_frameworks.add("Metal")
|
||||
extra_frameworks.add("MetalKit")
|
||||
extra_frameworks.add("MetalFX")
|
||||
env.Prepend(CPPPATH=["#thirdparty/spirv-cross"])
|
||||
env.Prepend(CPPEXTPATH=["#thirdparty/spirv-cross"])
|
||||
|
||||
if env["vulkan"]:
|
||||
env.AppendUnique(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"])
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DIR_ACCESS_MACOS_H
|
||||
#define DIR_ACCESS_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
|
|
@ -42,6 +41,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
class DirAccessMacOS : public DirAccessUnix {
|
||||
GDSOFTCLASS(DirAccessMacOS, DirAccessUnix);
|
||||
|
||||
protected:
|
||||
virtual String fix_unicode_name(const char *p_name) const override;
|
||||
|
||||
|
|
@ -55,5 +56,3 @@ protected:
|
|||
};
|
||||
|
||||
#endif // UNIX ENABLED
|
||||
|
||||
#endif // DIR_ACCESS_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "dir_access_macos.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#import "dir_access_macos.h"
|
||||
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#import <AppKit/NSWorkspace.h>
|
||||
|
|
@ -43,7 +43,7 @@ String DirAccessMacOS::fix_unicode_name(const char *p_name) const {
|
|||
String fname;
|
||||
if (p_name != nullptr) {
|
||||
NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping];
|
||||
fname.parse_utf8([nsstr UTF8String]);
|
||||
fname.append_utf8([nsstr UTF8String]);
|
||||
}
|
||||
|
||||
return fname;
|
||||
|
|
@ -66,7 +66,7 @@ String DirAccessMacOS::get_drive(int p_drive) {
|
|||
String volname;
|
||||
NSString *path = [vols[p_drive] path];
|
||||
|
||||
volname.parse_utf8([path UTF8String]);
|
||||
volname.append_utf8([path UTF8String]);
|
||||
|
||||
return volname;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DISPLAY_SERVER_MACOS_H
|
||||
#define DISPLAY_SERVER_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/input/input.h"
|
||||
#include "servers/display_server.h"
|
||||
|
|
@ -39,16 +38,16 @@
|
|||
#include "gl_manager_macos_legacy.h"
|
||||
#endif // GLES3_ENABLED
|
||||
|
||||
#include "native_menu_macos.h"
|
||||
#import "native_menu_macos.h"
|
||||
|
||||
#if defined(RD_ENABLED)
|
||||
#include "servers/rendering/rendering_device.h"
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
#include "rendering_context_driver_vulkan_macos.h"
|
||||
#import "rendering_context_driver_vulkan_macos.h"
|
||||
#endif // VULKAN_ENABLED
|
||||
#if defined(METAL_ENABLED)
|
||||
#include "drivers/metal/rendering_context_driver_metal.h"
|
||||
#import "drivers/metal/rendering_context_driver_metal.h"
|
||||
#endif
|
||||
#endif // RD_ENABLED
|
||||
|
||||
|
|
@ -65,7 +64,7 @@
|
|||
#undef CursorShape
|
||||
|
||||
class DisplayServerMacOS : public DisplayServer {
|
||||
// No need to register with GDCLASS, it's platform-specific and nothing is added.
|
||||
GDSOFTCLASS(DisplayServerMacOS, DisplayServer);
|
||||
|
||||
_THREAD_SAFE_CLASS_
|
||||
|
||||
|
|
@ -124,6 +123,8 @@ public:
|
|||
bool on_top = false;
|
||||
bool borderless = false;
|
||||
bool resize_disabled = false;
|
||||
bool no_min_btn = false;
|
||||
bool no_max_btn = false;
|
||||
bool no_focus = false;
|
||||
bool is_popup = false;
|
||||
bool mpass = false;
|
||||
|
|
@ -236,7 +237,9 @@ private:
|
|||
|
||||
static NSCursor *_cursor_from_selector(SEL p_selector, SEL p_fallback = nil);
|
||||
|
||||
Error _file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb);
|
||||
Error _file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb, WindowID p_window_id);
|
||||
|
||||
void initialize_tts() const;
|
||||
|
||||
public:
|
||||
void menu_callback(id p_sender);
|
||||
|
|
@ -254,6 +257,7 @@ public:
|
|||
void send_event(NSEvent *p_event);
|
||||
void send_window_event(const WindowData &p_wd, WindowEvent p_event);
|
||||
void release_pressed_events();
|
||||
void sync_mouse_state();
|
||||
void get_key_modifier_state(unsigned int p_macos_state, Ref<InputEventWithModifiers> r_state) const;
|
||||
void update_mouse_pos(WindowData &p_wd, NSPoint p_location_in_window);
|
||||
void push_to_key_event_buffer(const KeyEvent &p_event);
|
||||
|
|
@ -303,8 +307,8 @@ public:
|
|||
virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) override;
|
||||
virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override;
|
||||
|
||||
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) override;
|
||||
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback) override;
|
||||
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback, WindowID p_window_id) override;
|
||||
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id) override;
|
||||
|
||||
virtual void beep() const override;
|
||||
|
||||
|
|
@ -423,6 +427,11 @@ public:
|
|||
virtual void window_set_window_buttons_offset(const Vector2i &p_offset, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||
virtual Vector3i window_get_safe_title_margins(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||
|
||||
virtual int accessibility_should_increase_contrast() const override;
|
||||
virtual int accessibility_should_reduce_animation() const override;
|
||||
virtual int accessibility_should_reduce_transparency() const override;
|
||||
virtual int accessibility_screen_reader_active() const override;
|
||||
|
||||
virtual Point2i ime_get_selection() const override;
|
||||
virtual String ime_get_text() const override;
|
||||
|
||||
|
|
@ -442,6 +451,7 @@ public:
|
|||
virtual Key keyboard_get_label_from_physical(Key p_keycode) const override;
|
||||
virtual void show_emoji_and_symbol_picker() const override;
|
||||
|
||||
void _process_events(bool p_pump);
|
||||
virtual void process_events() override;
|
||||
virtual void force_process_and_drop_events() override;
|
||||
|
||||
|
|
@ -469,5 +479,3 @@ public:
|
|||
DisplayServerMacOS(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error);
|
||||
~DisplayServerMacOS();
|
||||
};
|
||||
|
||||
#endif // DISPLAY_SERVER_MACOS_H
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MACOS_EXPORT_H
|
||||
#define MACOS_EXPORT_H
|
||||
#pragma once
|
||||
|
||||
void register_macos_exporter_types();
|
||||
void register_macos_exporter();
|
||||
|
||||
#endif // MACOS_EXPORT_H
|
||||
|
|
|
|||
|
|
@ -561,13 +561,13 @@ void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options
|
|||
|
||||
{
|
||||
String hint;
|
||||
for (uint64_t i = 0; i < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++i) {
|
||||
for (uint64_t i = 0; i < std::size(data_collect_purpose_info); ++i) {
|
||||
if (i != 0) {
|
||||
hint += ",";
|
||||
}
|
||||
hint += vformat("%s:%d", data_collect_purpose_info[i].prop_name, (1 << i));
|
||||
}
|
||||
for (uint64_t i = 0; i < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++i) {
|
||||
for (uint64_t i = 0; i < std::size(data_collect_type_info); ++i) {
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/collected", data_collect_type_info[i].prop_name)), false));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[i].prop_name)), false));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[i].prop_name)), false));
|
||||
|
|
@ -671,7 +671,7 @@ void EditorExportPlatformMacOS::_make_icon(const Ref<EditorExportPreset> &p_pres
|
|||
{ "is32", "s8mk", false, 16 } //16×16 24-bit RLE + 8-bit uncompressed mask
|
||||
};
|
||||
|
||||
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
|
||||
for (uint64_t i = 0; i < std::size(icon_infos); ++i) {
|
||||
Ref<Image> copy = p_icon->duplicate();
|
||||
copy->convert(Image::FORMAT_RGBA8);
|
||||
copy->resize(icon_infos[i].size, icon_infos[i].size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int()));
|
||||
|
|
@ -736,14 +736,13 @@ void EditorExportPlatformMacOS::_make_icon(const Ref<EditorExportPreset> &p_pres
|
|||
}
|
||||
|
||||
void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist) {
|
||||
String str;
|
||||
String str = String::utf8((const char *)plist.ptr(), plist.size());
|
||||
String strnew;
|
||||
str.parse_utf8((const char *)plist.ptr(), plist.size());
|
||||
Vector<String> lines = str.split("\n");
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (lines[i].find("$priv_collection") != -1) {
|
||||
bool section_opened = false;
|
||||
for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) {
|
||||
for (uint64_t j = 0; j < std::size(data_collect_type_info); ++j) {
|
||||
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
|
||||
bool linked = p_preset->get(vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[j].prop_name));
|
||||
bool tracking = p_preset->get(vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[j].prop_name));
|
||||
|
|
@ -772,7 +771,7 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
|
|||
if (purposes != 0) {
|
||||
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypePurposes</key>\n";
|
||||
strnew += "\t\t\t\t<array>\n";
|
||||
for (uint64_t k = 0; k < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++k) {
|
||||
for (uint64_t k = 0; k < std::size(data_collect_purpose_info); ++k) {
|
||||
if (purposes & (1 << k)) {
|
||||
strnew += vformat("\t\t\t\t\t<string>%s</string>\n", data_collect_purpose_info[k].type_name);
|
||||
}
|
||||
|
|
@ -815,15 +814,14 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
|
|||
}
|
||||
|
||||
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
|
||||
String str;
|
||||
String str = String::utf8((const char *)plist.ptr(), plist.size());
|
||||
String strnew;
|
||||
str.parse_utf8((const char *)plist.ptr(), plist.size());
|
||||
Vector<String> lines = str.split("\n");
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (lines[i].contains("$binary")) {
|
||||
strnew += lines[i].replace("$binary", p_binary) + "\n";
|
||||
} else if (lines[i].contains("$name")) {
|
||||
strnew += lines[i].replace("$name", GLOBAL_GET("application/config/name")) + "\n";
|
||||
strnew += lines[i].replace("$name", get_project_setting(p_preset, "application/config/name")) + "\n";
|
||||
} else if (lines[i].contains("$bundle_identifier")) {
|
||||
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
|
||||
} else if (lines[i].contains("$short_version")) {
|
||||
|
|
@ -982,7 +980,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
|
|||
} else {
|
||||
print_verbose("rcodesign (" + p_path + "):\n" + str);
|
||||
int next_nl = str.find_char('\n', rq_offset);
|
||||
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23);
|
||||
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23) : str.substr(rq_offset + 23, next_nl - rq_offset - 23);
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
|
||||
|
|
@ -1066,7 +1064,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
|
|||
} else {
|
||||
print_verbose("notarytool (" + p_path + "):\n" + str);
|
||||
int next_nl = str.find_char('\n', rq_offset);
|
||||
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4);
|
||||
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4) : str.substr(rq_offset + 4, next_nl - rq_offset - 4);
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
|
||||
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
|
||||
|
|
@ -1500,7 +1498,7 @@ Error EditorExportPlatformMacOS::_export_debug_script(const Ref<EditorExportPres
|
|||
}
|
||||
|
||||
f->store_line("#!/bin/sh");
|
||||
f->store_line("echo -ne '\\033c\\033]0;" + p_app_name + "\\a'");
|
||||
f->store_line("printf '\\033c\\033]0;%s\\a' " + p_app_name);
|
||||
f->store_line("");
|
||||
f->store_line("function app_realpath() {");
|
||||
f->store_line(" SOURCE=$1");
|
||||
|
|
@ -1566,8 +1564,8 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture;
|
||||
|
||||
String pkg_name;
|
||||
if (String(GLOBAL_GET("application/config/name")) != "") {
|
||||
pkg_name = String(GLOBAL_GET("application/config/name"));
|
||||
if (String(get_project_setting(p_preset, "application/config/name")) != "") {
|
||||
pkg_name = String(get_project_setting(p_preset, "application/config/name"));
|
||||
} else {
|
||||
pkg_name = "Unnamed";
|
||||
}
|
||||
|
|
@ -1660,7 +1658,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
}
|
||||
}
|
||||
|
||||
Dictionary appnames = GLOBAL_GET("application/config/name_localized");
|
||||
Dictionary appnames = get_project_setting(p_preset, "application/config/name_localized");
|
||||
Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized");
|
||||
Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized");
|
||||
Dictionary location_usage_descriptions = p_preset->get("privacy/location_usage_description_localized");
|
||||
|
|
@ -1674,7 +1672,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized");
|
||||
Dictionary copyrights = p_preset->get("application/copyright_localized");
|
||||
|
||||
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
|
||||
Vector<String> translations = get_project_setting(p_preset, "internationalization/locale/translations");
|
||||
if (translations.size() > 0) {
|
||||
{
|
||||
String fname = tmp_app_path_name + "/Contents/Resources/en.lproj";
|
||||
|
|
@ -1682,7 +1680,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
Ref<FileAccess> f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
|
||||
f->store_line("/* Localized versions of Info.plist keys */");
|
||||
f->store_line("");
|
||||
f->store_line("CFBundleDisplayName = \"" + GLOBAL_GET("application/config/name").operator String() + "\";");
|
||||
f->store_line("CFBundleDisplayName = \"" + get_project_setting(p_preset, "application/config/name").operator String() + "\";");
|
||||
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
|
||||
f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";");
|
||||
}
|
||||
|
|
@ -1781,7 +1779,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
int export_angle = p_preset->get("application/export_angle");
|
||||
bool include_angle_libs = false;
|
||||
if (export_angle == 0) {
|
||||
include_angle_libs = String(GLOBAL_GET("rendering/gl_compatibility/driver.macos")) == "opengl3_angle";
|
||||
include_angle_libs = String(get_project_setting(p_preset, "rendering/gl_compatibility/driver.macos")) == "opengl3_angle";
|
||||
} else if (export_angle == 1) {
|
||||
include_angle_libs = true;
|
||||
}
|
||||
|
|
@ -1869,10 +1867,10 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
|
|||
String icon_path;
|
||||
if (p_preset->get("application/icon") != "") {
|
||||
icon_path = p_preset->get("application/icon");
|
||||
} else if (GLOBAL_GET("application/config/macos_native_icon") != "") {
|
||||
icon_path = GLOBAL_GET("application/config/macos_native_icon");
|
||||
} else if (get_project_setting(p_preset, "application/config/macos_native_icon") != "") {
|
||||
icon_path = get_project_setting(p_preset, "application/config/macos_native_icon");
|
||||
} else {
|
||||
icon_path = GLOBAL_GET("application/config/icon");
|
||||
icon_path = get_project_setting(p_preset, "application/config/icon");
|
||||
}
|
||||
|
||||
if (!icon_path.is_empty()) {
|
||||
|
|
@ -2570,8 +2568,8 @@ Error EditorExportPlatformMacOS::run(const Ref<EditorExportPreset> &p_preset, in
|
|||
}
|
||||
|
||||
String pkg_name;
|
||||
if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
|
||||
pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
|
||||
if (String(get_project_setting(p_preset, "application/config/name")) != "") {
|
||||
pkg_name = String(get_project_setting(p_preset, "application/config/name"));
|
||||
} else {
|
||||
pkg_name = "Unnamed";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MACOS_EXPORT_PLUGIN_H
|
||||
#define MACOS_EXPORT_PLUGIN_H
|
||||
#pragma once
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/dir_access.h"
|
||||
|
|
@ -38,7 +37,6 @@
|
|||
#include "core/io/marshalls.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/version.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/export/editor_export.h"
|
||||
|
||||
|
|
@ -173,5 +171,3 @@ public:
|
|||
|
||||
EditorExportPlatformMacOS();
|
||||
};
|
||||
|
||||
#endif // MACOS_EXPORT_PLUGIN_H
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 25.6 25.6"><path fill="#1c9ef8" d="M.948 19.474V6.126c0-2.767 2.42-5.178 5.178-5.178h6.904s-2.992 7.506-2.992 13.233c0 .346.337.69.69.69h2.877c0 6.648.906 8.436 1.266 9.781H6.126c-2.75 0-5.178-2.407-5.178-5.178z"/><path fill="none" stroke="#323232" stroke-linecap="round" stroke-width="1.036" d="M7.162 8.312v1.496"/><path fill="#e1e6ed" d="M10.729 14.871c-.352 0-.69-.344-.69-.69C10.038 8.414 13.03.948 13.03.948h6.444c2.77 0 5.178 2.416 5.178 5.178v13.348c0 2.754-2.407 5.178-5.178 5.178h-4.603c-.357-1.333-1.266-2.887-1.266-9.78z"/><g fill="none" stroke="#323232" stroke-linecap="round"><path stroke-width="1.036" d="M17.575 8.255V9.75"/><path stroke-width=".69" d="M5.55 16.943c1.037 1.794 3.907 2.876 6.79 2.876 2.877 0 5.745-1.068 6.789-2.876"/></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 25.6 25.6"><path fill="#1c9ef8" d="M.948 19.474V6.126c0-2.767 2.42-5.178 5.178-5.178h6.904s-2.992 7.506-2.992 13.233c0 .346.337.69.69.69h2.877c0 6.648.906 8.436 1.266 9.781H6.126c-2.75 0-5.178-2.407-5.178-5.178z"/><path fill="none" stroke="#323232" stroke-linecap="round" stroke-width="1.036" d="M7.162 8.312v1.496"/><path fill="#e1e6ed" d="M10.729 14.871c-.352 0-.69-.344-.69-.69C10.038 8.414 13.03.948 13.03.948h6.444c2.77 0 5.178 2.416 5.178 5.178v13.348c0 2.754-2.407 5.178-5.178 5.178h-4.603c-.357-1.333-1.266-2.887-1.266-9.78z"/><g fill="none" stroke="#323232" stroke-linecap="round"><path stroke-width="1.036" d="M17.575 8.255V9.75"/><path stroke-width=".69" d="M5.55 16.943c1.037 1.794 3.907 2.876 6.79 2.876 2.877 0 5.745-1.068 6.789-2.876"/></g></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 837 B After Width: | Height: | Size: 838 B |
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="16" height="16"><path fill="#e0e0e0" d="M4.418 1.055a3.364 3.364 0 0 0-3.364 3.364v7.164a3.364 3.364 0 0 0 3.364 3.364h7.164a3.364 3.364 0 0 0 3.364-3.364V4.418a3.364 3.364 0 0 0-3.364-3.364H7.729Zm3.875 1.164h3.291a2.2 2.2 0 0 1 2.2 2.2v7.164a2.2 2.2 0 0 1-2.2 2.2h-2.15a8.884 8.884 0 0 1-.358-1.598c-.135.02-.487.082-.693.117a7.345 7.345 0 0 1-1.254 0 7.114 7.114 0 0 1-.926-.139 6.057 6.057 0 0 1-.867-.271 3.843 3.843 0 0 1-.988-.566 3.214 3.214 0 0 1-.397-.378 2.8 2.8 0 0 1-.318-.441.56.56 0 0 1 .968-.56c.083.138.188.26.312.362.096.082.2.158.307.224.12.075.243.142.371.201.285.139.583.247.89.319a5.35 5.35 0 0 0 1.282.158c.065 0 .129-.005.184-.006.056 0 .102-.005.148-.008l.096-.006c.114-.009.228-.02.31-.032.083-.013.11-.021.143-.028.099-.022.204-.058.327-.089a28.438 28.438 0 0 1-.06-1.929V8.53H6.887c.048-1.963.746-4.357 1.181-5.677.1-.293.184-.527.225-.633ZM5.531 6.394a.56.56 0 0 1-1.118 0v-.9a.56.56 0 0 1 1.118 0Zm3.432 4.646.02.306c.02.264.049.527.082.788l.011.05c1.154-.235 2.281-.773 2.806-1.68a.56.56 0 1 0-.968-.56c-.261.454-1.082.873-1.951 1.097zM10 6.364a.56.56 0 0 0 1.118 0v-.9a.56.56 0 0 0-1.118 0z"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="16" height="16"><path fill="#e0e0e0" d="M4.418 1.055a3.364 3.364 0 0 0-3.364 3.364v7.164a3.364 3.364 0 0 0 3.364 3.364h7.164a3.364 3.364 0 0 0 3.364-3.364V4.418a3.364 3.364 0 0 0-3.364-3.364H7.729Zm3.875 1.164h3.291a2.2 2.2 0 0 1 2.2 2.2v7.164a2.2 2.2 0 0 1-2.2 2.2h-2.15a8.884 8.884 0 0 1-.358-1.598c-.135.02-.487.082-.693.117a7.345 7.345 0 0 1-1.254 0 7.114 7.114 0 0 1-.926-.139 6.057 6.057 0 0 1-.867-.271 3.843 3.843 0 0 1-.988-.566 3.214 3.214 0 0 1-.397-.378 2.8 2.8 0 0 1-.318-.441.56.56 0 0 1 .968-.56c.083.138.188.26.312.362.096.082.2.158.307.224.12.075.243.142.371.201.285.139.583.247.89.319a5.35 5.35 0 0 0 1.282.158c.065 0 .129-.005.184-.006.056 0 .102-.005.148-.008l.096-.006c.114-.009.228-.02.31-.032.083-.013.11-.021.143-.028.099-.022.204-.058.327-.089a28.438 28.438 0 0 1-.06-1.929V8.53H6.887c.048-1.963.746-4.357 1.181-5.677.1-.293.184-.527.225-.633ZM5.531 6.394a.56.56 0 0 1-1.118 0v-.9a.56.56 0 0 1 1.118 0Zm3.432 4.646.02.306c.02.264.049.527.082.788l.011.05c1.154-.235 2.281-.773 2.806-1.68a.56.56 0 1 0-.968-.56c-.261.454-1.082.873-1.951 1.097zM10 6.364a.56.56 0 0 0 1.118 0v-.9a.56.56 0 0 0-1.118 0z"/></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -28,20 +28,18 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GL_MANAGER_MACOS_ANGLE_H
|
||||
#define GL_MANAGER_MACOS_ANGLE_H
|
||||
#pragma once
|
||||
|
||||
#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED)
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "drivers/egl/egl_manager.h"
|
||||
#include "servers/display_server.h"
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <CoreVideo/CoreVideo.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <CoreVideo/CoreVideo.h>
|
||||
|
||||
class GLManagerANGLE_MacOS : public EGLManager {
|
||||
private:
|
||||
|
|
@ -59,5 +57,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // MACOS_ENABLED && GLES3_ENABLED
|
||||
|
||||
#endif // GL_MANAGER_MACOS_ANGLE_H
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "gl_manager_macos_angle.h"
|
||||
#import "gl_manager_macos_angle.h"
|
||||
|
||||
#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <EGL/eglext_angle.h>
|
||||
#import <EGL/eglext_angle.h>
|
||||
|
||||
const char *GLManagerANGLE_MacOS::_get_platform_extension_name() const {
|
||||
return "EGL_ANGLE_platform_angle";
|
||||
|
|
|
|||
|
|
@ -28,12 +28,10 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GL_MANAGER_MACOS_LEGACY_H
|
||||
#define GL_MANAGER_MACOS_LEGACY_H
|
||||
#pragma once
|
||||
|
||||
#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED)
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "servers/display_server.h"
|
||||
|
|
@ -42,8 +40,7 @@
|
|||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <CoreVideo/CoreVideo.h>
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
|
||||
|
||||
typedef CGLError (*CGLEnablePtr)(CGLContextObj ctx, CGLContextEnable pname);
|
||||
typedef CGLError (*CGLSetParameterPtr)(CGLContextObj ctx, CGLContextParameter pname, const GLint *params);
|
||||
|
|
@ -91,8 +88,6 @@ public:
|
|||
~GLManagerLegacy_MacOS();
|
||||
};
|
||||
|
||||
#pragma clang diagnostic push
|
||||
GODOT_CLANG_WARNING_PUSH
|
||||
|
||||
#endif // MACOS_ENABLED && GLES3_ENABLED
|
||||
|
||||
#endif // GL_MANAGER_MACOS_LEGACY_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "gl_manager_macos_legacy.h"
|
||||
#import "gl_manager_macos_legacy.h"
|
||||
|
||||
#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED)
|
||||
|
||||
|
|
@ -36,8 +36,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
|
||||
|
||||
Error GLManagerLegacy_MacOS::create_context(GLWindow &win) {
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
|
|
@ -204,6 +203,6 @@ GLManagerLegacy_MacOS::~GLManagerLegacy_MacOS() {
|
|||
release_current();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
GODOT_CLANG_WARNING_POP
|
||||
|
||||
#endif // MACOS_ENABLED && GLES3_ENABLED
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_APPLICATION_H
|
||||
#define GODOT_APPLICATION_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
|
|
@ -39,5 +38,3 @@
|
|||
|
||||
@interface GodotApplication : NSApplication
|
||||
@end
|
||||
|
||||
#endif // GODOT_APPLICATION_H
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_application.h"
|
||||
#import "godot_application.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
|
||||
@implementation GodotApplication
|
||||
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
} break;
|
||||
}
|
||||
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds && keycode != Key::NONE) {
|
||||
DisplayServerMacOS::KeyEvent ke;
|
||||
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
[self mediaKeyEvent:keyCode state:keyState repeat:keyRepeat];
|
||||
}
|
||||
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds) {
|
||||
if ([event type] == NSEventTypeLeftMouseDown || [event type] == NSEventTypeRightMouseDown || [event type] == NSEventTypeOtherMouseDown) {
|
||||
if (ds->mouse_process_popups()) {
|
||||
|
|
|
|||
|
|
@ -28,19 +28,27 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_APPLICATION_DELEGATE_H
|
||||
#define GODOT_APPLICATION_DELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface GodotApplicationDelegate : NSObject <NSUserInterfaceItemSearching, NSApplicationDelegate>
|
||||
@interface GodotApplicationDelegate : NSObject <NSUserInterfaceItemSearching, NSApplicationDelegate> {
|
||||
bool high_contrast;
|
||||
bool reduce_motion;
|
||||
bool reduce_transparency;
|
||||
bool voice_over;
|
||||
}
|
||||
|
||||
- (void)forceUnbundledWindowActivationHackStep1;
|
||||
- (void)forceUnbundledWindowActivationHackStep2;
|
||||
- (void)forceUnbundledWindowActivationHackStep3;
|
||||
- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
|
||||
- (void)accessibilityDisplayOptionsChange:(NSNotification *)notification;
|
||||
- (bool)getHighContrast;
|
||||
- (bool)getReduceMotion;
|
||||
- (bool)getReduceTransparency;
|
||||
- (bool)getVoiceOver;
|
||||
@end
|
||||
|
||||
#endif // GODOT_APPLICATION_DELEGATE_H
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_application_delegate.h"
|
||||
#import "godot_application_delegate.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#include "native_menu_macos.h"
|
||||
#include "os_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "native_menu_macos.h"
|
||||
#import "os_macos.h"
|
||||
|
||||
@implementation GodotApplicationDelegate
|
||||
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
- (void)searchForItemsWithSearchString:(NSString *)searchString resultLimit:(NSInteger)resultLimit matchedItemHandler:(void (^)(NSArray *items))handleMatchedItems {
|
||||
NSMutableArray *found_items = [[NSMutableArray alloc] init];
|
||||
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds && ds->_help_get_search_callback().is_valid()) {
|
||||
Callable cb = ds->_help_get_search_callback();
|
||||
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
}
|
||||
|
||||
- (void)performActionForItem:(id)item {
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds && ds->_help_get_action_callback().is_valid()) {
|
||||
Callable cb = ds->_help_get_action_callback();
|
||||
|
||||
|
|
@ -118,13 +118,19 @@
|
|||
}
|
||||
|
||||
- (void)system_theme_changed:(NSNotification *)notification {
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds) {
|
||||
ds->emit_system_theme_changed();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notice {
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
static_cast<OS_MacOS *>(OS::get_singleton())->start_main();
|
||||
}
|
||||
|
||||
- (void)activate {
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
||||
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
|
||||
const char *bundled_id = getenv("__CFBundleIdentifier");
|
||||
NSString *nsbundleid_env = [NSString stringWithUTF8String:(bundled_id != nullptr) ? bundled_id : ""];
|
||||
|
|
@ -137,12 +143,17 @@
|
|||
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(system_theme_changed:) name:@"AppleColorPreferencesChangedNotification" object:nil];
|
||||
}
|
||||
|
||||
static const char *godot_ac_ctx = "gd_accessibility_observer_ctx";
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
|
||||
NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager];
|
||||
[aem setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
|
||||
[aem setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];
|
||||
[[NSWorkspace sharedWorkspace] addObserver:self forKeyPath:@"voiceOverEnabled" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:(void *)godot_ac_ctx];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(accessibilityDisplayOptionsChange:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
|
||||
high_contrast = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldIncreaseContrast];
|
||||
reduce_motion = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion];
|
||||
reduce_transparency = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceTransparency];
|
||||
voice_over = [[NSWorkspace sharedWorkspace] isVoiceOverEnabled];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
@ -150,38 +161,78 @@
|
|||
- (void)dealloc {
|
||||
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:@"AppleInterfaceThemeChangedNotification" object:nil];
|
||||
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:@"AppleColorPreferencesChangedNotification" object:nil];
|
||||
[[NSWorkspace sharedWorkspace] removeObserver:self forKeyPath:@"voiceOverEnabled" context:(void *)godot_ac_ctx];
|
||||
}
|
||||
|
||||
- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||
if (context == (void *)godot_ac_ctx) {
|
||||
voice_over = [[NSWorkspace sharedWorkspace] isVoiceOverEnabled];
|
||||
} else {
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)accessibilityDisplayOptionsChange:(NSNotification *)notification {
|
||||
high_contrast = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldIncreaseContrast];
|
||||
reduce_motion = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion];
|
||||
reduce_transparency = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceTransparency];
|
||||
}
|
||||
|
||||
- (bool)getHighContrast {
|
||||
return high_contrast;
|
||||
}
|
||||
|
||||
- (bool)getReduceMotion {
|
||||
return reduce_motion;
|
||||
}
|
||||
|
||||
- (bool)getReduceTransparency {
|
||||
return reduce_transparency;
|
||||
}
|
||||
|
||||
- (bool)getVoiceOver {
|
||||
return voice_over;
|
||||
}
|
||||
|
||||
- (void)application:(NSApplication *)application openURLs:(NSArray<NSURL *> *)urls {
|
||||
OS_MacOS *os = (OS_MacOS *)OS::get_singleton();
|
||||
if (!event || !os) {
|
||||
if (!os) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> args;
|
||||
if (([event eventClass] == kInternetEventClass) && ([event eventID] == kAEGetURL)) {
|
||||
// Opening URL scheme.
|
||||
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
args.push_back(vformat("--uri=\"%s\"", String::utf8([url UTF8String])));
|
||||
}
|
||||
|
||||
if (([event eventClass] == kCoreEventClass) && ([event eventID] == kAEOpenDocuments)) {
|
||||
// Opening file association.
|
||||
NSAppleEventDescriptor *files = [event paramDescriptorForKeyword:keyDirectObject];
|
||||
if (files) {
|
||||
NSInteger count = [files numberOfItems];
|
||||
for (NSInteger i = 1; i <= count; i++) {
|
||||
NSURL *url = [NSURL URLWithString:[[files descriptorAtIndex:i] stringValue]];
|
||||
args.push_back(String::utf8([url.path UTF8String]));
|
||||
}
|
||||
for (NSURL *url in urls) {
|
||||
if ([url isFileURL]) {
|
||||
args.push_back(String::utf8([url.path UTF8String]));
|
||||
} else {
|
||||
args.push_back(vformat("--uri=\"%s\"", String::utf8([url.absoluteString UTF8String])));
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.is_empty()) {
|
||||
if (os->get_main_loop()) {
|
||||
// Application is already running, open a new instance with the URL/files as command line arguments.
|
||||
os->create_instance(args);
|
||||
} else {
|
||||
} else if (os->get_cmd_argc() == 0) {
|
||||
// Application is just started, add to the list of command line arguments and continue.
|
||||
os->set_cmdline_platform_args(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)application:(NSApplication *)sender openFiles:(NSArray<NSString *> *)filenames {
|
||||
OS_MacOS *os = (OS_MacOS *)OS::get_singleton();
|
||||
if (!os) {
|
||||
return;
|
||||
}
|
||||
List<String> args;
|
||||
for (NSString *filename in filenames) {
|
||||
NSURL *url = [NSURL URLWithString:filename];
|
||||
args.push_back(String::utf8([url.path UTF8String]));
|
||||
}
|
||||
if (!args.is_empty()) {
|
||||
if (os->get_main_loop()) {
|
||||
// Application is already running, open a new instance with the URL/files as command line arguments.
|
||||
os->create_instance(args);
|
||||
} else if (os->get_cmd_argc() == 0) {
|
||||
// Application is just started, add to the list of command line arguments and continue.
|
||||
os->set_cmdline_platform_args(args);
|
||||
}
|
||||
|
|
@ -189,7 +240,7 @@
|
|||
}
|
||||
|
||||
- (void)applicationDidResignActive:(NSNotification *)notification {
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds) {
|
||||
ds->mouse_process_popups(true);
|
||||
}
|
||||
|
|
@ -205,7 +256,7 @@
|
|||
}
|
||||
|
||||
- (void)globalMenuCallback:(id)sender {
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds) {
|
||||
return ds->menu_callback(sender);
|
||||
}
|
||||
|
|
@ -220,11 +271,23 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)notification {
|
||||
OS_MacOS *os = (OS_MacOS *)OS::get_singleton();
|
||||
if (os) {
|
||||
os->cleanup();
|
||||
exit(os->get_exit_code());
|
||||
}
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
if (ds) {
|
||||
DisplayServerMacOS *ds = Object::cast_to<DisplayServerMacOS>(DisplayServer::get_singleton());
|
||||
if (ds && ds->has_window(DisplayServerMacOS::MAIN_WINDOW_ID)) {
|
||||
ds->send_window_event(ds->get_window(DisplayServerMacOS::MAIN_WINDOW_ID), DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST);
|
||||
}
|
||||
OS_MacOS *os = (OS_MacOS *)OS::get_singleton();
|
||||
if (!os || os->os_should_terminate()) {
|
||||
return NSTerminateNow;
|
||||
}
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_BUTTON_VIEW_H
|
||||
#define GODOT_BUTTON_VIEW_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -53,5 +52,3 @@
|
|||
- (NSPoint)getOffset;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_BUTTON_VIEW_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_button_view.h"
|
||||
#import "godot_button_view.h"
|
||||
|
||||
@implementation GodotButtonView
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_CONTENT_VIEW_H
|
||||
#define GODOT_CONTENT_VIEW_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -55,8 +54,7 @@
|
|||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
|
||||
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
|
||||
|
||||
@interface GodotContentView : RootView <NSTextInputClient> {
|
||||
DisplayServer::WindowID window_id;
|
||||
|
|
@ -79,6 +77,4 @@
|
|||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#endif // GODOT_CONTENT_VIEW_H
|
||||
GODOT_CLANG_WARNING_POP
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_content_view.h"
|
||||
#import "godot_content_view.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#include "key_mapping_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "key_mapping_macos.h"
|
||||
|
||||
#include "main/main.h"
|
||||
|
||||
|
|
@ -270,8 +270,7 @@
|
|||
text.resize([characters length] + 1);
|
||||
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
||||
|
||||
String u32text;
|
||||
u32text.parse_utf16(text.ptr(), text.length());
|
||||
String u32text = String::utf16(text.ptr(), text.length());
|
||||
|
||||
for (int i = 0; i < u32text.length(); i++) {
|
||||
const char32_t codepoint = u32text[i];
|
||||
|
|
@ -622,7 +621,7 @@
|
|||
[self removeTrackingArea:tracking_area];
|
||||
}
|
||||
|
||||
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingCursorUpdate | NSTrackingInVisibleRect;
|
||||
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingActiveWhenFirstResponder | NSTrackingCursorUpdate | NSTrackingInVisibleRect;
|
||||
tracking_area = [[NSTrackingArea alloc] initWithRect:[self bounds] options:options owner:self userInfo:nil];
|
||||
|
||||
[self addTrackingArea:tracking_area];
|
||||
|
|
@ -652,8 +651,7 @@
|
|||
text.resize([characters length] + 1);
|
||||
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
||||
|
||||
String u32text;
|
||||
u32text.parse_utf16(text.ptr(), text.length());
|
||||
String u32text = String::utf16(text.ptr(), text.length());
|
||||
|
||||
DisplayServerMacOS::KeyEvent ke;
|
||||
ke.window_id = window_id;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "os_macos.h"
|
||||
#import "os_macos.h"
|
||||
|
||||
#include "main/main.h"
|
||||
|
||||
|
|
@ -59,36 +59,12 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
OS_MacOS os;
|
||||
Error err;
|
||||
OS_MacOS os(argv[0], argc - first_arg, &argv[first_arg]);
|
||||
|
||||
// We must override main when testing is enabled.
|
||||
TEST_MAIN_OVERRIDE
|
||||
|
||||
@autoreleasepool {
|
||||
err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
|
||||
}
|
||||
|
||||
if (err != OK) {
|
||||
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int ret;
|
||||
@autoreleasepool {
|
||||
ret = Main::start();
|
||||
}
|
||||
if (ret == EXIT_SUCCESS) {
|
||||
os.run();
|
||||
} else {
|
||||
os.set_exit_code(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
Main::cleanup();
|
||||
}
|
||||
os.run(); // Note: This function will never return.
|
||||
|
||||
return os.get_exit_code();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_MENU_DELEGATE_H
|
||||
#define GODOT_MENU_DELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
|
@ -40,5 +39,3 @@
|
|||
- (void)doNothing:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_MENU_DELEGATE_H
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_menu_delegate.h"
|
||||
#import "godot_menu_delegate.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#include "godot_menu_item.h"
|
||||
#include "key_mapping_macos.h"
|
||||
#include "native_menu_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "godot_menu_item.h"
|
||||
#import "key_mapping_macos.h"
|
||||
#import "native_menu_macos.h"
|
||||
|
||||
@implementation GodotMenuDelegate
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_MENU_ITEM_H
|
||||
#define GODOT_MENU_ITEM_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -51,6 +50,7 @@ enum GlobalMenuCheckType {
|
|||
Callable key_callback;
|
||||
Callable hover_callback;
|
||||
Variant meta;
|
||||
Key accel;
|
||||
GlobalMenuCheckType checkable_type;
|
||||
bool checked;
|
||||
int max_states;
|
||||
|
|
@ -59,5 +59,3 @@ enum GlobalMenuCheckType {
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_MENU_ITEM_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_menu_item.h"
|
||||
#import "godot_menu_item.h"
|
||||
|
||||
@implementation GodotMenuItem
|
||||
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
self->checked = false;
|
||||
self->max_states = 0;
|
||||
self->state = 0;
|
||||
self->accel = Key::NONE;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_OPEN_SAVE_DELEGATE_H
|
||||
#define GODOT_OPEN_SAVE_DELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
|
@ -63,5 +62,3 @@
|
|||
- (void)setRootPath:(const String &)p_root_path;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_OPEN_SAVE_DELEGATE_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_open_save_delegate.h"
|
||||
#import "godot_open_save_delegate.h"
|
||||
|
||||
@implementation GodotOpenSaveDelegate
|
||||
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
|
||||
NSMutableArray *type_filters = [[NSMutableArray alloc] init];
|
||||
for (int j = 0; j < filter_slice_count; j++) {
|
||||
String str = (flt.get_slice(",", j).strip_edges());
|
||||
String str = (flt.get_slicec(',', j).strip_edges());
|
||||
if (!str.is_empty()) {
|
||||
if (@available(macOS 11, *)) {
|
||||
UTType *ut = nullptr;
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
|
||||
NSMutableArray *type_filters = [[NSMutableArray alloc] init];
|
||||
for (int j = 0; j < filter_slice_count; j++) {
|
||||
String str = (flt.get_slice(",", j).strip_edges());
|
||||
String str = (flt.get_slicec(',', j).strip_edges());
|
||||
if (!str.is_empty()) {
|
||||
if (@available(macOS 11, *)) {
|
||||
UTType *ut = nullptr;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_STATUS_ITEM_H
|
||||
#define GODOT_STATUS_ITEM_H
|
||||
#pragma once
|
||||
|
||||
#include "core/input/input_enums.h"
|
||||
#include "core/variant/callable.h"
|
||||
|
|
@ -46,5 +45,3 @@
|
|||
- (void)setCallback:(const Callable &)callback;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_STATUS_ITEM_H
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_status_item.h"
|
||||
#import "godot_status_item.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
|
||||
@implementation GodotStatusItemDelegate
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_WINDOW_H
|
||||
#define GODOT_WINDOW_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -45,5 +44,3 @@
|
|||
- (void)setAnimDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_WINDOW_H
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_window.h"
|
||||
#import "godot_window.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
|
||||
@implementation GodotWindow
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_WINDOW_DELEGATE_H
|
||||
#define GODOT_WINDOW_DELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/display_server.h"
|
||||
|
||||
|
|
@ -43,5 +42,3 @@
|
|||
- (void)setWindowID:(DisplayServer::WindowID)wid;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GODOT_WINDOW_DELEGATE_H
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "godot_window_delegate.h"
|
||||
#import "godot_window_delegate.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#include "godot_button_view.h"
|
||||
#include "godot_window.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "godot_button_view.h"
|
||||
#import "godot_window.h"
|
||||
|
||||
@implementation GodotWindowDelegate
|
||||
|
||||
|
|
@ -184,10 +184,12 @@
|
|||
}
|
||||
|
||||
// Restore borderless, transparent and resizability state.
|
||||
if (wd.borderless || wd.layered_window) {
|
||||
if (wd.borderless) {
|
||||
[wd.window_object setStyleMask:NSWindowStyleMaskBorderless];
|
||||
[wd.window_object setHasShadow:NO];
|
||||
} else {
|
||||
[wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.extend_to_title ? NSWindowStyleMaskFullSizeContentView : 0) | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
|
||||
[wd.window_object setHasShadow:YES];
|
||||
}
|
||||
if (wd.layered_window) {
|
||||
ds->set_window_per_pixel_transparency_enabled(true, window_id);
|
||||
|
|
@ -322,6 +324,9 @@
|
|||
|
||||
wd.focused = true;
|
||||
ds->set_last_focused_window(window_id);
|
||||
#ifdef ACCESSKIT_ENABLED
|
||||
ds->accessibility_set_window_focused(window_id, true);
|
||||
#endif
|
||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_IN);
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +344,9 @@
|
|||
|
||||
wd.focused = false;
|
||||
ds->release_pressed_events();
|
||||
#ifdef ACCESSKIT_ENABLED
|
||||
ds->accessibility_set_window_focused(window_id, false);
|
||||
#endif
|
||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_OUT);
|
||||
}
|
||||
|
||||
|
|
@ -352,6 +360,9 @@
|
|||
|
||||
wd.focused = false;
|
||||
ds->release_pressed_events();
|
||||
#ifdef ACCESSKIT_ENABLED
|
||||
ds->accessibility_set_window_focused(window_id, false);
|
||||
#endif
|
||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_OUT);
|
||||
}
|
||||
|
||||
|
|
@ -366,6 +377,9 @@
|
|||
if ([wd.window_object isKeyWindow]) {
|
||||
wd.focused = true;
|
||||
ds->set_last_focused_window(window_id);
|
||||
#ifdef ACCESSKIT_ENABLED
|
||||
ds->accessibility_set_window_focused(window_id, true);
|
||||
#endif
|
||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_IN);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef KEY_MAPPING_MACOS_H
|
||||
#define KEY_MAPPING_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/keyboard.h"
|
||||
|
||||
|
|
@ -51,5 +50,3 @@ public:
|
|||
static String keycode_get_native_string(Key p_keycode);
|
||||
static unsigned int keycode_get_native_mask(Key p_keycode);
|
||||
};
|
||||
|
||||
#endif // KEY_MAPPING_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "key_mapping_macos.h"
|
||||
#import "key_mapping_macos.h"
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
|
|
@ -390,7 +390,7 @@ Key KeyMappingMacOS::remap_key(unsigned int p_key, unsigned int p_state, bool p_
|
|||
LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysBit,
|
||||
&keys_down,
|
||||
sizeof(chars) / sizeof(chars[0]),
|
||||
std::size(chars),
|
||||
&real_length,
|
||||
chars);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MACOS_TERMINAL_LOGGER_H
|
||||
#define MACOS_TERMINAL_LOGGER_H
|
||||
#pragma once
|
||||
|
||||
#ifdef MACOS_ENABLED
|
||||
|
||||
|
|
@ -41,5 +40,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // MACOS_ENABLED
|
||||
|
||||
#endif // MACOS_TERMINAL_LOGGER_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "macos_terminal_logger.h"
|
||||
#import "macos_terminal_logger.h"
|
||||
|
||||
#ifdef MACOS_ENABLED
|
||||
|
||||
|
|
|
|||
11
engine/platform/macos/msvs.py
Normal file
11
engine/platform/macos/msvs.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Tuples with the name of the arch
|
||||
def get_platforms():
|
||||
return [("arm64", "arm64"), ("x64", "x86_64")]
|
||||
|
||||
|
||||
def get_configurations():
|
||||
return ["editor", "template_debug", "template_release"]
|
||||
|
||||
|
||||
def get_build_prefix(env):
|
||||
return []
|
||||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef NATIVE_MENU_MACOS_H
|
||||
#define NATIVE_MENU_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
|
|
@ -160,5 +159,3 @@ public:
|
|||
NativeMenuMacOS();
|
||||
~NativeMenuMacOS();
|
||||
};
|
||||
|
||||
#endif // NATIVE_MENU_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "native_menu_macos.h"
|
||||
#import "native_menu_macos.h"
|
||||
|
||||
#include "display_server_macos.h"
|
||||
#include "godot_menu_item.h"
|
||||
#include "key_mapping_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "godot_menu_item.h"
|
||||
#import "key_mapping_macos.h"
|
||||
|
||||
#include "scene/resources/image_texture.h"
|
||||
|
||||
|
|
@ -294,6 +294,9 @@ void NativeMenuMacOS::popup(const RID &p_rid, const Vector2i &p_position) {
|
|||
position /= ds->screen_get_max_scale();
|
||||
|
||||
[md->menu popUpMenuPositioningItem:nil atLocation:NSMakePoint(position.x, position.y - 5) inView:nil]; // Menu vertical position doesn't include rounded corners, add `5` display pixels to better align it with Godot buttons.
|
||||
|
||||
ds->release_pressed_events(); // Note: context menu block main loop and consume events, pressed keys and mouse buttons should be released manually.
|
||||
ds->sync_mouse_state();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -412,6 +415,7 @@ int NativeMenuMacOS::add_item(const RID &p_rid, const String &p_label, const Cal
|
|||
obj->callback = p_callback;
|
||||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->accel = p_accel;
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
|
||||
[menu_item setRepresentedObject:obj];
|
||||
}
|
||||
|
|
@ -430,6 +434,7 @@ int NativeMenuMacOS::add_check_item(const RID &p_rid, const String &p_label, con
|
|||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->checkable_type = CHECKABLE_TYPE_CHECK_BOX;
|
||||
obj->accel = p_accel;
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
|
||||
[menu_item setRepresentedObject:obj];
|
||||
}
|
||||
|
|
@ -447,6 +452,7 @@ int NativeMenuMacOS::add_icon_item(const RID &p_rid, const Ref<Texture2D> &p_ico
|
|||
obj->callback = p_callback;
|
||||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->accel = p_accel;
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
if (ds && p_icon.is_valid() && p_icon->get_width() > 0 && p_icon->get_height() > 0 && p_icon->get_image().is_valid()) {
|
||||
obj->img = p_icon->get_image();
|
||||
|
|
@ -476,6 +482,7 @@ int NativeMenuMacOS::add_icon_check_item(const RID &p_rid, const Ref<Texture2D>
|
|||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->checkable_type = CHECKABLE_TYPE_CHECK_BOX;
|
||||
obj->accel = p_accel;
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
if (ds && p_icon.is_valid() && p_icon->get_width() > 0 && p_icon->get_height() > 0 && p_icon->get_image().is_valid()) {
|
||||
obj->img = p_icon->get_image();
|
||||
|
|
@ -505,6 +512,7 @@ int NativeMenuMacOS::add_radio_check_item(const RID &p_rid, const String &p_labe
|
|||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->checkable_type = CHECKABLE_TYPE_RADIO_BUTTON;
|
||||
obj->accel = p_accel;
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
|
||||
[menu_item setRepresentedObject:obj];
|
||||
}
|
||||
|
|
@ -523,6 +531,7 @@ int NativeMenuMacOS::add_icon_radio_check_item(const RID &p_rid, const Ref<Textu
|
|||
obj->key_callback = p_key_callback;
|
||||
obj->meta = p_tag;
|
||||
obj->checkable_type = CHECKABLE_TYPE_RADIO_BUTTON;
|
||||
obj->accel = p_accel;
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
if (ds && p_icon.is_valid() && p_icon->get_width() > 0 && p_icon->get_height() > 0 && p_icon->get_image().is_valid()) {
|
||||
obj->img = p_icon->get_image();
|
||||
|
|
@ -553,6 +562,7 @@ int NativeMenuMacOS::add_multistate_item(const RID &p_rid, const String &p_label
|
|||
obj->meta = p_tag;
|
||||
obj->max_states = p_max_states;
|
||||
obj->state = p_default_state;
|
||||
obj->accel = p_accel;
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
|
||||
[menu_item setRepresentedObject:obj];
|
||||
}
|
||||
|
|
@ -1093,6 +1103,8 @@ void NativeMenuMacOS::set_item_submenu(const RID &p_rid, int p_idx, const RID &p
|
|||
NSMenuItem *menu_item = [md->menu itemAtIndex:p_idx];
|
||||
if (menu_item) {
|
||||
[md->menu setSubmenu:md_sub->menu forItem:menu_item];
|
||||
[menu_item setAction:nil];
|
||||
[menu_item setKeyEquivalent:@""];
|
||||
}
|
||||
} else {
|
||||
int item_start = _get_system_menu_start(md->menu);
|
||||
|
|
@ -1105,7 +1117,11 @@ void NativeMenuMacOS::set_item_submenu(const RID &p_rid, int p_idx, const RID &p
|
|||
ERR_PRINT("Can't remove open menu!");
|
||||
return;
|
||||
}
|
||||
GodotMenuItem *obj = [menu_item representedObject];
|
||||
String keycode = KeyMappingMacOS::keycode_get_native_string(obj->accel & KeyModifierMask::CODE_MASK);
|
||||
[md->menu setSubmenu:nil forItem:menu_item];
|
||||
[menu_item setAction:@selector(globalMenuCallback:)];
|
||||
[menu_item setKeyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1121,12 +1137,17 @@ void NativeMenuMacOS::set_item_accelerator(const RID &p_rid, int p_idx, Key p_ke
|
|||
ERR_FAIL_COND(p_idx >= item_start + item_count);
|
||||
NSMenuItem *menu_item = [md->menu itemAtIndex:p_idx];
|
||||
if (menu_item) {
|
||||
if (p_keycode == Key::NONE) {
|
||||
[menu_item setKeyEquivalent:@""];
|
||||
} else {
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_keycode)];
|
||||
String keycode = KeyMappingMacOS::keycode_get_native_string(p_keycode & KeyModifierMask::CODE_MASK);
|
||||
[menu_item setKeyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()]];
|
||||
GodotMenuItem *obj = [menu_item representedObject];
|
||||
obj->accel = p_keycode;
|
||||
NSMenu *sub_menu = [menu_item submenu];
|
||||
if (!sub_menu) {
|
||||
if (p_keycode == Key::NONE) {
|
||||
[menu_item setKeyEquivalent:@""];
|
||||
} else {
|
||||
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_keycode)];
|
||||
String keycode = KeyMappingMacOS::keycode_get_native_string(p_keycode & KeyModifierMask::CODE_MASK);
|
||||
[menu_item setKeyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef OS_MACOS_H
|
||||
#define OS_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#include "crash_handler_macos.h"
|
||||
|
||||
|
|
@ -41,6 +40,14 @@
|
|||
#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;
|
||||
bool main_stared = false;
|
||||
|
||||
JoypadApple *joypad_apple = nullptr;
|
||||
|
||||
#ifdef COREAUDIO_ENABLED
|
||||
|
|
@ -52,7 +59,7 @@ class OS_MacOS : public OS_Unix {
|
|||
|
||||
CrashHandler crash_handler;
|
||||
|
||||
CFRunLoopObserverRef pre_wait_observer;
|
||||
CFRunLoopObserverRef pre_wait_observer = nil;
|
||||
|
||||
MainLoop *main_loop = nullptr;
|
||||
|
||||
|
|
@ -65,6 +72,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;
|
||||
|
|
@ -132,10 +141,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();
|
||||
};
|
||||
|
||||
#endif // OS_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "os_macos.h"
|
||||
#import "os_macos.h"
|
||||
|
||||
#include "dir_access_macos.h"
|
||||
#include "display_server_macos.h"
|
||||
#include "godot_application.h"
|
||||
#include "godot_application_delegate.h"
|
||||
#include "macos_terminal_logger.h"
|
||||
#import "dir_access_macos.h"
|
||||
#import "display_server_macos.h"
|
||||
#import "godot_application.h"
|
||||
#import "godot_application_delegate.h"
|
||||
#import "macos_terminal_logger.h"
|
||||
|
||||
#include "core/crypto/crypto_core.h"
|
||||
#include "core/version_generated.gen.h"
|
||||
|
|
@ -42,19 +42,30 @@
|
|||
|
||||
#include <dlfcn.h>
|
||||
#include <libproc.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#import <mach-o/dyld.h>
|
||||
#include <os/log.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
void OS_MacOS::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context) {
|
||||
// Prevent main loop from sleeping and redraw window during modal popup display.
|
||||
// Do not redraw when rendering is done from the separate thread, it will conflict with the OpenGL context updates.
|
||||
OS_MacOS *os = static_cast<OS_MacOS *>(OS::get_singleton());
|
||||
|
||||
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
||||
if (get_singleton()->get_main_loop() && ds && !get_singleton()->is_separate_thread_rendering_enabled() && !ds->get_is_resizing()) {
|
||||
Main::force_redraw();
|
||||
if (!Main::is_iterating()) { // Avoid cyclic loop.
|
||||
Main::iteration();
|
||||
@autoreleasepool {
|
||||
@try {
|
||||
// Get rid of pending events.
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
DisplayServerMacOS *ds_mac = Object::cast_to<DisplayServerMacOS>(ds);
|
||||
if (ds_mac) {
|
||||
ds_mac->_process_events(false);
|
||||
} else if (ds) {
|
||||
ds->process_events();
|
||||
}
|
||||
os->joypad_apple->process_joypads();
|
||||
|
||||
if (Main::iteration()) {
|
||||
os->terminate();
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +110,7 @@ Vector<String> OS_MacOS::get_granted_permissions() const {
|
|||
BOOL isStale = NO;
|
||||
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
|
||||
if (!error && !isStale) {
|
||||
String url_string;
|
||||
url_string.parse_utf8([[url path] UTF8String]);
|
||||
String url_string = String::utf8([[url path] UTF8String]);
|
||||
ret.push_back(url_string);
|
||||
}
|
||||
}
|
||||
|
|
@ -322,7 +332,7 @@ String OS_MacOS::get_bundle_resource_dir() const {
|
|||
NSBundle *main = [NSBundle mainBundle];
|
||||
if (main) {
|
||||
NSString *resource_path = [main resourcePath];
|
||||
ret.parse_utf8([resource_path UTF8String]);
|
||||
ret.append_utf8([resource_path UTF8String]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -334,7 +344,7 @@ String OS_MacOS::get_bundle_icon_path() const {
|
|||
if (main) {
|
||||
NSString *icon_path = [[main infoDictionary] objectForKey:@"CFBundleIconFile"];
|
||||
if (icon_path) {
|
||||
ret.parse_utf8([icon_path UTF8String]);
|
||||
ret.append_utf8([icon_path UTF8String]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -342,7 +352,7 @@ String OS_MacOS::get_bundle_icon_path() const {
|
|||
|
||||
// Get properly capitalized engine name for system paths
|
||||
String OS_MacOS::get_godot_dir_name() const {
|
||||
return String(VERSION_SHORT_NAME).capitalize();
|
||||
return String(GODOT_VERSION_SHORT_NAME).capitalize();
|
||||
}
|
||||
|
||||
String OS_MacOS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
|
||||
|
|
@ -377,7 +387,7 @@ String OS_MacOS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
|
|||
if (found) {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES);
|
||||
if (paths && [paths count] >= 1) {
|
||||
ret.parse_utf8([[paths firstObject] UTF8String]);
|
||||
ret.append_utf8([[paths firstObject] UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +431,7 @@ Error OS_MacOS::shell_open(const String &p_uri) {
|
|||
|
||||
String OS_MacOS::get_locale() const {
|
||||
NSString *locale_code = [[NSLocale preferredLanguages] objectAtIndex:0];
|
||||
return String([locale_code UTF8String]).replace("-", "_");
|
||||
return String([locale_code UTF8String]).replace_char('-', '_');
|
||||
}
|
||||
|
||||
Vector<String> OS_MacOS::get_system_fonts() const {
|
||||
|
|
@ -544,23 +554,26 @@ Vector<String> OS_MacOS::get_system_font_path_for_text(const String &p_font_name
|
|||
CTFontDescriptorRef font = CTFontDescriptorCreateWithAttributes(attributes);
|
||||
if (font) {
|
||||
CTFontRef family = CTFontCreateWithFontDescriptor(font, 0, nullptr);
|
||||
CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
|
||||
CFRange range = CFRangeMake(0, CFStringGetLength(string));
|
||||
CTFontRef fallback_family = CTFontCreateForString(family, string, range);
|
||||
if (fallback_family) {
|
||||
CTFontDescriptorRef fallback_font = CTFontCopyFontDescriptor(fallback_family);
|
||||
if (fallback_font) {
|
||||
CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fallback_font, kCTFontURLAttribute);
|
||||
if (url) {
|
||||
NSString *font_path = [NSString stringWithString:[(__bridge NSURL *)url path]];
|
||||
ret.push_back(String::utf8([font_path UTF8String]));
|
||||
CFRelease(url);
|
||||
if (family) {
|
||||
CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
|
||||
CFRange range = CFRangeMake(0, CFStringGetLength(string));
|
||||
CTFontRef fallback_family = CTFontCreateForString(family, string, range);
|
||||
if (fallback_family) {
|
||||
CTFontDescriptorRef fallback_font = CTFontCopyFontDescriptor(fallback_family);
|
||||
if (fallback_font) {
|
||||
CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fallback_font, kCTFontURLAttribute);
|
||||
if (url) {
|
||||
NSString *font_path = [NSString stringWithString:[(__bridge NSURL *)url path]];
|
||||
ret.push_back(String::utf8([font_path UTF8String]));
|
||||
CFRelease(url);
|
||||
}
|
||||
CFRelease(fallback_font);
|
||||
}
|
||||
CFRelease(fallback_font);
|
||||
CFRelease(fallback_family);
|
||||
}
|
||||
CFRelease(fallback_family);
|
||||
CFRelease(string);
|
||||
CFRelease(family);
|
||||
}
|
||||
CFRelease(string);
|
||||
CFRelease(font);
|
||||
}
|
||||
|
||||
|
|
@ -637,10 +650,7 @@ String OS_MacOS::get_executable_path() const {
|
|||
if (ret <= 0) {
|
||||
return OS::get_executable_path();
|
||||
} else {
|
||||
String path;
|
||||
path.parse_utf8(pathbuf);
|
||||
|
||||
return path;
|
||||
return String::utf8(pathbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -710,8 +720,7 @@ Error OS_MacOS::create_instance(const List<String> &p_arguments, ProcessID *r_ch
|
|||
// If executable is bundled, always execute editor instances as an app bundle to ensure app window is registered and activated correctly.
|
||||
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
|
||||
if (nsappname != nil) {
|
||||
String path;
|
||||
path.parse_utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
|
||||
String path = String::utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
|
||||
return create_process(path, p_arguments, r_child_id, false);
|
||||
} else {
|
||||
return create_process(get_executable_path(), p_arguments, r_child_id, false);
|
||||
|
|
@ -745,7 +754,7 @@ String OS_MacOS::get_unique_id() const {
|
|||
}
|
||||
|
||||
if (serial_number_ns_string) {
|
||||
serial_number.parse_utf8([serial_number_ns_string UTF8String]);
|
||||
serial_number.append_utf8([serial_number_ns_string UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -806,7 +815,8 @@ String OS_MacOS::get_system_ca_certificates() {
|
|||
Error err = CryptoCore::b64_encode(pba.ptrw(), pba.size(), &b64len, (unsigned char *)CFDataGetBytePtr(der), derlen);
|
||||
CFRelease(der);
|
||||
ERR_CONTINUE(err != OK);
|
||||
certs += "-----BEGIN CERTIFICATE-----\n" + String((char *)pba.ptr(), b64len) + "\n-----END CERTIFICATE-----\n";
|
||||
// Certificate is bas64 encoded, aka ascii.
|
||||
certs += "-----BEGIN CERTIFICATE-----\n" + String::ascii(Span((char *)pba.ptr(), b64len)) + "\n-----END CERTIFICATE-----\n";
|
||||
}
|
||||
CFRelease(result);
|
||||
return certs;
|
||||
|
|
@ -819,36 +829,73 @@ OS::PreferredTextureFormat OS_MacOS::get_preferred_texture_format() const {
|
|||
}
|
||||
|
||||
void OS_MacOS::run() {
|
||||
if (!main_loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
main_loop->initialize();
|
||||
}
|
||||
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
@autoreleasepool {
|
||||
@try {
|
||||
if (DisplayServer::get_singleton()) {
|
||||
DisplayServer::get_singleton()->process_events(); // Get rid of pending events.
|
||||
}
|
||||
joypad_apple->process_joypads();
|
||||
|
||||
if (Main::iteration()) {
|
||||
quit = true;
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main_loop->finalize();
|
||||
[NSApp run];
|
||||
}
|
||||
|
||||
OS_MacOS::OS_MacOS() {
|
||||
void OS_MacOS::start_main() {
|
||||
Error err;
|
||||
@autoreleasepool {
|
||||
err = Main::setup(execpath, argc, argv);
|
||||
}
|
||||
|
||||
if (err == OK) {
|
||||
main_stared = true;
|
||||
|
||||
int ret;
|
||||
@autoreleasepool {
|
||||
ret = Main::start();
|
||||
}
|
||||
if (ret == EXIT_SUCCESS) {
|
||||
if (main_loop) {
|
||||
@autoreleasepool {
|
||||
main_loop->initialize();
|
||||
}
|
||||
pre_wait_observer = CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, &pre_wait_observer_cb, nullptr);
|
||||
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
set_exit_code(EXIT_FAILURE);
|
||||
}
|
||||
} else if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||
set_exit_code(EXIT_SUCCESS);
|
||||
} else {
|
||||
set_exit_code(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
terminate();
|
||||
}
|
||||
|
||||
void OS_MacOS::activate() {
|
||||
[delegate activate];
|
||||
}
|
||||
|
||||
void OS_MacOS::terminate() {
|
||||
if (pre_wait_observer) {
|
||||
CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
CFRelease(pre_wait_observer);
|
||||
pre_wait_observer = nil;
|
||||
}
|
||||
|
||||
should_terminate = true;
|
||||
[NSApp terminate:nil];
|
||||
}
|
||||
|
||||
void OS_MacOS::cleanup() {
|
||||
if (main_loop) {
|
||||
main_loop->finalize();
|
||||
}
|
||||
if (main_stared) {
|
||||
@autoreleasepool {
|
||||
Main::cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OS_MacOS::OS_MacOS(const char *p_execpath, int p_argc, char **p_argv) {
|
||||
execpath = p_execpath;
|
||||
argc = p_argc;
|
||||
argv = p_argv;
|
||||
if (is_sandboxed()) {
|
||||
// Load security-scoped bookmarks, request access, remove stale or invalid bookmarks.
|
||||
NSArray *bookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:@"sec_bookmarks"];
|
||||
|
|
@ -882,7 +929,7 @@ OS_MacOS::OS_MacOS() {
|
|||
[GodotApplication sharedApplication];
|
||||
|
||||
// In case we are unbundled, make us a proper UI application.
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
|
||||
|
||||
// Menu bar setup must go between sharedApplication above and
|
||||
// finishLaunching below, in order to properly emulate the behavior
|
||||
|
|
@ -890,35 +937,13 @@ OS_MacOS::OS_MacOS() {
|
|||
|
||||
NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""];
|
||||
[NSApp setMainMenu:main_menu];
|
||||
[NSApp finishLaunching];
|
||||
|
||||
id delegate = [[GodotApplicationDelegate alloc] init];
|
||||
delegate = [[GodotApplicationDelegate alloc] init];
|
||||
ERR_FAIL_NULL(delegate);
|
||||
[NSApp setDelegate:delegate];
|
||||
[NSApp registerUserInterfaceItemSearchHandler:delegate];
|
||||
|
||||
pre_wait_observer = CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, &pre_wait_observer_cb, nullptr);
|
||||
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
|
||||
// Process application:openFile: event.
|
||||
while (true) {
|
||||
NSEvent *event = [NSApp
|
||||
nextEventMatchingMask:NSEventMaskAny
|
||||
untilDate:[NSDate distantPast]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES];
|
||||
|
||||
if (event == nil) {
|
||||
break;
|
||||
}
|
||||
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
OS_MacOS::~OS_MacOS() {
|
||||
CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
CFRelease(pre_wait_observer);
|
||||
// NOP
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,12 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#define PLATFORM_THREAD_OVERRIDE
|
||||
|
||||
#define PTHREAD_RENAME_SELF
|
||||
|
||||
#define _weakify(var) __weak typeof(var) GDWeak_##var = var;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PLATFORM_GL_H
|
||||
#define PLATFORM_GL_H
|
||||
#pragma once
|
||||
|
||||
#ifndef GL_API_ENABLED
|
||||
#define GL_API_ENABLED // Allow using desktop GL.
|
||||
|
|
@ -48,5 +47,3 @@
|
|||
#include "thirdparty/glad/glad/egl.h"
|
||||
#endif
|
||||
#include "thirdparty/glad/glad/gl.h"
|
||||
|
||||
#endif // PLATFORM_GL_H
|
||||
|
|
|
|||
33
engine/platform/macos/platform_thread.h
Normal file
33
engine/platform/macos/platform_thread.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**************************************************************************/
|
||||
/* platform_thread.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "drivers/apple/thread_apple.h"
|
||||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDERING_CONTEXT_DRIVER_VULKAN_MACOS_H
|
||||
#define RENDERING_CONTEXT_DRIVER_VULKAN_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#ifdef VULKAN_ENABLED
|
||||
|
||||
|
|
@ -54,5 +53,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // VULKAN_ENABLED
|
||||
|
||||
#endif // RENDERING_CONTEXT_DRIVER_VULKAN_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "rendering_context_driver_vulkan_macos.h"
|
||||
#import "rendering_context_driver_vulkan_macos.h"
|
||||
|
||||
#ifdef VULKAN_ENABLED
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TTS_MACOS_H
|
||||
#define TTS_MACOS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/templates/hash_map.h"
|
||||
|
|
@ -67,5 +66,3 @@
|
|||
- (void)speak:(const String &)text voice:(const String &)voice volume:(int)volume pitch:(float)pitch rate:(float)rate utterance_id:(int)utterance_id interrupt:(bool)interrupt;
|
||||
- (Array)getVoices;
|
||||
@end
|
||||
|
||||
#endif // TTS_MACOS_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "tts_macos.h"
|
||||
#import "tts_macos.h"
|
||||
|
||||
@implementation TTS_MacOS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue