summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/crash_handler_osx.h1
-rw-r--r--platform/osx/crash_handler_osx.mm1
-rw-r--r--platform/osx/detect.py4
-rw-r--r--platform/osx/dir_access_osx.h1
-rw-r--r--platform/osx/dir_access_osx.mm1
-rw-r--r--platform/osx/export/export.cpp45
-rw-r--r--platform/osx/export/export.h1
-rw-r--r--platform/osx/godot_main_osx.mm1
-rw-r--r--platform/osx/joypad_osx.cpp1
-rw-r--r--platform/osx/joypad_osx.h1
-rw-r--r--platform/osx/os_osx.h3
-rw-r--r--platform/osx/os_osx.mm179
-rw-r--r--platform/osx/platform_config.h1
-rw-r--r--platform/osx/sem_osx.cpp1
-rw-r--r--platform/osx/sem_osx.h1
15 files changed, 160 insertions, 82 deletions
diff --git a/platform/osx/crash_handler_osx.h b/platform/osx/crash_handler_osx.h
index 51e0a3ffcb..5d93afb22d 100644
--- a/platform/osx/crash_handler_osx.h
+++ b/platform/osx/crash_handler_osx.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef CRASH_HANDLER_OSX_H
#define CRASH_HANDLER_OSX_H
diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm
index c4b5204e1a..d757674a9b 100644
--- a/platform/osx/crash_handler_osx.mm
+++ b/platform/osx/crash_handler_osx.mm
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "main/main.h"
#include "os_osx.h"
#include "project_settings.h"
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 2e686fbee4..bb601abd40 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -76,7 +76,7 @@ def configure(env):
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
mpclangver = env["macports_clang"]
env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang"
- env["LD"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++"
+ env["LINK"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++"
env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++"
env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar"
env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
@@ -110,7 +110,7 @@ def configure(env):
if (env["CXX"] == "clang++"):
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
env["CC"] = "clang"
- env["LD"] = "clang++"
+ env["LINK"] = "clang++"
## Dependencies
diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h
index eec3016eaa..e01ff2fe4d 100644
--- a/platform/osx/dir_access_osx.h
+++ b/platform/osx/dir_access_osx.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef DIR_ACCESS_OSX_H
#define DIR_ACCESS_OSX_H
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
index a187083dd1..cf66cab060 100644
--- a/platform/osx/dir_access_osx.mm
+++ b/platform/osx/dir_access_osx.mm
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "dir_access_osx.h"
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 657a899367..c4efa1f0ff 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -359,6 +359,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
if (err == OK) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks");
+ err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
+ }
+
+ if (err == OK) {
print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
}
@@ -502,10 +507,23 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (use_dmg()) {
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
- err = save_pack(p_preset, pack_path);
+ Vector<SharedObject> shared_objects;
+ Error err = save_pack(p_preset, pack_path, &shared_objects);
// see if we can code sign our new package
String identity = p_preset->get("codesign/identity");
+
+ if (err == OK) {
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < shared_objects.size(); i++) {
+ da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
+ if (err == OK && identity != "") {
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
+ }
+ }
+ memdelete(da);
+ }
+
if (err == OK && identity != "") {
ep.step("Code signing bundle", 2);
@@ -541,7 +559,9 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
} else {
String pack_path = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".pck");
- Error err = save_pack(p_preset, pack_path);
+
+ Vector<SharedObject> shared_objects;
+ Error err = save_pack(p_preset, pack_path, &shared_objects);
if (err == OK) {
zipOpenNewFileInZip(dst_pkg_zip,
@@ -567,11 +587,32 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
break;
zipWriteInFileInZip(dst_pkg_zip, buf, r);
}
+
zipCloseFileInZip(dst_pkg_zip);
memdelete(pf);
} else {
err = ERR_CANT_OPEN;
}
+
+ //add shared objects
+ for (int i = 0; i < shared_objects.size(); i++) {
+ Vector<uint8_t> file = FileAccess::get_file_as_array(shared_objects[i].path);
+ ERR_CONTINUE(file.empty());
+
+ zipOpenNewFileInZip(dst_pkg_zip,
+ (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(dst_pkg_zip, file.ptr(), file.size());
+ zipCloseFileInZip(dst_pkg_zip);
+ }
}
}
}
diff --git a/platform/osx/export/export.h b/platform/osx/export/export.h
index ccb96022f9..08294fc33c 100644
--- a/platform/osx/export/export.h
+++ b/platform/osx/export/export.h
@@ -27,4 +27,5 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_osx_exporter();
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 156b4c02f2..9d1a5566c9 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "main/main.h"
#include "os_osx.h"
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index bc65aa8149..20ceadca9d 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "joypad_osx.h"
#include <machine/endian.h>
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index 78ee4581d5..addbefc5ad 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef JOYPADOSX_H
#define JOYPADOSX_H
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 2a71de12e9..3648d41604 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef OS_OSX_H
#define OS_OSX_H
@@ -138,6 +139,8 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
+
virtual void set_cursor_shape(CursorShape p_shape);
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index a16391c30f..939f75859c 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "os_osx.h"
#include "dir_access_osx.h"
@@ -38,6 +39,8 @@
#include "servers/visual/visual_server_raster.h"
#include "version_generated.gen.h"
+#include <mach-o/dyld.h>
+
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <IOKit/IOCFPlugIn.h>
@@ -48,6 +51,7 @@
#include <os/log.h>
#endif
+#include <dlfcn.h>
#include <fcntl.h>
#include <libproc.h>
#include <stdio.h>
@@ -57,25 +61,31 @@
#include <unistd.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+#define NSEventMaskAny NSAnyEventMask
+#define NSEventTypeKeyDown NSKeyDown
+#define NSEventTypeKeyUp NSKeyUp
+#define NSEventModifierFlagShift NSShiftKeyMask
+#define NSEventModifierFlagCommand NSCommandKeyMask
+#define NSEventModifierFlagControl NSControlKeyMask
+#define NSEventModifierFlagOption NSAlternateKeyMask
+#define NSWindowStyleMaskTitled NSTitledWindowMask
+#define NSWindowStyleMaskResizable NSResizableWindowMask
+#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
+#define NSWindowStyleMaskClosable NSClosableWindowMask
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#endif
static NSRect convertRectToBacking(NSRect contentRect) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
- return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
- else
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
- return contentRect;
+ return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
}
static void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> state) {
- state->set_shift((p_osx_state & NSShiftKeyMask));
- state->set_control((p_osx_state & NSControlKeyMask));
- state->set_alt((p_osx_state & NSAlternateKeyMask));
- state->set_metakey((p_osx_state & NSCommandKeyMask));
+ state->set_shift((p_osx_state & NSEventModifierFlagShift));
+ state->set_control((p_osx_state & NSEventModifierFlagControl));
+ state->set_alt((p_osx_state & NSEventModifierFlagOption));
+ state->set_metakey((p_osx_state & NSEventModifierFlagCommand));
}
static int mouse_x = 0;
@@ -103,7 +113,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
// special case handling of command-period, which is traditionally a special
// shortcut in macOS and doesn't arrive at our regular keyDown handler.
- if ([event type] == NSKeyDown) {
+ if ([event type] == NSEventTypeKeyDown) {
if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
Ref<InputEventKey> k;
@@ -121,7 +131,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
- if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
+ if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand))
[[self keyWindow] sendEvent:event];
else
[super sendEvent:event];
@@ -187,7 +197,6 @@ static Vector2 get_mouse_pos(NSEvent *event) {
return NO;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
OS_OSX::singleton->zoomed = true;
}
@@ -195,7 +204,6 @@ static Vector2 get_mouse_pos(NSEvent *event) {
- (void)windowDidExitFullScreen:(NSNotification *)notification {
OS_OSX::singleton->zoomed = false;
}
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED
- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
if (!OS_OSX::singleton)
@@ -389,8 +397,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)cancelComposition {
[self unmarkText];
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- [currentInputManager markedTextAbandoned:self];
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
}
- (void)insertText:(id)aString {
@@ -419,8 +427,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
NSCharacterSet *ctrlChars = [NSCharacterSet controlCharacterSet];
NSCharacterSet *wsnlChars = [NSCharacterSet whitespaceAndNewlineCharacterSet];
if ([characters rangeOfCharacterFromSet:ctrlChars].length && [characters rangeOfCharacterFromSet:wsnlChars].length == 0) {
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- [currentInputManager markedTextAbandoned:self];
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
[self cancelComposition];
return;
}
@@ -506,7 +514,7 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
}
- (void)mouseDown:(NSEvent *)event {
- if (([event modifierFlags] & NSControlKeyMask)) {
+ if (([event modifierFlags] & NSEventModifierFlagControl)) {
mouse_down_control = true;
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
} else {
@@ -807,29 +815,29 @@ static int translateKey(unsigned int key) {
int mod = [event modifierFlags];
if (key == 0x36 || key == 0x37) {
- if (mod & NSCommandKeyMask) {
- mod &= ~NSCommandKeyMask;
+ if (mod & NSEventModifierFlagCommand) {
+ mod &= ~NSEventModifierFlagCommand;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x38 || key == 0x3c) {
- if (mod & NSShiftKeyMask) {
- mod &= ~NSShiftKeyMask;
+ if (mod & NSEventModifierFlagShift) {
+ mod &= ~NSEventModifierFlagShift;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x3a || key == 0x3d) {
- if (mod & NSAlternateKeyMask) {
- mod &= ~NSAlternateKeyMask;
+ if (mod & NSEventModifierFlagOption) {
+ mod &= ~NSEventModifierFlagOption;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x3b || key == 0x3e) {
- if (mod & NSControlKeyMask) {
- mod &= ~NSControlKeyMask;
+ if (mod & NSEventModifierFlagControl) {
+ mod &= ~NSEventModifierFlagControl;
k->set_pressed(true);
} else {
k->set_pressed(false);
@@ -889,20 +897,12 @@ inline void sendPanEvent(double dx, double dy, int modifierFlags) {
- (void)scrollWheel:(NSEvent *)event {
double deltaX, deltaY;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
- deltaX = [event scrollingDeltaX];
- deltaY = [event scrollingDeltaY];
+ deltaX = [event scrollingDeltaX];
+ deltaY = [event scrollingDeltaY];
- if ([event hasPreciseScrollingDeltas]) {
- deltaX *= 0.03;
- deltaY *= 0.03;
- }
- } else
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED
- {
- deltaX = [event deltaX];
- deltaY = [event deltaY];
+ if ([event hasPreciseScrollingDeltas]) {
+ deltaX *= 0.03;
+ deltaY *= 0.03;
}
if ([event phase] != NSEventPhaseNone || [event momentumPhase] != NSEventPhaseNone) {
@@ -1004,7 +1004,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
if (p_desired.borderless_window) {
styleMask = NSWindowStyleMaskBorderless;
} else {
- styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
+ styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0);
}
window_object = [[GodotWindow alloc]
@@ -1013,7 +1013,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
backing:NSBackingStoreBuffered
defer:NO];
- ERR_FAIL_COND(window_object == nil, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(window_object == nil, ERR_UNAVAILABLE);
window_view = [[GodotContentView alloc] init];
@@ -1029,7 +1029,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
window_size.width = p_desired.width * displayScale;
window_size.height = p_desired.height * displayScale;
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && displayScale > 1.0) {
+ if (displayScale > 1.0) {
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
@@ -1041,8 +1041,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
[window_object setAcceptsMouseMovedEvents:YES];
[window_object center];
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
- [window_object setRestorable:NO];
+ [window_object setRestorable:NO];
unsigned int attributeCount = 0;
@@ -1100,11 +1099,11 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
#undef ADD_ATTR2
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
- ERR_FAIL_COND(pixelFormat == nil, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(pixelFormat == nil, ERR_UNAVAILABLE);
context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
- ERR_FAIL_COND(context == nil, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(context == nil, ERR_UNAVAILABLE);
[context setView:window_view];
@@ -1202,34 +1201,42 @@ public:
switch (p_type) {
case ERR_WARNING:
- os_log_info(OS_LOG_DEFAULT,
- "WARNING: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
+ os_log_info(OS_LOG_DEFAULT,
+ "WARNING: %{public}s: %{public}s\nAt: %{public}s:%i.",
+ p_function, err_details, p_file, p_line);
+ }
logf_error("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n", p_function,
err_details);
logf_error("\E[0;33m At: %s:%i.\E[0m\n", p_file, p_line);
break;
case ERR_SCRIPT:
- os_log_error(OS_LOG_DEFAULT,
- "SCRIPT ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
+ os_log_error(OS_LOG_DEFAULT,
+ "SCRIPT ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
+ p_function, err_details, p_file, p_line);
+ }
logf_error("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n", p_function,
err_details);
logf_error("\E[0;35m At: %s:%i.\E[0m\n", p_file, p_line);
break;
case ERR_SHADER:
- os_log_error(OS_LOG_DEFAULT,
- "SHADER ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
+ os_log_error(OS_LOG_DEFAULT,
+ "SHADER ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
+ p_function, err_details, p_file, p_line);
+ }
logf_error("\E[1;36mSHADER ERROR: %s: \E[0m\E[1m%s\n", p_function,
err_details);
logf_error("\E[0;36m At: %s:%i.\E[0m\n", p_file, p_line);
break;
case ERR_ERROR:
default:
- os_log_error(OS_LOG_DEFAULT,
- "ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
+ os_log_error(OS_LOG_DEFAULT,
+ "ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
+ p_function, err_details, p_file, p_line);
+ }
logf_error("\E[1;31mERROR: %s: \E[0m\E[1m%s\n", p_function, err_details);
logf_error("\E[0;31m At: %s:%i.\E[0m\n", p_file, p_line);
break;
@@ -1258,6 +1265,28 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) {
[window release];
}
+Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+
+ String path = p_path;
+
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from within the executable path
+ path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
+ }
+
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from a standard macOS location
+ path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file());
+ }
+
+ p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
+ if (!p_library_handle) {
+ ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+ return OK;
+}
+
void OS_OSX::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape == p_shape)
@@ -1742,9 +1771,8 @@ float OS_OSX::_display_scale(id screen) const {
if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
return fmax(1.0, [screen backingScaleFactor]);
}
- } else {
- return 1.0;
}
+ return 1.0;
}
Point2 OS_OSX::get_native_window_position() const {
@@ -1803,10 +1831,14 @@ void OS_OSX::set_window_size(const Size2 p_size) {
CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
if (menuBarHeight != 0.f) {
size.y += menuBarHeight;
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101104
} else {
- size.y += [[NSStatusBar systemStatusBar] thickness];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
+ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12) {
+#else
+ {
#endif
+ size.y += [[NSStatusBar systemStatusBar] thickness];
+ }
}
}
@@ -1819,36 +1851,27 @@ void OS_OSX::set_window_size(const Size2 p_size) {
void OS_OSX::set_window_fullscreen(bool p_enabled) {
if (zoomed != p_enabled) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
[window_object toggleFullScreen:nil];
-#else
- [window_object performZoom:nil];
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
}
zoomed = p_enabled;
};
bool OS_OSX::is_window_fullscreen() const {
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
- if ([window_object respondsToSelector:@selector(isZoomed)])
- return [window_object isZoomed];
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
-
return zoomed;
};
void OS_OSX::set_window_resizable(bool p_enabled) {
if (p_enabled)
- [window_object setStyleMask:[window_object styleMask] | NSResizableWindowMask];
+ [window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
else
- [window_object setStyleMask:[window_object styleMask] & ~NSResizableWindowMask];
+ [window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable];
};
bool OS_OSX::is_window_resizable() const {
- return [window_object styleMask] & NSResizableWindowMask;
+ return [window_object styleMask] & NSWindowStyleMaskResizable;
};
void OS_OSX::set_window_minimized(bool p_enabled) {
@@ -1903,7 +1926,7 @@ void OS_OSX::set_borderless_window(bool p_borderless) {
if (p_borderless) {
[window_object setStyleMask:NSWindowStyleMaskBorderless];
} else {
- [window_object setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask];
+ [window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable];
// Force update of the window styles
NSRect frameRect = [window_object frame];
@@ -2027,7 +2050,7 @@ void OS_OSX::process_events() {
while (true) {
NSEvent *event = [NSApp
- nextEventMatchingMask:NSAnyEventMask
+ nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@@ -2219,7 +2242,7 @@ OS_OSX::OS_OSX() {
[apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
+ [menu_item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)];
[apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h
index a3715e7e4e..1b497cebef 100644
--- a/platform/osx/platform_config.h
+++ b/platform/osx/platform_config.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include <alloca.h>
#define GLES3_INCLUDE_H "glad/glad.h"
diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp
index 2e7da62e5b..92f749322e 100644
--- a/platform/osx/sem_osx.cpp
+++ b/platform/osx/sem_osx.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "sem_osx.h"
#include <fcntl.h>
diff --git a/platform/osx/sem_osx.h b/platform/osx/sem_osx.h
index 0b9bbdfa76..ce31e966b7 100644
--- a/platform/osx/sem_osx.h
+++ b/platform/osx/sem_osx.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef SEM_OSX_H
#define SEM_OSX_H