diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/SCsub (renamed from platform/iphone/SCsub) | 18 | ||||
-rw-r--r-- | platform/ios/api/api.cpp (renamed from platform/iphone/api/api.cpp) | 10 | ||||
-rw-r--r-- | platform/ios/api/api.h (renamed from platform/iphone/api/api.h) | 12 | ||||
-rw-r--r-- | platform/ios/app_delegate.h (renamed from platform/iphone/app_delegate.h) | 0 | ||||
-rw-r--r-- | platform/ios/app_delegate.mm (renamed from platform/iphone/app_delegate.mm) | 18 | ||||
-rw-r--r-- | platform/ios/detect.py (renamed from platform/iphone/detect.py) | 30 | ||||
-rw-r--r-- | platform/ios/device_metrics.h (renamed from platform/iphone/device_metrics.h) | 0 | ||||
-rw-r--r-- | platform/ios/device_metrics.m (renamed from platform/iphone/device_metrics.m) | 0 | ||||
-rw-r--r-- | platform/ios/display_layer.h (renamed from platform/iphone/display_layer.h) | 0 | ||||
-rw-r--r-- | platform/ios/display_layer.mm (renamed from platform/iphone/display_layer.mm) | 4 | ||||
-rw-r--r-- | platform/ios/display_server_ios.h (renamed from platform/iphone/display_server_iphone.h) | 24 | ||||
-rw-r--r-- | platform/ios/display_server_ios.mm (renamed from platform/iphone/display_server_iphone.mm) | 197 | ||||
-rw-r--r-- | platform/ios/export/export.cpp (renamed from platform/iphone/export/export.cpp) | 2 | ||||
-rw-r--r-- | platform/ios/export/export.h (renamed from platform/osx/export/export.h) | 8 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.cpp (renamed from platform/iphone/export/export_plugin.cpp) | 22 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.h (renamed from platform/iphone/export/export_plugin.h) | 6 | ||||
-rw-r--r-- | platform/ios/export/godot_plugin_config.cpp (renamed from platform/iphone/export/godot_plugin_config.cpp) | 0 | ||||
-rw-r--r-- | platform/ios/export/godot_plugin_config.h (renamed from platform/iphone/export/godot_plugin_config.h) | 4 | ||||
-rw-r--r-- | platform/ios/godot_app_delegate.h (renamed from platform/iphone/godot_app_delegate.h) | 0 | ||||
-rw-r--r-- | platform/ios/godot_app_delegate.m (renamed from platform/iphone/godot_app_delegate.m) | 0 | ||||
-rw-r--r-- | platform/ios/godot_ios.mm (renamed from platform/iphone/godot_iphone.mm) | 18 | ||||
-rw-r--r-- | platform/ios/godot_view.h (renamed from platform/iphone/godot_view.h) | 0 | ||||
-rw-r--r-- | platform/ios/godot_view.mm (renamed from platform/iphone/godot_view.mm) | 46 | ||||
-rw-r--r-- | platform/ios/godot_view_gesture_recognizer.h (renamed from platform/iphone/godot_view_gesture_recognizer.h) | 0 | ||||
-rw-r--r-- | platform/ios/godot_view_gesture_recognizer.mm (renamed from platform/iphone/godot_view_gesture_recognizer.mm) | 0 | ||||
-rw-r--r-- | platform/ios/godot_view_renderer.h (renamed from platform/iphone/godot_view_renderer.h) | 0 | ||||
-rw-r--r-- | platform/ios/godot_view_renderer.mm (renamed from platform/iphone/godot_view_renderer.mm) | 10 | ||||
-rw-r--r-- | platform/ios/ios.h (renamed from platform/iphone/ios.h) | 0 | ||||
-rw-r--r-- | platform/ios/ios.mm (renamed from platform/iphone/ios.mm) | 0 | ||||
-rw-r--r-- | platform/ios/joypad_ios.h (renamed from platform/iphone/joypad_iphone.h) | 12 | ||||
-rw-r--r-- | platform/ios/joypad_ios.mm (renamed from platform/iphone/joypad_iphone.mm) | 18 | ||||
-rw-r--r-- | platform/ios/keyboard_input_view.h (renamed from platform/iphone/keyboard_input_view.h) | 0 | ||||
-rw-r--r-- | platform/ios/keyboard_input_view.mm (renamed from platform/iphone/keyboard_input_view.mm) | 12 | ||||
-rw-r--r-- | platform/ios/logo.png (renamed from platform/iphone/logo.png) | bin | 1297 -> 1297 bytes | |||
-rw-r--r-- | platform/ios/main.m (renamed from platform/iphone/main.m) | 0 | ||||
-rw-r--r-- | platform/ios/os_ios.h (renamed from platform/iphone/os_iphone.h) | 26 | ||||
-rw-r--r-- | platform/ios/os_ios.mm (renamed from platform/iphone/os_iphone.mm) | 98 | ||||
-rw-r--r-- | platform/ios/platform_config.h (renamed from platform/iphone/platform_config.h) | 0 | ||||
-rw-r--r-- | platform/ios/tts_ios.h (renamed from platform/iphone/tts_ios.h) | 0 | ||||
-rw-r--r-- | platform/ios/tts_ios.mm (renamed from platform/iphone/tts_ios.mm) | 0 | ||||
-rw-r--r-- | platform/ios/view_controller.h (renamed from platform/iphone/view_controller.h) | 0 | ||||
-rw-r--r-- | platform/ios/view_controller.mm (renamed from platform/iphone/view_controller.mm) | 20 | ||||
-rw-r--r-- | platform/ios/vulkan_context_ios.h (renamed from platform/iphone/vulkan_context_iphone.h) | 14 | ||||
-rw-r--r-- | platform/ios/vulkan_context_ios.mm (renamed from platform/iphone/vulkan_context_iphone.mm) | 12 | ||||
-rw-r--r-- | platform/javascript/js/engine/config.js | 1 | ||||
-rw-r--r-- | platform/linuxbsd/SCsub | 12 | ||||
-rw-r--r-- | platform/linuxbsd/detect.py | 110 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 6 | ||||
-rw-r--r-- | platform/macos/SCsub | 30 | ||||
-rw-r--r-- | platform/macos/crash_handler_macos.h (renamed from platform/osx/crash_handler_osx.h) | 8 | ||||
-rw-r--r-- | platform/macos/crash_handler_macos.mm (renamed from platform/osx/crash_handler_osx.mm) | 4 | ||||
-rw-r--r-- | platform/macos/detect.py (renamed from platform/osx/detect.py) | 12 | ||||
-rw-r--r-- | platform/macos/dir_access_macos.h (renamed from platform/osx/dir_access_osx.h) | 8 | ||||
-rw-r--r-- | platform/macos/dir_access_macos.mm (renamed from platform/osx/dir_access_osx.mm) | 12 | ||||
-rw-r--r-- | platform/macos/display_server_macos.h (renamed from platform/osx/display_server_osx.h) | 30 | ||||
-rw-r--r-- | platform/macos/display_server_macos.mm (renamed from platform/osx/display_server_osx.mm) | 460 | ||||
-rw-r--r-- | platform/macos/export/codesign.cpp (renamed from platform/osx/export/codesign.cpp) | 0 | ||||
-rw-r--r-- | platform/macos/export/codesign.h (renamed from platform/osx/export/codesign.h) | 0 | ||||
-rw-r--r-- | platform/macos/export/export.cpp (renamed from platform/osx/export/export.cpp) | 4 | ||||
-rw-r--r-- | platform/macos/export/export.h (renamed from platform/iphone/export/export.h) | 8 | ||||
-rw-r--r-- | platform/macos/export/export_plugin.cpp (renamed from platform/osx/export/export_plugin.cpp) | 93 | ||||
-rw-r--r-- | platform/macos/export/export_plugin.h (renamed from platform/osx/export/export_plugin.h) | 18 | ||||
-rw-r--r-- | platform/macos/export/lipo.cpp (renamed from platform/osx/export/lipo.cpp) | 0 | ||||
-rw-r--r-- | platform/macos/export/lipo.h (renamed from platform/osx/export/lipo.h) | 0 | ||||
-rw-r--r-- | platform/macos/export/macho.cpp (renamed from platform/osx/export/macho.cpp) | 0 | ||||
-rw-r--r-- | platform/macos/export/macho.h (renamed from platform/osx/export/macho.h) | 0 | ||||
-rw-r--r-- | platform/macos/export/plist.cpp (renamed from platform/osx/export/plist.cpp) | 0 | ||||
-rw-r--r-- | platform/macos/export/plist.h (renamed from platform/osx/export/plist.h) | 0 | ||||
-rw-r--r-- | platform/macos/gl_manager_macos_legacy.h (renamed from platform/osx/gl_manager_osx_legacy.h) | 18 | ||||
-rw-r--r-- | platform/macos/gl_manager_macos_legacy.mm (renamed from platform/osx/gl_manager_osx_legacy.mm) | 42 | ||||
-rw-r--r-- | platform/macos/godot_application.h (renamed from platform/osx/godot_application.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_application.mm (renamed from platform/osx/godot_application.mm) | 4 | ||||
-rw-r--r-- | platform/macos/godot_application_delegate.h (renamed from platform/osx/godot_application_delegate.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_application_delegate.mm (renamed from platform/osx/godot_application_delegate.mm) | 18 | ||||
-rw-r--r-- | platform/macos/godot_content_view.h (renamed from platform/osx/godot_content_view.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_content_view.mm (renamed from platform/osx/godot_content_view.mm) | 126 | ||||
-rw-r--r-- | platform/macos/godot_main_macos.mm (renamed from platform/osx/godot_main_osx.mm) | 6 | ||||
-rw-r--r-- | platform/macos/godot_menu_item.h (renamed from platform/osx/godot_menu_item.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_window.h (renamed from platform/osx/godot_window.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_window.mm (renamed from platform/osx/godot_window.mm) | 12 | ||||
-rw-r--r-- | platform/macos/godot_window_delegate.h (renamed from platform/osx/godot_window_delegate.h) | 0 | ||||
-rw-r--r-- | platform/macos/godot_window_delegate.mm (renamed from platform/osx/godot_window_delegate.mm) | 66 | ||||
-rw-r--r-- | platform/macos/joypad_macos.cpp (renamed from platform/osx/joypad_osx.cpp) | 32 | ||||
-rw-r--r-- | platform/macos/joypad_macos.h (renamed from platform/osx/joypad_osx.h) | 14 | ||||
-rw-r--r-- | platform/macos/key_mapping_macos.h (renamed from platform/osx/key_mapping_osx.h) | 12 | ||||
-rw-r--r-- | platform/macos/key_mapping_macos.mm (renamed from platform/osx/key_mapping_osx.mm) | 24 | ||||
-rw-r--r-- | platform/macos/logo.png (renamed from platform/osx/logo.png) | bin | 7195 -> 7195 bytes | |||
-rw-r--r-- | platform/macos/macos_terminal_logger.h (renamed from platform/osx/osx_terminal_logger.h) | 14 | ||||
-rw-r--r-- | platform/macos/macos_terminal_logger.mm (renamed from platform/osx/osx_terminal_logger.mm) | 10 | ||||
-rw-r--r-- | platform/macos/os_macos.h (renamed from platform/osx/os_osx.h) | 18 | ||||
-rw-r--r-- | platform/macos/os_macos.mm (renamed from platform/osx/os_osx.mm) | 100 | ||||
-rw-r--r-- | platform/macos/platform_config.h (renamed from platform/osx/platform_config.h) | 0 | ||||
-rw-r--r-- | platform/macos/platform_macos_builders.py (renamed from platform/osx/platform_osx_builders.py) | 2 | ||||
-rw-r--r-- | platform/macos/tts_macos.h (renamed from platform/osx/tts_osx.h) | 10 | ||||
-rw-r--r-- | platform/macos/tts_macos.mm (renamed from platform/osx/tts_osx.mm) | 6 | ||||
-rw-r--r-- | platform/macos/vulkan_context_macos.h (renamed from platform/osx/vulkan_context_osx.h) | 14 | ||||
-rw-r--r-- | platform/macos/vulkan_context_macos.mm (renamed from platform/osx/vulkan_context_osx.mm) | 12 | ||||
-rw-r--r-- | platform/osx/SCsub | 30 | ||||
-rw-r--r-- | platform/uwp/os_uwp.cpp | 1 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 18 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 2 | ||||
-rw-r--r-- | platform/windows/godot.natvis | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 6 |
103 files changed, 1042 insertions, 1034 deletions
diff --git a/platform/iphone/SCsub b/platform/ios/SCsub index 5e10bf5646..bf12ab6dd7 100644 --- a/platform/iphone/SCsub +++ b/platform/ios/SCsub @@ -2,16 +2,16 @@ Import("env") -iphone_lib = [ - "godot_iphone.mm", - "os_iphone.mm", +ios_lib = [ + "godot_ios.mm", + "os_ios.mm", "main.m", "app_delegate.mm", "view_controller.mm", "ios.mm", - "vulkan_context_iphone.mm", - "display_server_iphone.mm", - "joypad_iphone.mm", + "vulkan_context_ios.mm", + "display_server_ios.mm", + "joypad_ios.mm", "godot_view.mm", "tts_ios.mm", "display_layer.mm", @@ -23,7 +23,7 @@ iphone_lib = [ ] env_ios = env.Clone() -ios_lib = env_ios.add_library("iphone", iphone_lib) +ios_lib = env_ios.add_library("ios", ios_lib) # (iOS) Enable module support env_ios.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) @@ -32,9 +32,9 @@ env_ios.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) def combine_libs(target=None, source=None, env=None): lib_path = target[0].srcnode().abspath if "osxcross" in env: - libtool = "$IPHONEPATH/usr/bin/${ios_triple}libtool" + libtool = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}libtool" else: - libtool = "$IPHONEPATH/usr/bin/libtool" + libtool = "$IOS_TOOLCHAIN_PATH/usr/bin/libtool" env.Execute( libtool + ' -static -o "' + lib_path + '" ' + " ".join([('"' + lib.srcnode().abspath + '"') for lib in source]) ) diff --git a/platform/iphone/api/api.cpp b/platform/ios/api/api.cpp index f2e6fd7a7a..00c76a9256 100644 --- a/platform/iphone/api/api.cpp +++ b/platform/ios/api/api.cpp @@ -30,19 +30,19 @@ #include "api.h" -#if defined(IPHONE_ENABLED) +#if defined(IOS_ENABLED) -void register_iphone_api() { +void register_ios_api() { godot_ios_plugins_initialize(); } -void unregister_iphone_api() { +void unregister_ios_api() { godot_ios_plugins_deinitialize(); } #else -void register_iphone_api() {} -void unregister_iphone_api() {} +void register_ios_api() {} +void unregister_ios_api() {} #endif diff --git a/platform/iphone/api/api.h b/platform/ios/api/api.h index ece91a9f1a..c7fd4ce77b 100644 --- a/platform/iphone/api/api.h +++ b/platform/ios/api/api.h @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IPHONE_API_H -#define IPHONE_API_H +#ifndef IOS_API_H +#define IOS_API_H -#if defined(IPHONE_ENABLED) +#if defined(IOS_ENABLED) extern void godot_ios_plugins_initialize(); extern void godot_ios_plugins_deinitialize(); #endif -void register_iphone_api(); -void unregister_iphone_api(); +void register_ios_api(); +void unregister_ios_api(); -#endif // IPHONE_API_H +#endif // IOS_API_H diff --git a/platform/iphone/app_delegate.h b/platform/ios/app_delegate.h index 0ec1dc071b..0ec1dc071b 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/ios/app_delegate.h diff --git a/platform/iphone/app_delegate.mm b/platform/ios/app_delegate.mm index c5c9b5a5f9..fb183d52d4 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/ios/app_delegate.mm @@ -34,7 +34,7 @@ #include "drivers/coreaudio/audio_driver_coreaudio.h" #import "godot_view.h" #include "main/main.h" -#include "os_iphone.h" +#include "os_ios.h" #import "view_controller.h" #import <AVFoundation/AVFoundation.h> @@ -45,8 +45,8 @@ extern int gargc; extern char **gargv; -extern int iphone_main(int, char **, String, String); -extern void iphone_finish(); +extern int ios_main(int, char **, String, String); +extern void ios_finish(); @implementation AppDelegate @@ -71,7 +71,7 @@ static ViewController *mainViewController = nil; paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cacheDirectory = [paths objectAtIndex:0]; - int err = iphone_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String])); + int err = ios_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String])); if (err != 0) { // bail, things did not go very well for us, should probably output a message on screen with our error code... @@ -106,10 +106,10 @@ static ViewController *mainViewController = nil; if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) { if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) { NSLog(@"Audio interruption began"); - OSIPhone::get_singleton()->on_focus_out(); + OS_IOS::get_singleton()->on_focus_out(); } else if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeEnded]]) { NSLog(@"Audio interruption ended"); - OSIPhone::get_singleton()->on_focus_in(); + OS_IOS::get_singleton()->on_focus_in(); } } } @@ -121,7 +121,7 @@ static ViewController *mainViewController = nil; } - (void)applicationWillTerminate:(UIApplication *)application { - iphone_finish(); + ios_finish(); } // When application goes to background (e.g. user switches to another app or presses Home), @@ -135,11 +135,11 @@ static ViewController *mainViewController = nil; // notification panel by swiping from the upper part of the screen. - (void)applicationWillResignActive:(UIApplication *)application { - OSIPhone::get_singleton()->on_focus_out(); + OS_IOS::get_singleton()->on_focus_out(); } - (void)applicationDidBecomeActive:(UIApplication *)application { - OSIPhone::get_singleton()->on_focus_in(); + OS_IOS::get_singleton()->on_focus_in(); } - (void)dealloc { diff --git a/platform/iphone/detect.py b/platform/ios/detect.py index 862f1fe50b..67c90b10a0 100644 --- a/platform/iphone/detect.py +++ b/platform/ios/detect.py @@ -23,11 +23,11 @@ def get_opts(): return [ ( - "IPHONEPATH", - "Path to iPhone toolchain", + "IOS_TOOLCHAIN_PATH", + "Path to iOS toolchain", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain", ), - ("IPHONESDK", "Path to the iPhone SDK", ""), + ("IOS_SDK_PATH", "Path to the iOS SDK", ""), BoolVariable("ios_simulator", "Build for iOS Simulator", False), BoolVariable("ios_exceptions", "Enable exceptions", False), ("ios_triple", "Triple for ios toolchain", ""), @@ -75,10 +75,10 @@ def configure(env): if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True - env["ENV"]["PATH"] = env["IPHONEPATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"] + env["ENV"]["PATH"] = env["IOS_TOOLCHAIN_PATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"] - compiler_path = "$IPHONEPATH/usr/bin/${ios_triple}" - s_compiler_path = "$IPHONEPATH/Developer/usr/bin/" + compiler_path = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}" + s_compiler_path = "$IOS_TOOLCHAIN_PATH/Developer/usr/bin/" ccache_path = os.environ.get("CCACHE") if ccache_path is None: @@ -97,12 +97,12 @@ def configure(env): ## Compile flags if env["ios_simulator"]: - detect_darwin_sdk_path("iphonesimulator", env) + detect_darwin_sdk_path("iossimulator", env) env.Append(ASFLAGS=["-mios-simulator-version-min=13.0"]) env.Append(CCFLAGS=["-mios-simulator-version-min=13.0"]) env.extra_suffix = ".simulator" + env.extra_suffix else: - detect_darwin_sdk_path("iphone", env) + detect_darwin_sdk_path("ios", env) env.Append(ASFLAGS=["-miphoneos-version-min=11.0"]) env.Append(CCFLAGS=["-miphoneos-version-min=11.0"]) @@ -112,7 +112,7 @@ def configure(env): CCFLAGS=( "-fobjc-arc -arch x86_64" " -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks" - " -fasm-blocks -isysroot $IPHONESDK" + " -fasm-blocks -isysroot $IOS_SDK_PATH" ).split() ) env.Append(ASFLAGS=["-arch", "x86_64"]) @@ -122,7 +122,7 @@ def configure(env): "-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing" " -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits" " -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies" - " -isysroot $IPHONESDK".split() + " -isysroot $IOS_SDK_PATH".split() ) ) env.Append(ASFLAGS=["-arch", "arm64"]) @@ -135,18 +135,18 @@ def configure(env): else: env.Append(CCFLAGS=["-fno-exceptions"]) - # Temp fix for ABS/MAX/MIN macros in iPhone SDK blocking compilation + # Temp fix for ABS/MAX/MIN macros in iOS SDK blocking compilation env.Append(CCFLAGS=["-Wno-ambiguous-macro"]) env.Prepend( CPPPATH=[ - "$IPHONESDK/usr/include", - "$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers", + "$IOS_SDK_PATH/usr/include", + "$IOS_SDK_PATH/System/Library/Frameworks/AudioUnit.framework/Headers", ] ) - env.Prepend(CPPPATH=["#platform/iphone"]) - env.Append(CPPDEFINES=["IPHONE_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) + env.Prepend(CPPPATH=["#platform/ios"]) + env.Append(CPPDEFINES=["IOS_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"]) diff --git a/platform/iphone/device_metrics.h b/platform/ios/device_metrics.h index b9fb9b2fd9..b9fb9b2fd9 100644 --- a/platform/iphone/device_metrics.h +++ b/platform/ios/device_metrics.h diff --git a/platform/iphone/device_metrics.m b/platform/ios/device_metrics.m index ec4dd8130d..ec4dd8130d 100644 --- a/platform/iphone/device_metrics.m +++ b/platform/ios/device_metrics.m diff --git a/platform/iphone/display_layer.h b/platform/ios/display_layer.h index a17c75dba1..a17c75dba1 100644 --- a/platform/iphone/display_layer.h +++ b/platform/ios/display_layer.h diff --git a/platform/iphone/display_layer.mm b/platform/ios/display_layer.mm index 92e81448ac..7c83494768 100644 --- a/platform/iphone/display_layer.mm +++ b/platform/ios/display_layer.mm @@ -32,9 +32,9 @@ #include "core/config/project_settings.h" #include "core/os/keyboard.h" -#include "display_server_iphone.h" +#include "display_server_ios.h" #include "main/main.h" -#include "os_iphone.h" +#include "os_ios.h" #include "servers/audio_server.h" #import <AudioToolbox/AudioServices.h> diff --git a/platform/iphone/display_server_iphone.h b/platform/ios/display_server_ios.h index 7af222e3f8..bfd611adb7 100644 --- a/platform/iphone/display_server_iphone.h +++ b/platform/ios/display_server_ios.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* display_server_iphone.h */ +/* display_server_ios.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef display_server_iphone_h -#define display_server_iphone_h +#ifndef display_server_ios_h +#define display_server_ios_h #include "core/input/input.h" #include "servers/display_server.h" @@ -38,7 +38,7 @@ #include "drivers/vulkan/rendering_device_vulkan.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" -#include "vulkan_context_iphone.h" +#include "vulkan_context_ios.h" #import <QuartzCore/CAMetalLayer.h> #ifdef USE_VOLK @@ -48,13 +48,13 @@ #endif #endif -class DisplayServerIPhone : public DisplayServer { - GDCLASS(DisplayServerIPhone, DisplayServer) +class DisplayServerIOS : public DisplayServer { + GDCLASS(DisplayServerIOS, DisplayServer) _THREAD_SAFE_CLASS_ #if defined(VULKAN_ENABLED) - VulkanContextIPhone *context_vulkan = nullptr; + VulkanContextIOS *context_vulkan = nullptr; RenderingDeviceVulkan *rendering_device_vulkan = nullptr; #endif @@ -73,15 +73,15 @@ class DisplayServerIPhone : public DisplayServer { void perform_event(const Ref<InputEvent> &p_event); - DisplayServerIPhone(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); - ~DisplayServerIPhone(); + DisplayServerIOS(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); + ~DisplayServerIOS(); public: String rendering_driver; - static DisplayServerIPhone *get_singleton(); + static DisplayServerIOS *get_singleton(); - static void register_iphone_driver(); + static void register_ios_driver(); static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static Vector<String> get_rendering_drivers_func(); @@ -214,4 +214,4 @@ public: void resize_window(CGSize size); }; -#endif /* display_server_iphone_h */ +#endif /* DISPLAY_SERVER_IOS_H */ diff --git a/platform/iphone/display_server_iphone.mm b/platform/ios/display_server_ios.mm index 573ee9b7a8..73d4a2a427 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/ios/display_server_ios.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* display_server_iphone.mm */ +/* display_server_ios.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "display_server_iphone.h" +#include "display_server_ios.h" #import "app_delegate.h" #include "core/config/project_settings.h" @@ -37,20 +37,20 @@ #import "godot_view.h" #include "ios.h" #import "keyboard_input_view.h" -#include "os_iphone.h" +#include "os_ios.h" #include "tts_ios.h" #import "view_controller.h" #import <Foundation/Foundation.h> #import <sys/utsname.h> -static const float kDisplayServerIPhoneAcceleration = 1; +static const float kDisplayServerIOSAcceleration = 1.f; -DisplayServerIPhone *DisplayServerIPhone::get_singleton() { - return (DisplayServerIPhone *)DisplayServer::get_singleton(); +DisplayServerIOS *DisplayServerIOS::get_singleton() { + return (DisplayServerIOS *)DisplayServer::get_singleton(); } -DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { +DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { rendering_driver = p_rendering_driver; // Init TTS @@ -101,7 +101,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo rendering_device_vulkan = nullptr; if (rendering_driver == "vulkan") { - context_vulkan = memnew(VulkanContextIPhone); + context_vulkan = memnew(VulkanContextIOS); if (context_vulkan->initialize() != OK) { memdelete(context_vulkan); context_vulkan = nullptr; @@ -136,7 +136,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo r_error = OK; } -DisplayServerIPhone::~DisplayServerIPhone() { +DisplayServerIOS::~DisplayServerIOS() { #if defined(VULKAN_ENABLED) if (rendering_device_vulkan) { rendering_device_vulkan->finalize(); @@ -152,11 +152,11 @@ DisplayServerIPhone::~DisplayServerIPhone() { #endif } -DisplayServer *DisplayServerIPhone::create_func(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { - return memnew(DisplayServerIPhone(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); +DisplayServer *DisplayServerIOS::create_func(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { + return memnew(DisplayServerIOS(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); } -Vector<String> DisplayServerIPhone::get_rendering_drivers_func() { +Vector<String> DisplayServerIOS::get_rendering_drivers_func() { Vector<String> drivers; #if defined(VULKAN_ENABLED) @@ -169,51 +169,52 @@ Vector<String> DisplayServerIPhone::get_rendering_drivers_func() { return drivers; } -void DisplayServerIPhone::register_iphone_driver() { - register_create_function("iphone", create_func, get_rendering_drivers_func); +void DisplayServerIOS::register_ios_driver() { + register_create_function("iOS", create_func, get_rendering_drivers_func); } // MARK: Events -void DisplayServerIPhone::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerIOS::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { window_resize_callback = p_callable; } -void DisplayServerIPhone::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerIOS::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { window_event_callback = p_callable; } -void DisplayServerIPhone::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerIOS::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { input_event_callback = p_callable; } -void DisplayServerIPhone::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerIOS::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { input_text_callback = p_callable; } -void DisplayServerIPhone::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerIOS::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { // Probably not supported for iOS } -void DisplayServerIPhone::process_events() { +void DisplayServerIOS::process_events() { + Input::get_singleton()->flush_buffered_events(); } -void DisplayServerIPhone::_dispatch_input_events(const Ref<InputEvent> &p_event) { - DisplayServerIPhone::get_singleton()->send_input_event(p_event); +void DisplayServerIOS::_dispatch_input_events(const Ref<InputEvent> &p_event) { + DisplayServerIOS::get_singleton()->send_input_event(p_event); } -void DisplayServerIPhone::send_input_event(const Ref<InputEvent> &p_event) const { +void DisplayServerIOS::send_input_event(const Ref<InputEvent> &p_event) const { _window_callback(input_event_callback, p_event); } -void DisplayServerIPhone::send_input_text(const String &p_text) const { +void DisplayServerIOS::send_input_text(const String &p_text) const { _window_callback(input_text_callback, p_text); } -void DisplayServerIPhone::send_window_event(DisplayServer::WindowEvent p_event) const { +void DisplayServerIOS::send_window_event(DisplayServer::WindowEvent p_event) const { _window_callback(window_event_callback, int(p_event)); } -void DisplayServerIPhone::_window_callback(const Callable &p_callable, const Variant &p_arg) const { +void DisplayServerIOS::_window_callback(const Callable &p_callable, const Variant &p_arg) const { if (!p_callable.is_null()) { const Variant *argp = &p_arg; Variant ret; @@ -226,7 +227,7 @@ void DisplayServerIPhone::_window_callback(const Callable &p_callable, const Var // MARK: Touches -void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click) { +void DisplayServerIOS::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click) { if (!GLOBAL_DEF("debug/disable_touch", false)) { Ref<InputEventScreenTouch> ev; ev.instantiate(); @@ -238,7 +239,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse } } -void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) { +void DisplayServerIOS::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) { if (!GLOBAL_DEF("debug/disable_touch", false)) { Ref<InputEventScreenDrag> ev; ev.instantiate(); @@ -249,17 +250,17 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int } } -void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) { +void DisplayServerIOS::perform_event(const Ref<InputEvent> &p_event) { Input::get_singleton()->parse_input_event(p_event); } -void DisplayServerIPhone::touches_cancelled(int p_idx) { +void DisplayServerIOS::touches_cancelled(int p_idx) { touch_press(p_idx, -1, -1, false, false); } // MARK: Keyboard -void DisplayServerIPhone::key(Key p_key, bool p_pressed) { +void DisplayServerIOS::key(Key p_key, bool p_pressed) { Ref<InputEventKey> ev; ev.instantiate(); ev->set_echo(false); @@ -272,31 +273,31 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) { // MARK: Motion -void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) { +void DisplayServerIOS::update_gravity(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z)); } -void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) { +void DisplayServerIOS::update_accelerometer(float p_x, float p_y, float p_z) { // Found out the Z should not be negated! Pass as is! Vector3 v_accelerometer = Vector3( - p_x / kDisplayServerIPhoneAcceleration, - p_y / kDisplayServerIPhoneAcceleration, - p_z / kDisplayServerIPhoneAcceleration); + p_x / kDisplayServerIOSAcceleration, + p_y / kDisplayServerIOSAcceleration, + p_z / kDisplayServerIOSAcceleration); Input::get_singleton()->set_accelerometer(v_accelerometer); } -void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) { +void DisplayServerIOS::update_magnetometer(float p_x, float p_y, float p_z) { Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z)); } -void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) { +void DisplayServerIOS::update_gyroscope(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z)); } // MARK: - -bool DisplayServerIPhone::has_feature(Feature p_feature) const { +bool DisplayServerIOS::has_feature(Feature p_feature) const { switch (p_feature) { // case FEATURE_CURSOR_SHAPE: // case FEATURE_CUSTOM_CURSOR_SHAPE: @@ -321,46 +322,46 @@ bool DisplayServerIPhone::has_feature(Feature p_feature) const { } } -String DisplayServerIPhone::get_name() const { - return "iPhone"; +String DisplayServerIOS::get_name() const { + return "iOS"; } -bool DisplayServerIPhone::tts_is_speaking() const { +bool DisplayServerIOS::tts_is_speaking() const { ERR_FAIL_COND_V(!tts, false); return [tts isSpeaking]; } -bool DisplayServerIPhone::tts_is_paused() const { +bool DisplayServerIOS::tts_is_paused() const { ERR_FAIL_COND_V(!tts, false); return [tts isPaused]; } -Array DisplayServerIPhone::tts_get_voices() const { +Array DisplayServerIOS::tts_get_voices() const { ERR_FAIL_COND_V(!tts, Array()); return [tts getVoices]; } -void DisplayServerIPhone::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { +void DisplayServerIOS::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { ERR_FAIL_COND(!tts); [tts speak:p_text voice:p_voice volume:p_volume pitch:p_pitch rate:p_rate utterance_id:p_utterance_id interrupt:p_interrupt]; } -void DisplayServerIPhone::tts_pause() { +void DisplayServerIOS::tts_pause() { ERR_FAIL_COND(!tts); [tts pauseSpeaking]; } -void DisplayServerIPhone::tts_resume() { +void DisplayServerIOS::tts_resume() { ERR_FAIL_COND(!tts); [tts resumeSpeaking]; } -void DisplayServerIPhone::tts_stop() { +void DisplayServerIOS::tts_stop() { ERR_FAIL_COND(!tts); [tts stopSpeaking]; } -Rect2i DisplayServerIPhone::get_display_safe_area() const { +Rect2i DisplayServerIOS::get_display_safe_area() const { if (@available(iOS 11, *)) { UIEdgeInsets insets = UIEdgeInsetsZero; UIView *view = AppDelegate.viewController.godotView; @@ -376,15 +377,15 @@ Rect2i DisplayServerIPhone::get_display_safe_area() const { } } -int DisplayServerIPhone::get_screen_count() const { +int DisplayServerIOS::get_screen_count() const { return 1; } -Point2i DisplayServerIPhone::screen_get_position(int p_screen) const { +Point2i DisplayServerIOS::screen_get_position(int p_screen) const { return Size2i(); } -Size2i DisplayServerIPhone::screen_get_size(int p_screen) const { +Size2i DisplayServerIOS::screen_get_size(int p_screen) const { CALayer *layer = AppDelegate.viewController.godotView.renderingLayer; if (!layer) { @@ -394,11 +395,11 @@ Size2i DisplayServerIPhone::screen_get_size(int p_screen) const { return Size2i(layer.bounds.size.width, layer.bounds.size.height) * screen_get_scale(p_screen); } -Rect2i DisplayServerIPhone::screen_get_usable_rect(int p_screen) const { +Rect2i DisplayServerIOS::screen_get_usable_rect(int p_screen) const { return Rect2i(screen_get_position(p_screen), screen_get_size(p_screen)); } -int DisplayServerIPhone::screen_get_dpi(int p_screen) const { +int DisplayServerIOS::screen_get_dpi(int p_screen) const { struct utsname systemInfo; uname(&systemInfo); @@ -435,25 +436,25 @@ int DisplayServerIPhone::screen_get_dpi(int p_screen) const { } } -float DisplayServerIPhone::screen_get_refresh_rate(int p_screen) const { +float DisplayServerIOS::screen_get_refresh_rate(int p_screen) const { return [UIScreen mainScreen].maximumFramesPerSecond; } -float DisplayServerIPhone::screen_get_scale(int p_screen) const { +float DisplayServerIOS::screen_get_scale(int p_screen) const { return [UIScreen mainScreen].nativeScale; } -Vector<DisplayServer::WindowID> DisplayServerIPhone::get_window_list() const { +Vector<DisplayServer::WindowID> DisplayServerIOS::get_window_list() const { Vector<DisplayServer::WindowID> list; list.push_back(MAIN_WINDOW_ID); return list; } -DisplayServer::WindowID DisplayServerIPhone::get_window_at_screen_position(const Point2i &p_position) const { +DisplayServer::WindowID DisplayServerIOS::get_window_at_screen_position(const Point2i &p_position) const { return MAIN_WINDOW_ID; } -int64_t DisplayServerIPhone::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const { +int64_t DisplayServerIOS::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const { ERR_FAIL_COND_V(p_window != MAIN_WINDOW_ID, 0); switch (p_handle_type) { case DISPLAY_HANDLE: { @@ -471,120 +472,120 @@ int64_t DisplayServerIPhone::window_get_native_handle(HandleType p_handle_type, } } -void DisplayServerIPhone::window_attach_instance_id(ObjectID p_instance, WindowID p_window) { +void DisplayServerIOS::window_attach_instance_id(ObjectID p_instance, WindowID p_window) { window_attached_instance_id = p_instance; } -ObjectID DisplayServerIPhone::window_get_attached_instance_id(WindowID p_window) const { +ObjectID DisplayServerIOS::window_get_attached_instance_id(WindowID p_window) const { return window_attached_instance_id; } -void DisplayServerIPhone::window_set_title(const String &p_title, WindowID p_window) { +void DisplayServerIOS::window_set_title(const String &p_title, WindowID p_window) { // Probably not supported for iOS } -int DisplayServerIPhone::window_get_current_screen(WindowID p_window) const { +int DisplayServerIOS::window_get_current_screen(WindowID p_window) const { return SCREEN_OF_MAIN_WINDOW; } -void DisplayServerIPhone::window_set_current_screen(int p_screen, WindowID p_window) { +void DisplayServerIOS::window_set_current_screen(int p_screen, WindowID p_window) { // Probably not supported for iOS } -Point2i DisplayServerIPhone::window_get_position(WindowID p_window) const { +Point2i DisplayServerIOS::window_get_position(WindowID p_window) const { return Point2i(); } -void DisplayServerIPhone::window_set_position(const Point2i &p_position, WindowID p_window) { +void DisplayServerIOS::window_set_position(const Point2i &p_position, WindowID p_window) { // Probably not supported for single window iOS app } -void DisplayServerIPhone::window_set_transient(WindowID p_window, WindowID p_parent) { +void DisplayServerIOS::window_set_transient(WindowID p_window, WindowID p_parent) { // Probably not supported for iOS } -void DisplayServerIPhone::window_set_max_size(const Size2i p_size, WindowID p_window) { +void DisplayServerIOS::window_set_max_size(const Size2i p_size, WindowID p_window) { // Probably not supported for iOS } -Size2i DisplayServerIPhone::window_get_max_size(WindowID p_window) const { +Size2i DisplayServerIOS::window_get_max_size(WindowID p_window) const { return Size2i(); } -void DisplayServerIPhone::window_set_min_size(const Size2i p_size, WindowID p_window) { +void DisplayServerIOS::window_set_min_size(const Size2i p_size, WindowID p_window) { // Probably not supported for iOS } -Size2i DisplayServerIPhone::window_get_min_size(WindowID p_window) const { +Size2i DisplayServerIOS::window_get_min_size(WindowID p_window) const { return Size2i(); } -void DisplayServerIPhone::window_set_size(const Size2i p_size, WindowID p_window) { +void DisplayServerIOS::window_set_size(const Size2i p_size, WindowID p_window) { // Probably not supported for iOS } -Size2i DisplayServerIPhone::window_get_size(WindowID p_window) const { +Size2i DisplayServerIOS::window_get_size(WindowID p_window) const { CGRect screenBounds = [UIScreen mainScreen].bounds; return Size2i(screenBounds.size.width, screenBounds.size.height) * screen_get_max_scale(); } -Size2i DisplayServerIPhone::window_get_real_size(WindowID p_window) const { +Size2i DisplayServerIOS::window_get_real_size(WindowID p_window) const { return window_get_size(p_window); } -void DisplayServerIPhone::window_set_mode(WindowMode p_mode, WindowID p_window) { +void DisplayServerIOS::window_set_mode(WindowMode p_mode, WindowID p_window) { // Probably not supported for iOS } -DisplayServer::WindowMode DisplayServerIPhone::window_get_mode(WindowID p_window) const { +DisplayServer::WindowMode DisplayServerIOS::window_get_mode(WindowID p_window) const { return WindowMode::WINDOW_MODE_FULLSCREEN; } -bool DisplayServerIPhone::window_is_maximize_allowed(WindowID p_window) const { +bool DisplayServerIOS::window_is_maximize_allowed(WindowID p_window) const { return false; } -void DisplayServerIPhone::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) { +void DisplayServerIOS::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) { // Probably not supported for iOS } -bool DisplayServerIPhone::window_get_flag(WindowFlags p_flag, WindowID p_window) const { +bool DisplayServerIOS::window_get_flag(WindowFlags p_flag, WindowID p_window) const { return false; } -void DisplayServerIPhone::window_request_attention(WindowID p_window) { +void DisplayServerIOS::window_request_attention(WindowID p_window) { // Probably not supported for iOS } -void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) { +void DisplayServerIOS::window_move_to_foreground(WindowID p_window) { // Probably not supported for iOS } -float DisplayServerIPhone::screen_get_max_scale() const { +float DisplayServerIOS::screen_get_max_scale() const { return screen_get_scale(SCREEN_OF_MAIN_WINDOW); } -void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) { +void DisplayServerIOS::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) { screen_orientation = p_orientation; } -DisplayServer::ScreenOrientation DisplayServerIPhone::screen_get_orientation(int p_screen) const { +DisplayServer::ScreenOrientation DisplayServerIOS::screen_get_orientation(int p_screen) const { return screen_orientation; } -bool DisplayServerIPhone::window_can_draw(WindowID p_window) const { +bool DisplayServerIOS::window_can_draw(WindowID p_window) const { return true; } -bool DisplayServerIPhone::can_any_window_draw() const { +bool DisplayServerIOS::can_any_window_draw() const { return true; } -bool DisplayServerIPhone::screen_is_touchscreen(int p_screen) const { +bool DisplayServerIOS::screen_is_touchscreen(int p_screen) const { return true; } -void DisplayServerIPhone::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_length, int p_cursor_start, int p_cursor_end) { +void DisplayServerIOS::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_length, int p_cursor_start, int p_cursor_end) { NSString *existingString = [[NSString alloc] initWithUTF8String:p_existing_text.utf8().get_data()]; [AppDelegate.viewController.keyboardView @@ -594,37 +595,37 @@ void DisplayServerIPhone::virtual_keyboard_show(const String &p_existing_text, c cursorEnd:p_cursor_end]; } -void DisplayServerIPhone::virtual_keyboard_hide() { +void DisplayServerIOS::virtual_keyboard_hide() { [AppDelegate.viewController.keyboardView resignFirstResponder]; } -void DisplayServerIPhone::virtual_keyboard_set_height(int height) { +void DisplayServerIOS::virtual_keyboard_set_height(int height) { virtual_keyboard_height = height * screen_get_max_scale(); } -int DisplayServerIPhone::virtual_keyboard_get_height() const { +int DisplayServerIOS::virtual_keyboard_get_height() const { return virtual_keyboard_height; } -void DisplayServerIPhone::clipboard_set(const String &p_text) { +void DisplayServerIOS::clipboard_set(const String &p_text) { [UIPasteboard generalPasteboard].string = [NSString stringWithUTF8String:p_text.utf8()]; } -String DisplayServerIPhone::clipboard_get() const { +String DisplayServerIOS::clipboard_get() const { NSString *text = [UIPasteboard generalPasteboard].string; return String::utf8([text UTF8String]); } -void DisplayServerIPhone::screen_set_keep_on(bool p_enable) { +void DisplayServerIOS::screen_set_keep_on(bool p_enable) { [UIApplication sharedApplication].idleTimerDisabled = p_enable; } -bool DisplayServerIPhone::screen_is_kept_on() const { +bool DisplayServerIOS::screen_is_kept_on() const { return [UIApplication sharedApplication].idleTimerDisabled; } -void DisplayServerIPhone::resize_window(CGSize viewSize) { +void DisplayServerIOS::resize_window(CGSize viewSize) { Size2i size = Size2i(viewSize.width, viewSize.height) * screen_get_max_scale(); #if defined(VULKAN_ENABLED) @@ -637,14 +638,14 @@ void DisplayServerIPhone::resize_window(CGSize viewSize) { _window_callback(window_resize_callback, resize_rect); } -void DisplayServerIPhone::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { +void DisplayServerIOS::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { _THREAD_SAFE_METHOD_ #if defined(VULKAN_ENABLED) context_vulkan->set_vsync_mode(p_window, p_vsync_mode); #endif } -DisplayServer::VSyncMode DisplayServerIPhone::window_get_vsync_mode(WindowID p_window) const { +DisplayServer::VSyncMode DisplayServerIOS::window_get_vsync_mode(WindowID p_window) const { _THREAD_SAFE_METHOD_ #if defined(VULKAN_ENABLED) return context_vulkan->get_vsync_mode(p_window); diff --git a/platform/iphone/export/export.cpp b/platform/ios/export/export.cpp index 3b02e661c1..1531c2bde5 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/ios/export/export.cpp @@ -32,7 +32,7 @@ #include "export_plugin.h" -void register_iphone_exporter() { +void register_ios_exporter() { Ref<EditorExportPlatformIOS> platform; platform.instantiate(); diff --git a/platform/osx/export/export.h b/platform/ios/export/export.h index b386337a09..756a1356ea 100644 --- a/platform/osx/export/export.h +++ b/platform/ios/export/export.h @@ -28,9 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OSX_EXPORT_H -#define OSX_EXPORT_H +#ifndef IOS_EXPORT_H +#define IOS_EXPORT_H -void register_osx_exporter(); +void register_ios_exporter(); -#endif // OSX_EXPORT_H +#endif // IOS_EXPORT_H diff --git a/platform/iphone/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 3b92bd19be..a2e80d33fd 100644 --- a/platform/iphone/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -418,7 +418,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ } // !BAS! I'm assuming the 9 in the original code was a typo. I've added -1 or else it seems to also be adding our terminating zero... - // should apply the same fix in our OSX export. + // should apply the same fix in our macOS export. CharString cs = strnew.utf8(); pfile.resize(cs.size() - 1); for (int i = 0; i < cs.size() - 1; i++) { @@ -1394,7 +1394,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p if (src_pkg_name.is_empty()) { String err; - src_pkg_name = find_export_template("iphone.zip", &err); + src_pkg_name = find_export_template("ios.zip", &err); if (src_pkg_name.is_empty()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("Export template not found.")); return ERR_FILE_NOT_FOUND; @@ -1444,7 +1444,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p return ERR_SKIP; } - String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".xcframework"; + String library_to_use = "libgodot.ios." + String(p_debug ? "debug" : "release") + ".xcframework"; print_line("Static framework: " + library_to_use); String pkg_name; @@ -1502,7 +1502,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p int ret = unzGoToFirstFile(src_pkg_zip); Vector<uint8_t> project_file_data; while (ret == UNZ_OK) { -#if defined(OSX_ENABLED) || defined(X11_ENABLED) +#if defined(MACOS_ENABLED) || defined(X11_ENABLED) bool is_execute = false; #endif @@ -1527,17 +1527,17 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p //write - file = file.replace_first("iphone/", ""); + file = file.replace_first("ios/", ""); if (files_to_parse.has(file)) { _fix_config_file(p_preset, data, config_data, p_debug); - } else if (file.begins_with("libgodot.iphone")) { + } else if (file.begins_with("libgodot.ios")) { if (!file.begins_with(library_to_use) || file.ends_with(String("/empty"))) { ret = unzGoToNextFile(src_pkg_zip); continue; //ignore! } found_library = true; -#if defined(OSX_ENABLED) || defined(X11_ENABLED) +#if defined(MACOS_ENABLED) || defined(X11_ENABLED) is_execute = true; #endif file = file.replace(library_to_use, binary_name + ".xcframework"); @@ -1580,7 +1580,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p f->store_buffer(data.ptr(), data.size()); } -#if defined(OSX_ENABLED) || defined(X11_ENABLED) +#if defined(MACOS_ENABLED) || defined(X11_ENABLED) if (is_execute) { // we need execute rights on this file chmod(file.utf8().get_data(), 0755); @@ -1725,7 +1725,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p f->store_buffer(project_file_data.ptr(), project_file_data.size()); } -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED { if (ep.step("Code-signing dylibs", 2)) { return ERR_SKIP; @@ -1790,7 +1790,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset // Look for export templates (first official, and if defined custom templates). - bool dvalid = exists_export_template("iphone.zip", &err); + bool dvalid = exists_export_template("ios.zip", &err); bool rvalid = dvalid; // Both in the same ZIP. if (p_preset->get("custom_template/debug") != "") { @@ -1838,7 +1838,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset } EditorExportPlatformIOS::EditorExportPlatformIOS() { - logo = ImageTexture::create_from_image(memnew(Image(_iphone_logo))); + logo = ImageTexture::create_from_image(memnew(Image(_ios_logo))); plugins_changed.set(); check_for_changes_thread.start(_check_for_changes_poll_thread, this); } diff --git a/platform/iphone/export/export_plugin.h b/platform/ios/export/export_plugin.h index 1db7418e3f..a30cb4644f 100644 --- a/platform/iphone/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IPHONE_EXPORT_PLUGIN_H -#define IPHONE_EXPORT_PLUGIN_H +#ifndef IOS_EXPORT_PLUGIN_H +#define IOS_EXPORT_PLUGIN_H #include "core/config/project_settings.h" #include "core/io/file_access.h" @@ -43,7 +43,7 @@ #include "editor/editor_export.h" #include "editor/editor_settings.h" #include "main/splash.gen.h" -#include "platform/iphone/logo.gen.h" +#include "platform/ios/logo.gen.h" #include "string.h" #include "godot_plugin_config.h" diff --git a/platform/iphone/export/godot_plugin_config.cpp b/platform/ios/export/godot_plugin_config.cpp index 9118b95337..9118b95337 100644 --- a/platform/iphone/export/godot_plugin_config.cpp +++ b/platform/ios/export/godot_plugin_config.cpp diff --git a/platform/iphone/export/godot_plugin_config.h b/platform/ios/export/godot_plugin_config.h index 9ef8aa8c6d..d2a2de4947 100644 --- a/platform/iphone/export/godot_plugin_config.h +++ b/platform/ios/export/godot_plugin_config.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IPHONE_GODOT_PLUGIN_CONFIG_H -#define IPHONE_GODOT_PLUGIN_CONFIG_H +#ifndef IOS_GODOT_PLUGIN_CONFIG_H +#define IOS_GODOT_PLUGIN_CONFIG_H #include "core/error/error_list.h" #include "core/io/config_file.h" diff --git a/platform/iphone/godot_app_delegate.h b/platform/ios/godot_app_delegate.h index 703a906bda..703a906bda 100644 --- a/platform/iphone/godot_app_delegate.h +++ b/platform/ios/godot_app_delegate.h diff --git a/platform/iphone/godot_app_delegate.m b/platform/ios/godot_app_delegate.m index 84347f9a30..84347f9a30 100644 --- a/platform/iphone/godot_app_delegate.m +++ b/platform/ios/godot_app_delegate.m diff --git a/platform/iphone/godot_iphone.mm b/platform/ios/godot_ios.mm index 59fdfa9dcd..5f3e786b8a 100644 --- a/platform/iphone/godot_iphone.mm +++ b/platform/ios/godot_ios.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_iphone.mm */ +/* godot_ios.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,17 +30,17 @@ #include "core/string/ustring.h" #include "main/main.h" -#include "os_iphone.h" +#include "os_ios.h" #include <stdio.h> #include <string.h> #include <unistd.h> -static OSIPhone *os = nullptr; +static OS_IOS *os = nullptr; int add_path(int, char **); int add_cmdline(int, char **); -int iphone_main(int, char **, String); +int ios_main(int, char **, String); int add_path(int p_argc, char **p_args) { NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"]; @@ -74,7 +74,7 @@ int add_cmdline(int p_argc, char **p_args) { return p_argc; } -int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { +int ios_main(int argc, char **argv, String data_dir, String cache_dir) { size_t len = strlen(argv[0]); while (len--) { @@ -91,11 +91,11 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { chdir(path); } - printf("godot_iphone %s\n", argv[0]); + printf("godot_ios %s\n", argv[0]); char cwd[512]; getcwd(cwd, sizeof(cwd)); printf("cwd %s\n", cwd); - os = new OSIPhone(data_dir, cache_dir); + os = new OS_IOS(data_dir, cache_dir); // We must override main when testing is enabled TEST_MAIN_OVERRIDE @@ -124,8 +124,8 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { return 0; } -void iphone_finish() { - printf("iphone_finish\n"); +void ios_finish() { + printf("ios_finish\n"); Main::cleanup(); delete os; } diff --git a/platform/iphone/godot_view.h b/platform/ios/godot_view.h index fcb97fa63a..fcb97fa63a 100644 --- a/platform/iphone/godot_view.h +++ b/platform/ios/godot_view.h diff --git a/platform/iphone/godot_view.mm b/platform/ios/godot_view.mm index e48dd2e507..9ed219508c 100644 --- a/platform/iphone/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -33,7 +33,7 @@ #include "core/os/keyboard.h" #include "core/string/ustring.h" #import "display_layer.h" -#include "display_server_iphone.h" +#include "display_server_ios.h" #import "godot_view_gesture_recognizer.h" #import "godot_view_renderer.h" @@ -281,8 +281,8 @@ static const float earth_gravity = 9.80665; self.renderingLayer.frame = self.bounds; [self.renderingLayer layoutDisplayLayer]; - if (DisplayServerIPhone::get_singleton()) { - DisplayServerIPhone::get_singleton()->resize_window(self.bounds.size); + if (DisplayServerIOS::get_singleton()) { + DisplayServerIOS::get_singleton()->resize_window(self.bounds.size); } } @@ -348,7 +348,7 @@ static const float earth_gravity = 9.80665; int tid = [self getTouchIDForTouch:touch]; ERR_FAIL_COND(tid == -1); CGPoint touchPoint = [touch locationInView:self]; - DisplayServerIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1); + DisplayServerIOS::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1); } } } @@ -362,7 +362,7 @@ static const float earth_gravity = 9.80665; ERR_FAIL_COND(tid == -1); CGPoint touchPoint = [touch locationInView:self]; CGPoint prev_point = [touch previousLocationInView:self]; - DisplayServerIPhone::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor); + DisplayServerIOS::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor); } } } @@ -376,7 +376,7 @@ static const float earth_gravity = 9.80665; ERR_FAIL_COND(tid == -1); [self removeTouch:touch]; CGPoint touchPoint = [touch locationInView:self]; - DisplayServerIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false); + DisplayServerIOS::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false); } } } @@ -388,7 +388,7 @@ static const float earth_gravity = 9.80665; UITouch *touch = [tlist objectAtIndex:i]; int tid = [self getTouchIDForTouch:touch]; ERR_FAIL_COND(tid == -1); - DisplayServerIPhone::get_singleton()->touches_cancelled(tid); + DisplayServerIOS::get_singleton()->touches_cancelled(tid); } } [self clearTouches]; @@ -452,28 +452,28 @@ static const float earth_gravity = 9.80665; switch (interfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: { - DisplayServerIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x, gravity.z); - DisplayServerIPhone::get_singleton()->update_accelerometer(-(acceleration.y + gravity.y), (acceleration.x + gravity.x), acceleration.z + gravity.z); - DisplayServerIPhone::get_singleton()->update_magnetometer(-magnetic.y, magnetic.x, magnetic.z); - DisplayServerIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x, rotation.z); + DisplayServerIOS::get_singleton()->update_gravity(-gravity.y, gravity.x, gravity.z); + DisplayServerIOS::get_singleton()->update_accelerometer(-(acceleration.y + gravity.y), (acceleration.x + gravity.x), acceleration.z + gravity.z); + DisplayServerIOS::get_singleton()->update_magnetometer(-magnetic.y, magnetic.x, magnetic.z); + DisplayServerIOS::get_singleton()->update_gyroscope(-rotation.y, rotation.x, rotation.z); } break; case UIInterfaceOrientationLandscapeRight: { - DisplayServerIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x, gravity.z); - DisplayServerIPhone::get_singleton()->update_accelerometer((acceleration.y + gravity.y), -(acceleration.x + gravity.x), acceleration.z + gravity.z); - DisplayServerIPhone::get_singleton()->update_magnetometer(magnetic.y, -magnetic.x, magnetic.z); - DisplayServerIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x, rotation.z); + DisplayServerIOS::get_singleton()->update_gravity(gravity.y, -gravity.x, gravity.z); + DisplayServerIOS::get_singleton()->update_accelerometer((acceleration.y + gravity.y), -(acceleration.x + gravity.x), acceleration.z + gravity.z); + DisplayServerIOS::get_singleton()->update_magnetometer(magnetic.y, -magnetic.x, magnetic.z); + DisplayServerIOS::get_singleton()->update_gyroscope(rotation.y, -rotation.x, rotation.z); } break; case UIInterfaceOrientationPortraitUpsideDown: { - DisplayServerIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y, gravity.z); - DisplayServerIPhone::get_singleton()->update_accelerometer(-(acceleration.x + gravity.x), (acceleration.y + gravity.y), acceleration.z + gravity.z); - DisplayServerIPhone::get_singleton()->update_magnetometer(-magnetic.x, magnetic.y, magnetic.z); - DisplayServerIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y, rotation.z); + DisplayServerIOS::get_singleton()->update_gravity(-gravity.x, gravity.y, gravity.z); + DisplayServerIOS::get_singleton()->update_accelerometer(-(acceleration.x + gravity.x), (acceleration.y + gravity.y), acceleration.z + gravity.z); + DisplayServerIOS::get_singleton()->update_magnetometer(-magnetic.x, magnetic.y, magnetic.z); + DisplayServerIOS::get_singleton()->update_gyroscope(-rotation.x, rotation.y, rotation.z); } break; default: { // assume portrait - DisplayServerIPhone::get_singleton()->update_gravity(gravity.x, gravity.y, gravity.z); - DisplayServerIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z); - DisplayServerIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z); - DisplayServerIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y, rotation.z); + DisplayServerIOS::get_singleton()->update_gravity(gravity.x, gravity.y, gravity.z); + DisplayServerIOS::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z); + DisplayServerIOS::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z); + DisplayServerIOS::get_singleton()->update_gyroscope(rotation.x, rotation.y, rotation.z); } break; } } diff --git a/platform/iphone/godot_view_gesture_recognizer.h b/platform/ios/godot_view_gesture_recognizer.h index 9fd8a6b222..9fd8a6b222 100644 --- a/platform/iphone/godot_view_gesture_recognizer.h +++ b/platform/ios/godot_view_gesture_recognizer.h diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/ios/godot_view_gesture_recognizer.mm index 49a92add5e..49a92add5e 100644 --- a/platform/iphone/godot_view_gesture_recognizer.mm +++ b/platform/ios/godot_view_gesture_recognizer.mm diff --git a/platform/iphone/godot_view_renderer.h b/platform/ios/godot_view_renderer.h index b3ee23ae4f..b3ee23ae4f 100644 --- a/platform/iphone/godot_view_renderer.h +++ b/platform/ios/godot_view_renderer.h diff --git a/platform/iphone/godot_view_renderer.mm b/platform/ios/godot_view_renderer.mm index 32477ae41c..140410fbef 100644 --- a/platform/iphone/godot_view_renderer.mm +++ b/platform/ios/godot_view_renderer.mm @@ -32,9 +32,9 @@ #include "core/config/project_settings.h" #include "core/os/keyboard.h" -#import "display_server_iphone.h" +#import "display_server_ios.h" #include "main/main.h" -#include "os_iphone.h" +#include "os_ios.h" #include "servers/audio_server.h" #import <AudioToolbox/AudioServices.h> @@ -69,7 +69,7 @@ if (!self.hasStartedMain) { self.hasStartedMain = YES; - OSIPhone::get_singleton()->start(); + OS_IOS::get_singleton()->start(); return YES; } @@ -108,11 +108,11 @@ } - (void)renderOnView:(UIView *)view { - if (!OSIPhone::get_singleton()) { + if (!OS_IOS::get_singleton()) { return; } - OSIPhone::get_singleton()->iterate(); + OS_IOS::get_singleton()->iterate(); } @end diff --git a/platform/iphone/ios.h b/platform/ios/ios.h index 0607d7b395..0607d7b395 100644 --- a/platform/iphone/ios.h +++ b/platform/ios/ios.h diff --git a/platform/iphone/ios.mm b/platform/ios/ios.mm index 79baae028a..79baae028a 100644 --- a/platform/iphone/ios.mm +++ b/platform/ios/ios.mm diff --git a/platform/iphone/joypad_iphone.h b/platform/ios/joypad_ios.h index 37e272a2c9..66c4b090bc 100644 --- a/platform/iphone/joypad_iphone.h +++ b/platform/ios/joypad_ios.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad_iphone.h */ +/* joypad_ios.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,7 +30,7 @@ #import <GameController/GameController.h> -@interface JoypadIPhoneObserver : NSObject +@interface JoypadIOSObserver : NSObject - (void)startObserving; - (void)startProcessing; @@ -38,13 +38,13 @@ @end -class JoypadIPhone { +class JoypadIOS { private: - JoypadIPhoneObserver *observer; + JoypadIOSObserver *observer; public: - JoypadIPhone(); - ~JoypadIPhone(); + JoypadIOS(); + ~JoypadIOS(); void start_processing(); }; diff --git a/platform/iphone/joypad_iphone.mm b/platform/ios/joypad_ios.mm index 9c2feeaaca..e147cb2527 100644 --- a/platform/iphone/joypad_iphone.mm +++ b/platform/ios/joypad_ios.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad_iphone.mm */ +/* joypad_ios.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#import "joypad_iphone.h" +#import "joypad_ios.h" #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" @@ -36,27 +36,27 @@ #import "godot_view.h" -#include "os_iphone.h" +#include "os_ios.h" -JoypadIPhone::JoypadIPhone() { - observer = [[JoypadIPhoneObserver alloc] init]; +JoypadIOS::JoypadIOS() { + observer = [[JoypadIOSObserver alloc] init]; [observer startObserving]; } -JoypadIPhone::~JoypadIPhone() { +JoypadIOS::~JoypadIOS() { if (observer) { [observer finishObserving]; observer = nil; } } -void JoypadIPhone::start_processing() { +void JoypadIOS::start_processing() { if (observer) { [observer startProcessing]; } } -@interface JoypadIPhoneObserver () +@interface JoypadIOSObserver () @property(assign, nonatomic) BOOL isObserving; @property(assign, nonatomic) BOOL isProcessing; @@ -65,7 +65,7 @@ void JoypadIPhone::start_processing() { @end -@implementation JoypadIPhoneObserver +@implementation JoypadIOSObserver - (instancetype)init { self = [super init]; diff --git a/platform/iphone/keyboard_input_view.h b/platform/ios/keyboard_input_view.h index 33fa5d571a..33fa5d571a 100644 --- a/platform/iphone/keyboard_input_view.h +++ b/platform/ios/keyboard_input_view.h diff --git a/platform/iphone/keyboard_input_view.mm b/platform/ios/keyboard_input_view.mm index f2a7b22483..76e3f23c9d 100644 --- a/platform/iphone/keyboard_input_view.mm +++ b/platform/ios/keyboard_input_view.mm @@ -31,8 +31,8 @@ #import "keyboard_input_view.h" #include "core/os/keyboard.h" -#include "display_server_iphone.h" -#include "os_iphone.h" +#include "display_server_ios.h" +#include "os_ios.h" @interface GodotKeyboardInputView () <UITextViewDelegate> @@ -115,8 +115,8 @@ - (void)deleteText:(NSInteger)charactersToDelete { for (int i = 0; i < charactersToDelete; i++) { - DisplayServerIPhone::get_singleton()->key(Key::BACKSPACE, true); - DisplayServerIPhone::get_singleton()->key(Key::BACKSPACE, false); + DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, true); + DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, false); } } @@ -138,8 +138,8 @@ break; } - DisplayServerIPhone::get_singleton()->key((Key)character, true); - DisplayServerIPhone::get_singleton()->key((Key)character, false); + DisplayServerIOS::get_singleton()->key((Key)character, true); + DisplayServerIOS::get_singleton()->key((Key)character, false); } } diff --git a/platform/iphone/logo.png b/platform/ios/logo.png Binary files differindex 966d8aa70a..966d8aa70a 100644 --- a/platform/iphone/logo.png +++ b/platform/ios/logo.png diff --git a/platform/iphone/main.m b/platform/ios/main.m index acfa7ab731..acfa7ab731 100644 --- a/platform/iphone/main.m +++ b/platform/ios/main.m diff --git a/platform/iphone/os_iphone.h b/platform/ios/os_ios.h index d03403bbb4..bbc77d48de 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/ios/os_ios.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_iphone.h */ +/* os_ios.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,24 +28,24 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef IPHONE_ENABLED +#ifdef IOS_ENABLED -#ifndef OS_IPHONE_H -#define OS_IPHONE_H +#ifndef OS_IOS_H +#define OS_IOS_H #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/unix/os_unix.h" #include "ios.h" -#include "joypad_iphone.h" +#include "joypad_ios.h" #include "servers/audio_server.h" #include "servers/rendering/renderer_compositor.h" #if defined(VULKAN_ENABLED) #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/iphone/vulkan_context_iphone.h" +#include "platform/ios/vulkan_context_ios.h" #endif -class OSIPhone : public OS_Unix { +class OS_IOS : public OS_Unix { private: static HashMap<String, void *> dynamic_symbol_lookup_table; friend void register_dynamic_symbol(char *name, void *address); @@ -54,7 +54,7 @@ private: iOS *ios = nullptr; - JoypadIPhone *joypad_iphone = nullptr; + JoypadIOS *joypad_ios = nullptr; MainLoop *main_loop = nullptr; @@ -79,10 +79,10 @@ private: void deinitialize_modules(); public: - static OSIPhone *get_singleton(); + static OS_IOS *get_singleton(); - OSIPhone(String p_data_dir, String p_cache_dir); - ~OSIPhone(); + OS_IOS(String p_data_dir, String p_cache_dir); + ~OS_IOS(); void initialize_modules(); @@ -119,6 +119,6 @@ public: void on_focus_in(); }; -#endif // OS_IPHONE_H +#endif // OS_IOS_H -#endif // IPHONE_ENABLED +#endif // IOS_ENABLED diff --git a/platform/iphone/os_iphone.mm b/platform/ios/os_ios.mm index 95b06b728e..880315209e 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/ios/os_ios.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_iphone.mm */ +/* os_ios.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef IPHONE_ENABLED +#ifdef IOS_ENABLED -#include "os_iphone.h" +#include "os_ios.h" #import "app_delegate.h" #include "core/config/project_settings.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/file_access_pack.h" -#include "display_server_iphone.h" +#include "display_server_ios.h" #include "drivers/unix/syslog_logger.h" #import "godot_view.h" #include "main/main.h" @@ -65,7 +65,7 @@ typedef void (*init_callback)(); static init_callback *ios_init_callbacks = nullptr; static int ios_init_callbacks_count = 0; static int ios_init_callbacks_capacity = 0; -HashMap<String, void *> OSIPhone::dynamic_symbol_lookup_table; +HashMap<String, void *> OS_IOS::dynamic_symbol_lookup_table; void add_ios_init_callback(init_callback cb) { if (ios_init_callbacks_count == ios_init_callbacks_capacity) { @@ -82,14 +82,14 @@ void add_ios_init_callback(init_callback cb) { } void register_dynamic_symbol(char *name, void *address) { - OSIPhone::dynamic_symbol_lookup_table[String(name)] = address; + OS_IOS::dynamic_symbol_lookup_table[String(name)] = address; } -OSIPhone *OSIPhone::get_singleton() { - return (OSIPhone *)OS::get_singleton(); +OS_IOS *OS_IOS::get_singleton() { + return (OS_IOS *)OS::get_singleton(); } -OSIPhone::OSIPhone(String p_data_dir, String p_cache_dir) { +OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) { for (int i = 0; i < ios_init_callbacks_count; ++i) { ios_init_callbacks[i](); } @@ -116,37 +116,37 @@ OSIPhone::OSIPhone(String p_data_dir, String p_cache_dir) { AudioDriverManager::add_driver(&audio_driver); - DisplayServerIPhone::register_iphone_driver(); + DisplayServerIOS::register_ios_driver(); } -OSIPhone::~OSIPhone() {} +OS_IOS::~OS_IOS() {} -void OSIPhone::alert(const String &p_alert, const String &p_title) { +void OS_IOS::alert(const String &p_alert, const String &p_title) { const CharString utf8_alert = p_alert.utf8(); const CharString utf8_title = p_title.utf8(); iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); } -void OSIPhone::initialize_core() { +void OS_IOS::initialize_core() { OS_Unix::initialize_core(); set_user_data_dir(user_data_dir); } -void OSIPhone::initialize() { +void OS_IOS::initialize() { initialize_core(); } -void OSIPhone::initialize_modules() { +void OS_IOS::initialize_modules() { ios = memnew(iOS); Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", ios)); - joypad_iphone = memnew(JoypadIPhone); + joypad_ios = memnew(JoypadIOS); } -void OSIPhone::deinitialize_modules() { - if (joypad_iphone) { - memdelete(joypad_iphone); +void OS_IOS::deinitialize_modules() { + if (joypad_ios) { + memdelete(joypad_ios); } if (ios) { @@ -154,7 +154,7 @@ void OSIPhone::deinitialize_modules() { } } -void OSIPhone::set_main_loop(MainLoop *p_main_loop) { +void OS_IOS::set_main_loop(MainLoop *p_main_loop) { main_loop = p_main_loop; if (main_loop) { @@ -162,11 +162,11 @@ void OSIPhone::set_main_loop(MainLoop *p_main_loop) { } } -MainLoop *OSIPhone::get_main_loop() const { +MainLoop *OS_IOS::get_main_loop() const { return main_loop; } -void OSIPhone::delete_main_loop() { +void OS_IOS::delete_main_loop() { if (main_loop) { main_loop->finalize(); memdelete(main_loop); @@ -175,7 +175,7 @@ void OSIPhone::delete_main_loop() { main_loop = nullptr; } -bool OSIPhone::iterate() { +bool OS_IOS::iterate() { if (!main_loop) { return true; } @@ -187,15 +187,15 @@ bool OSIPhone::iterate() { return Main::iteration(); } -void OSIPhone::start() { +void OS_IOS::start() { Main::start(); - if (joypad_iphone) { - joypad_iphone->start_processing(); + if (joypad_ios) { + joypad_ios->start_processing(); } } -void OSIPhone::finalize() { +void OS_IOS::finalize() { deinitialize_modules(); // Already gets called @@ -204,7 +204,7 @@ void OSIPhone::finalize() { // MARK: Dynamic Libraries -Error OSIPhone::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { +Error OS_IOS::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { if (p_path.length() == 0) { p_library_handle = RTLD_SELF; @@ -217,16 +217,16 @@ Error OSIPhone::open_dynamic_library(const String p_path, void *&p_library_handl return OS_Unix::open_dynamic_library(p_path, p_library_handle, p_also_set_library_path, r_resolved_path); } -Error OSIPhone::close_dynamic_library(void *p_library_handle) { +Error OS_IOS::close_dynamic_library(void *p_library_handle) { if (p_library_handle == RTLD_SELF) { return OK; } return OS_Unix::close_dynamic_library(p_library_handle); } -Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) { +Error OS_IOS::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) { if (p_library_handle == RTLD_SELF) { - void **ptr = OSIPhone::dynamic_symbol_lookup_table.getptr(p_name); + void **ptr = OS_IOS::dynamic_symbol_lookup_table.getptr(p_name); if (ptr) { p_symbol_handle = *ptr; return OK; @@ -235,11 +235,11 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const return OS_Unix::get_dynamic_library_symbol_handle(p_library_handle, p_name, p_symbol_handle, p_optional); } -String OSIPhone::get_name() const { +String OS_IOS::get_name() const { return "iOS"; } -String OSIPhone::get_model_name() const { +String OS_IOS::get_model_name() const { String model = ios->get_model(); if (model != "") { return model; @@ -248,7 +248,7 @@ String OSIPhone::get_model_name() const { return OS_Unix::get_model_name(); } -Error OSIPhone::shell_open(String p_uri) { +Error OS_IOS::shell_open(String p_uri) { NSString *urlPath = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()]; NSURL *url = [NSURL URLWithString:urlPath]; @@ -263,21 +263,21 @@ Error OSIPhone::shell_open(String p_uri) { return OK; } -void OSIPhone::set_user_data_dir(String p_dir) { +void OS_IOS::set_user_data_dir(String p_dir) { Ref<DirAccess> da = DirAccess::open(p_dir); user_data_dir = da->get_current_dir(); printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), p_dir.utf8().get_data()); } -String OSIPhone::get_user_data_dir() const { +String OS_IOS::get_user_data_dir() const { return user_data_dir; } -String OSIPhone::get_cache_path() const { +String OS_IOS::get_cache_path() const { return cache_dir; } -String OSIPhone::get_locale() const { +String OS_IOS::get_locale() const { NSString *preferedLanguage = [NSLocale preferredLanguages].firstObject; if (preferedLanguage) { @@ -288,12 +288,12 @@ String OSIPhone::get_locale() const { return String::utf8([localeIdentifier UTF8String]).replace("-", "_"); } -String OSIPhone::get_unique_id() const { +String OS_IOS::get_unique_id() const { NSString *uuid = [UIDevice currentDevice].identifierForVendor.UUIDString; return String::utf8([uuid UTF8String]); } -String OSIPhone::get_processor_name() const { +String OS_IOS::get_processor_name() const { char buffer[256]; size_t buffer_len = 256; if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) { @@ -302,7 +302,7 @@ String OSIPhone::get_processor_name() const { ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); } -void OSIPhone::vibrate_handheld(int p_duration_ms) { +void OS_IOS::vibrate_handheld(int p_duration_ms) { if (ios->supports_haptic_engine()) { ios->vibrate_haptic_engine((float)p_duration_ms / 1000.f); } else { @@ -311,16 +311,16 @@ void OSIPhone::vibrate_handheld(int p_duration_ms) { } } -bool OSIPhone::_check_internal_feature_support(const String &p_feature) { +bool OS_IOS::_check_internal_feature_support(const String &p_feature) { return p_feature == "mobile"; } -void OSIPhone::on_focus_out() { +void OS_IOS::on_focus_out() { if (is_focused) { is_focused = false; - if (DisplayServerIPhone::get_singleton()) { - DisplayServerIPhone::get_singleton()->send_window_event(DisplayServer::WINDOW_EVENT_FOCUS_OUT); + if (DisplayServerIOS::get_singleton()) { + DisplayServerIOS::get_singleton()->send_window_event(DisplayServer::WINDOW_EVENT_FOCUS_OUT); } [AppDelegate.viewController.godotView stopRendering]; @@ -329,12 +329,12 @@ void OSIPhone::on_focus_out() { } } -void OSIPhone::on_focus_in() { +void OS_IOS::on_focus_in() { if (!is_focused) { is_focused = true; - if (DisplayServerIPhone::get_singleton()) { - DisplayServerIPhone::get_singleton()->send_window_event(DisplayServer::WINDOW_EVENT_FOCUS_IN); + if (DisplayServerIOS::get_singleton()) { + DisplayServerIOS::get_singleton()->send_window_event(DisplayServer::WINDOW_EVENT_FOCUS_IN); } [AppDelegate.viewController.godotView startRendering]; @@ -343,4 +343,4 @@ void OSIPhone::on_focus_in() { } } -#endif // IPHONE_ENABLED +#endif // IOS_ENABLED diff --git a/platform/iphone/platform_config.h b/platform/ios/platform_config.h index fed77d8932..fed77d8932 100644 --- a/platform/iphone/platform_config.h +++ b/platform/ios/platform_config.h diff --git a/platform/iphone/tts_ios.h b/platform/ios/tts_ios.h index 064316b0b2..064316b0b2 100644 --- a/platform/iphone/tts_ios.h +++ b/platform/ios/tts_ios.h diff --git a/platform/iphone/tts_ios.mm b/platform/ios/tts_ios.mm index a079d02add..a079d02add 100644 --- a/platform/iphone/tts_ios.mm +++ b/platform/ios/tts_ios.mm diff --git a/platform/iphone/view_controller.h b/platform/ios/view_controller.h index c8b37a4d11..c8b37a4d11 100644 --- a/platform/iphone/view_controller.h +++ b/platform/ios/view_controller.h diff --git a/platform/iphone/view_controller.mm b/platform/ios/view_controller.mm index 4f4ef4f046..43669d3f94 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/ios/view_controller.mm @@ -30,11 +30,11 @@ #import "view_controller.h" #include "core/config/project_settings.h" -#include "display_server_iphone.h" +#include "display_server_ios.h" #import "godot_view.h" #import "godot_view_renderer.h" #import "keyboard_input_view.h" -#include "os_iphone.h" +#include "os_ios.h" #import <AVFoundation/AVFoundation.h> #import <GameController/GameController.h> @@ -168,11 +168,11 @@ } - (BOOL)shouldAutorotate { - if (!DisplayServerIPhone::get_singleton()) { + if (!DisplayServerIOS::get_singleton()) { return NO; } - switch (DisplayServerIPhone::get_singleton()->screen_get_orientation(DisplayServer::SCREEN_OF_MAIN_WINDOW)) { + switch (DisplayServerIOS::get_singleton()->screen_get_orientation(DisplayServer::SCREEN_OF_MAIN_WINDOW)) { case DisplayServer::SCREEN_SENSOR: case DisplayServer::SCREEN_SENSOR_LANDSCAPE: case DisplayServer::SCREEN_SENSOR_PORTRAIT: @@ -183,11 +183,11 @@ } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { - if (!DisplayServerIPhone::get_singleton()) { + if (!DisplayServerIOS::get_singleton()) { return UIInterfaceOrientationMaskAll; } - switch (DisplayServerIPhone::get_singleton()->screen_get_orientation(DisplayServer::SCREEN_OF_MAIN_WINDOW)) { + switch (DisplayServerIOS::get_singleton()->screen_get_orientation(DisplayServer::SCREEN_OF_MAIN_WINDOW)) { case DisplayServer::SCREEN_PORTRAIT: return UIInterfaceOrientationMaskPortrait; case DisplayServer::SCREEN_REVERSE_LANDSCAPE: @@ -226,14 +226,14 @@ CGRect rawFrame = [value CGRectValue]; CGRect keyboardFrame = [self.view convertRect:rawFrame fromView:nil]; - if (DisplayServerIPhone::get_singleton()) { - DisplayServerIPhone::get_singleton()->virtual_keyboard_set_height(keyboardFrame.size.height); + if (DisplayServerIOS::get_singleton()) { + DisplayServerIOS::get_singleton()->virtual_keyboard_set_height(keyboardFrame.size.height); } } - (void)keyboardHidden:(NSNotification *)notification { - if (DisplayServerIPhone::get_singleton()) { - DisplayServerIPhone::get_singleton()->virtual_keyboard_set_height(0); + if (DisplayServerIOS::get_singleton()) { + DisplayServerIOS::get_singleton()->virtual_keyboard_set_height(0); } } diff --git a/platform/iphone/vulkan_context_iphone.h b/platform/ios/vulkan_context_ios.h index 7576525755..e9c09e087a 100644 --- a/platform/iphone/vulkan_context_iphone.h +++ b/platform/ios/vulkan_context_ios.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_iphone.h */ +/* vulkan_context_ios.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,21 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VULKAN_CONTEXT_IPHONE_H -#define VULKAN_CONTEXT_IPHONE_H +#ifndef VULKAN_CONTEXT_IOS_H +#define VULKAN_CONTEXT_IOS_H #include "drivers/vulkan/vulkan_context.h" #import <UIKit/UIKit.h> -class VulkanContextIPhone : public VulkanContext { +class VulkanContextIOS : public VulkanContext { virtual const char *_get_platform_surface_extension() const; public: Error window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, CALayer *p_metal_layer, int p_width, int p_height); - VulkanContextIPhone(); - ~VulkanContextIPhone(); + VulkanContextIOS(); + ~VulkanContextIOS(); }; -#endif // VULKAN_CONTEXT_IPHONE_H +#endif // VULKAN_CONTEXT_IOS_H diff --git a/platform/iphone/vulkan_context_iphone.mm b/platform/ios/vulkan_context_ios.mm index 17cb0f6009..09cd369aa5 100644 --- a/platform/iphone/vulkan_context_iphone.mm +++ b/platform/ios/vulkan_context_ios.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_iphone.mm */ +/* vulkan_context_ios.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,18 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "vulkan_context_iphone.h" +#include "vulkan_context_ios.h" #ifdef USE_VOLK #include <volk.h> #else #include <vulkan/vulkan.h> #endif -const char *VulkanContextIPhone::_get_platform_surface_extension() const { +const char *VulkanContextIOS::_get_platform_surface_extension() const { return VK_MVK_IOS_SURFACE_EXTENSION_NAME; } -Error VulkanContextIPhone::window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, CALayer *p_metal_layer, int p_width, int p_height) { +Error VulkanContextIOS::window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, CALayer *p_metal_layer, int p_width, int p_height) { VkIOSSurfaceCreateInfoMVK createInfo; createInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK; createInfo.pNext = nullptr; @@ -54,6 +54,6 @@ Error VulkanContextIPhone::window_create(DisplayServer::WindowID p_window_id, Di return _window_create(p_window_id, p_vsync_mode, surface, p_width, p_height); } -VulkanContextIPhone::VulkanContextIPhone() {} +VulkanContextIOS::VulkanContextIOS() {} -VulkanContextIPhone::~VulkanContextIPhone() {} +VulkanContextIOS::~VulkanContextIOS() {} diff --git a/platform/javascript/js/engine/config.js b/platform/javascript/js/engine/config.js index 2e5e1ed0d1..9c4b6c2012 100644 --- a/platform/javascript/js/engine/config.js +++ b/platform/javascript/js/engine/config.js @@ -334,6 +334,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- locale = navigator.languages ? navigator.languages[0] : navigator.language; locale = locale.split('.')[0]; } + locale = locale.replace('-', '_'); const onExit = this.onExit; // Godot configuration. diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub index 09a432eae2..636a3c7db2 100644 --- a/platform/linuxbsd/SCsub +++ b/platform/linuxbsd/SCsub @@ -12,7 +12,7 @@ common_linuxbsd = [ "freedesktop_screensaver.cpp", ] -if "x11" in env and env["x11"]: +if env["x11"]: common_linuxbsd += [ "gl_manager_x11.cpp", "detect_prime_x11.cpp", @@ -20,13 +20,13 @@ if "x11" in env and env["x11"]: "key_mapping_x11.cpp", ] -if "speechd" in env and env["speechd"]: - common_linuxbsd.append(["speechd-so_wrap.c", "tts_linux.cpp"]) + if env["vulkan"]: + common_linuxbsd.append("vulkan_context_x11.cpp") -if "vulkan" in env and env["vulkan"]: - common_linuxbsd.append("vulkan_context_x11.cpp") +if env["speechd"]: + common_linuxbsd.append(["speechd-so_wrap.c", "tts_linux.cpp"]) -if "udev" in env and env["udev"]: +if env["udev"]: common_linuxbsd.append("libudev-so_wrap.c") prog = env.add_program("#bin/godot", ["godot_linuxbsd.cpp"] + common_linuxbsd) diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 19cf341c85..065250c40e 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -1,6 +1,7 @@ import os import platform import sys +from methods import get_compiler_version, using_gcc def is_active(): @@ -15,47 +16,11 @@ def can_build(): if os.name != "posix" or sys.platform == "darwin": return False - # Check the minimal dependencies - x11_error = os.system("pkg-config --version > /dev/null") - if x11_error: + pkgconf_error = os.system("pkg-config --version > /dev/null") + if pkgconf_error: print("Error: pkg-config not found. Aborting.") return False - x11_error = os.system("pkg-config x11 --modversion > /dev/null") - if x11_error: - print("Error: X11 libraries not found. Aborting.") - return False - - x11_error = os.system("pkg-config xcursor --modversion > /dev/null") - if x11_error: - print("Error: Xcursor library not found. Aborting.") - return False - - x11_error = os.system("pkg-config xinerama --modversion > /dev/null") - if x11_error: - print("Error: Xinerama library not found. Aborting.") - return False - - x11_error = os.system("pkg-config xext --modversion > /dev/null") - if x11_error: - print("Error: Xext library not found. Aborting.") - return False - - x11_error = os.system("pkg-config xrandr --modversion > /dev/null") - if x11_error: - print("Error: XrandR library not found. Aborting.") - return False - - x11_error = os.system("pkg-config xrender --modversion > /dev/null") - if x11_error: - print("Error: XRender library not found. Aborting.") - return False - - x11_error = os.system("pkg-config xi --modversion > /dev/null") - if x11_error: - print("Error: Xi library not found. Aborting.") - return False - return True @@ -63,9 +28,9 @@ def get_opts(): from SCons.Variables import BoolVariable, EnumVariable return [ + EnumVariable("linker", "Linker program", "default", ("default", "bfd", "gold", "lld", "mold")), BoolVariable("use_llvm", "Use the LLVM compiler", False), - BoolVariable("use_lld", "Use the LLD linker", False), - BoolVariable("use_thinlto", "Use ThinLTO", False), + BoolVariable("use_thinlto", "Use ThinLTO (LLVM only, requires linker=lld, implies use_lto=yes)", False), BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True), BoolVariable("use_coverage", "Test Godot coverage", False), BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), @@ -147,15 +112,32 @@ def configure(env): env["CXX"] = "clang++" env.extra_suffix = ".llvm" + env.extra_suffix - if env["use_lld"]: - if env["use_llvm"]: - env.Append(LINKFLAGS=["-fuse-ld=lld"]) - if env["use_thinlto"]: - # A convenience so you don't need to write use_lto too when using SCons - env["use_lto"] = True + if env["linker"] != "default": + print("Using linker program: " + env["linker"]) + if env["linker"] == "mold" and using_gcc(env): # GCC < 12.1 doesn't support -fuse-ld=mold. + cc_version = get_compiler_version(env) + cc_semver = (int(cc_version["major"]), int(cc_version["minor"])) + if cc_semver < (12, 1): + found_wrapper = False + for path in ["/usr/libexec", "/usr/local/libexec", "/usr/lib", "/usr/local/lib"]: + if os.path.isfile(path + "/mold/ld"): + env.Append(LINKFLAGS=["-B" + path + "/mold"]) + found_wrapper = True + break + if not found_wrapper: + print("Couldn't locate mold installation path. Make sure it's installed in /usr or /usr/local.") + sys.exit(255) + else: + env.Append(LINKFLAGS=["-fuse-ld=mold"]) else: - print("Using LLD with GCC is not supported yet. Try compiling with 'use_llvm=yes'.") + env.Append(LINKFLAGS=["-fuse-ld=%s" % env["linker"]]) + + if env["use_thinlto"]: + if not env["use_llvm"] or env["linker"] != "lld": + print("ThinLTO is only compatible with LLVM and the LLD linker, use `use_llvm=yes linker=lld`.") sys.exit(255) + else: + env["use_lto"] = True # ThinLTO implies LTO if env["use_coverage"]: env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) @@ -200,33 +182,32 @@ def configure(env): env.Append(LINKFLAGS=["-fsanitize=memory"]) if env["use_lto"]: - if not env["use_llvm"] and env.GetOption("num_jobs") > 1: + if env["use_thinlto"]: + env.Append(CCFLAGS=["-flto=thin"]) + env.Append(LINKFLAGS=["-flto=thin"]) + elif not env["use_llvm"] and env.GetOption("num_jobs") > 1: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) else: - if env["use_lld"] and env["use_thinlto"]: - env.Append(CCFLAGS=["-flto=thin"]) - env.Append(LINKFLAGS=["-flto=thin"]) - else: - env.Append(CCFLAGS=["-flto"]) - env.Append(LINKFLAGS=["-flto"]) + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto"]) if not env["use_llvm"]: env["RANLIB"] = "gcc-ranlib" env["AR"] = "gcc-ar" env.Append(CCFLAGS=["-pipe"]) - env.Append(LINKFLAGS=["-pipe"]) ## Dependencies - env.ParseConfig("pkg-config x11 --cflags --libs") - env.ParseConfig("pkg-config xcursor --cflags --libs") - env.ParseConfig("pkg-config xinerama --cflags --libs") - env.ParseConfig("pkg-config xext --cflags --libs") - env.ParseConfig("pkg-config xrandr --cflags --libs") - env.ParseConfig("pkg-config xrender --cflags --libs") - env.ParseConfig("pkg-config xi --cflags --libs") + if env["x11"]: + env.ParseConfig("pkg-config x11 --cflags --libs") + env.ParseConfig("pkg-config xcursor --cflags --libs") + env.ParseConfig("pkg-config xinerama --cflags --libs") + env.ParseConfig("pkg-config xext --cflags --libs") + env.ParseConfig("pkg-config xrandr --cflags --libs") + env.ParseConfig("pkg-config xrender --cflags --libs") + env.ParseConfig("pkg-config xi --cflags --libs") if env["touch"]: env.Append(CPPDEFINES=["TOUCH_ENABLED"]) @@ -382,8 +363,9 @@ def configure(env): # No pkgconfig file so far, hardcode expected lib name. env.Append(LIBS=["glslang", "SPIRV"]) - env.Append(CPPDEFINES=["GLES3_ENABLED"]) - env.ParseConfig("pkg-config gl --cflags --libs") + if env["opengl3"]: + env.Append(CPPDEFINES=["GLES3_ENABLED"]) + env.ParseConfig("pkg-config gl --cflags --libs") env.Append(LIBS=["pthread"]) diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index b0f87484b9..d4267d3c02 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -275,7 +275,7 @@ bool DisplayServerX11::_refresh_device_info() { xi.pen_pressure_range[dev->deviceid] = Vector2(pressure_min, pressure_max); xi.pen_tilt_x_range[dev->deviceid] = Vector2(tilt_x_min, tilt_x_max); xi.pen_tilt_y_range[dev->deviceid] = Vector2(tilt_y_min, tilt_y_max); - xi.pen_inverted_devices[dev->deviceid] = (bool)strstr(dev->name, "eraser"); + xi.pen_inverted_devices[dev->deviceid] = String(dev->name).findn("eraser") > 0; } XIFreeDeviceInfo(info); @@ -1489,8 +1489,8 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window XMoveResizeWindow(x11_display, wd.x11_window, position.x, position.y, size.x, size.y); } else { if (p_screen != window_get_current_screen(p_window)) { - Point2i position = screen_get_position(p_screen); - XMoveWindow(x11_display, wd.x11_window, position.x, position.y); + Vector2 ofs = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window)); + window_set_position(ofs + screen_get_position(p_screen), p_window); } } } diff --git a/platform/macos/SCsub b/platform/macos/SCsub new file mode 100644 index 0000000000..d0856c709a --- /dev/null +++ b/platform/macos/SCsub @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +Import("env") + +from platform_methods import run_in_subprocess +import platform_macos_builders + +files = [ + "os_macos.mm", + "godot_application.mm", + "godot_application_delegate.mm", + "crash_handler_macos.mm", + "macos_terminal_logger.mm", + "display_server_macos.mm", + "godot_content_view.mm", + "godot_window_delegate.mm", + "godot_window.mm", + "key_mapping_macos.mm", + "godot_main_macos.mm", + "dir_access_macos.mm", + "tts_macos.mm", + "joypad_macos.cpp", + "vulkan_context_macos.mm", + "gl_manager_macos_legacy.mm", +] + +prog = env.add_program("#bin/godot", files) + +if env["debug_symbols"] and env["separate_debug_symbols"]: + env.AddPostAction(prog, run_in_subprocess(platform_macos_builders.make_debug_macos)) diff --git a/platform/osx/crash_handler_osx.h b/platform/macos/crash_handler_macos.h index 72938e5e0a..c9b0e77dc4 100644 --- a/platform/osx/crash_handler_osx.h +++ b/platform/macos/crash_handler_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* crash_handler_osx.h */ +/* crash_handler_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef CRASH_HANDLER_OSX_H -#define CRASH_HANDLER_OSX_H +#ifndef CRASH_HANDLER_MACOS_H +#define CRASH_HANDLER_MACOS_H class CrashHandler { bool disabled; @@ -44,4 +44,4 @@ public: ~CrashHandler(); }; -#endif // CRASH_HANDLER_OSX_H +#endif // CRASH_HANDLER_MACOS_H diff --git a/platform/osx/crash_handler_osx.mm b/platform/macos/crash_handler_macos.mm index a798ba3b46..74bd012f0c 100644 --- a/platform/osx/crash_handler_osx.mm +++ b/platform/macos/crash_handler_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* crash_handler_osx.mm */ +/* crash_handler_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "crash_handler_osx.h" +#include "crash_handler_macos.h" #include "core/config/project_settings.h" #include "core/os/os.h" diff --git a/platform/osx/detect.py b/platform/macos/detect.py index 47765cff71..20e7afa772 100644 --- a/platform/osx/detect.py +++ b/platform/macos/detect.py @@ -8,7 +8,7 @@ def is_active(): def get_name(): - return "OSX" + return "macOS" def can_build(): @@ -98,7 +98,7 @@ def configure(env): ## Architecture - # Mac OS X no longer runs on 32-bit since 10.7 which is unsupported since 2014 + # macOS no longer runs on 32-bit since 10.7 which is unsupported since 2014 # As such, we only support 64-bit env["bits"] = "64" @@ -134,7 +134,7 @@ def configure(env): env["CC"] = "clang" env["CXX"] = "clang++" - detect_darwin_sdk_path("osx", env) + detect_darwin_sdk_path("macos", env) env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) env.Append(LINKFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) @@ -191,8 +191,10 @@ def configure(env): ## Flags - env.Prepend(CPPPATH=["#platform/osx"]) - env.Append(CPPDEFINES=["OSX_ENABLED", "UNIX_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED"]) + env.Prepend(CPPPATH=["#platform/macos"]) + env.Append( + CPPDEFINES=["MACOS_ENABLED", "UNIX_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED"] + ) env.Append( LINKFLAGS=[ "-framework", diff --git a/platform/osx/dir_access_osx.h b/platform/macos/dir_access_macos.h index 3c66c81d4f..2b234ad96c 100644 --- a/platform/osx/dir_access_osx.h +++ b/platform/macos/dir_access_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* dir_access_osx.h */ +/* dir_access_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef DIR_ACCESS_OSX_H -#define DIR_ACCESS_OSX_H +#ifndef DIR_ACCESS_MACOS_H +#define DIR_ACCESS_MACOS_H #if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED) @@ -41,7 +41,7 @@ #include "core/io/dir_access.h" #include "drivers/unix/dir_access_unix.h" -class DirAccessOSX : public DirAccessUnix { +class DirAccessMacOS : public DirAccessUnix { protected: virtual String fix_unicode_name(const char *p_name) const; diff --git a/platform/osx/dir_access_osx.mm b/platform/macos/dir_access_macos.mm index 6bafb9470d..8f3906c6b8 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/macos/dir_access_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* dir_access_osx.mm */ +/* dir_access_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "dir_access_osx.h" +#include "dir_access_macos.h" #if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED) @@ -37,7 +37,7 @@ #import <AppKit/NSWorkspace.h> #import <Foundation/Foundation.h> -String DirAccessOSX::fix_unicode_name(const char *p_name) const { +String DirAccessMacOS::fix_unicode_name(const char *p_name) const { String fname; NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping]; @@ -46,14 +46,14 @@ String DirAccessOSX::fix_unicode_name(const char *p_name) const { return fname; } -int DirAccessOSX::get_drive_count() { +int DirAccessMacOS::get_drive_count() { NSArray *res_keys = [NSArray arrayWithObjects:NSURLVolumeURLKey, NSURLIsSystemImmutableKey, nil]; NSArray *vols = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:res_keys options:NSVolumeEnumerationSkipHiddenVolumes]; return [vols count]; } -String DirAccessOSX::get_drive(int p_drive) { +String DirAccessMacOS::get_drive(int p_drive) { NSArray *res_keys = [NSArray arrayWithObjects:NSURLVolumeURLKey, NSURLIsSystemImmutableKey, nil]; NSArray *vols = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:res_keys options:NSVolumeEnumerationSkipHiddenVolumes]; int count = [vols count]; @@ -68,7 +68,7 @@ String DirAccessOSX::get_drive(int p_drive) { return volname; } -bool DirAccessOSX::is_hidden(const String &p_name) { +bool DirAccessMacOS::is_hidden(const String &p_name) { String f = get_current_dir().plus_file(p_name); NSURL *url = [NSURL fileURLWithPath:@(f.utf8().get_data())]; NSNumber *hidden = nil; diff --git a/platform/osx/display_server_osx.h b/platform/macos/display_server_macos.h index 9575cb29a2..41031ec81b 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/macos/display_server_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* display_server_osx.h */ +/* display_server_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef DISPLAY_SERVER_OSX_H -#define DISPLAY_SERVER_OSX_H +#ifndef DISPLAY_SERVER_MACOS_H +#define DISPLAY_SERVER_MACOS_H #define BitMap _QDBitMap // Suppress deprecated QuickDraw definition. @@ -37,12 +37,12 @@ #include "servers/display_server.h" #if defined(GLES3_ENABLED) -#include "gl_manager_osx_legacy.h" +#include "gl_manager_macos_legacy.h" #endif // GLES3_ENABLED #if defined(VULKAN_ENABLED) #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/osx/vulkan_context_osx.h" +#include "platform/macos/vulkan_context_macos.h" #endif // VULKAN_ENABLED #import <AppKit/AppKit.h> @@ -54,15 +54,15 @@ #undef BitMap #undef CursorShape -class DisplayServerOSX : public DisplayServer { - GDCLASS(DisplayServerOSX, DisplayServer) +class DisplayServerMacOS : public DisplayServer { + GDCLASS(DisplayServerMacOS, DisplayServer) _THREAD_SAFE_CLASS_ public: struct KeyEvent { WindowID window_id = INVALID_WINDOW_ID; - unsigned int osx_state = false; + unsigned int macos_state = false; bool pressed = false; bool echo = false; bool raw = false; @@ -115,10 +115,10 @@ public: private: #if defined(GLES3_ENABLED) - GLManager_OSX *gl_manager = nullptr; + GLManager_MacOS *gl_manager = nullptr; #endif #if defined(VULKAN_ENABLED) - VulkanContextOSX *context_vulkan = nullptr; + VulkanContextMacOS *context_vulkan = nullptr; RenderingDeviceVulkan *rendering_device_vulkan = nullptr; #endif String rendering_driver; @@ -203,7 +203,7 @@ public: void send_event(NSEvent *p_event); void send_window_event(const WindowData &p_wd, WindowEvent p_event); void release_pressed_events(); - void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> r_state) const; + 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); void update_im_text(const Point2i &p_selection, const String &p_text); @@ -397,10 +397,10 @@ public: static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static Vector<String> get_rendering_drivers_func(); - static void register_osx_driver(); + static void register_macos_driver(); - DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); - ~DisplayServerOSX(); + DisplayServerMacOS(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); + ~DisplayServerMacOS(); }; -#endif // DISPLAY_SERVER_OSX_H +#endif // DISPLAY_SERVER_MACOS_H diff --git a/platform/osx/display_server_osx.mm b/platform/macos/display_server_macos.mm index 91d64b50f0..07ba5d7497 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/macos/display_server_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* display_server_osx.mm */ +/* display_server_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "display_server_osx.h" +#include "display_server_macos.h" #include "godot_content_view.h" #include "godot_menu_item.h" #include "godot_window.h" #include "godot_window_delegate.h" -#include "key_mapping_osx.h" -#include "os_osx.h" +#include "key_mapping_macos.h" +#include "os_macos.h" -#include "tts_osx.h" +#include "tts_macos.h" #include "core/io/marshalls.h" #include "core/math/geometry_2d.h" @@ -60,7 +60,7 @@ #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #endif -const NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) const { +const NSMenu *DisplayServerMacOS::_get_menu_root(const String &p_menu_root) const { const NSMenu *menu = nullptr; if (p_menu_root == "") { // Main menu. @@ -81,7 +81,7 @@ const NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) const return menu; } -NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) { +NSMenu *DisplayServerMacOS::_get_menu_root(const String &p_menu_root) { NSMenu *menu = nullptr; if (p_menu_root == "") { // Main menu. @@ -105,7 +105,7 @@ NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) { return menu; } -DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, VSyncMode p_vsync_mode, const Rect2i &p_rect) { +DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mode, VSyncMode p_vsync_mode, const Rect2i &p_rect) { WindowID id; const float scale = screen_get_max_scale(); { @@ -193,7 +193,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V return id; } -void DisplayServerOSX::_update_window_style(WindowData p_wd) { +void DisplayServerMacOS::_update_window_style(WindowData p_wd) { bool borderless_full = false; if (p_wd.borderless) { @@ -222,7 +222,7 @@ void DisplayServerOSX::_update_window_style(WindowData p_wd) { } } -void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) { +void DisplayServerMacOS::_set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) { ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; @@ -267,7 +267,7 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled } } -void DisplayServerOSX::_update_displays_arrangement() { +void DisplayServerMacOS::_update_displays_arrangement() { origin = Point2i(); for (int i = 0; i < get_screen_count(); i++) { @@ -282,20 +282,20 @@ void DisplayServerOSX::_update_displays_arrangement() { displays_arrangement_dirty = false; } -Point2i DisplayServerOSX::_get_screens_origin() const { +Point2i DisplayServerMacOS::_get_screens_origin() const { // Returns the native top-left screen coordinate of the smallest rectangle // that encompasses all screens. Needed in get_screen_position(), // window_get_position, and window_set_position() // to convert between OS X native screen coordinates and the ones expected by Godot. if (displays_arrangement_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_displays_arrangement(); + const_cast<DisplayServerMacOS *>(this)->_update_displays_arrangement(); } return origin; } -Point2i DisplayServerOSX::_get_native_screen_position(int p_screen) const { +Point2i DisplayServerMacOS::_get_native_screen_position(int p_screen) const { NSArray *screenArray = [NSScreen screens]; if ((NSUInteger)p_screen < [screenArray count]) { NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame]; @@ -306,18 +306,18 @@ Point2i DisplayServerOSX::_get_native_screen_position(int p_screen) const { return Point2i(); } -void DisplayServerOSX::_displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); +void DisplayServerMacOS::_displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) { + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { ds->displays_arrangement_dirty = true; } } -void DisplayServerOSX::_dispatch_input_events(const Ref<InputEvent> &p_event) { - ((DisplayServerOSX *)(get_singleton()))->_dispatch_input_event(p_event); +void DisplayServerMacOS::_dispatch_input_events(const Ref<InputEvent> &p_event) { + ((DisplayServerMacOS *)(get_singleton()))->_dispatch_input_event(p_event); } -void DisplayServerOSX::_dispatch_input_event(const Ref<InputEvent> &p_event) { +void DisplayServerMacOS::_dispatch_input_event(const Ref<InputEvent> &p_event) { _THREAD_SAFE_METHOD_ if (!in_dispatch_input_event) { in_dispatch_input_event = true; @@ -364,12 +364,12 @@ void DisplayServerOSX::_dispatch_input_event(const Ref<InputEvent> &p_event) { } } -void DisplayServerOSX::_push_input(const Ref<InputEvent> &p_event) { +void DisplayServerMacOS::_push_input(const Ref<InputEvent> &p_event) { Ref<InputEvent> ev = p_event; Input::get_singleton()->parse_input_event(ev); } -void DisplayServerOSX::_process_key_events() { +void DisplayServerMacOS::_process_key_events() { Ref<InputEventKey> k; for (int i = 0; i < key_event_pos; i++) { const KeyEvent &ke = key_event_buffer[i]; @@ -378,7 +378,7 @@ void DisplayServerOSX::_process_key_events() { k.instantiate(); k->set_window_id(ke.window_id); - get_key_modifier_state(ke.osx_state, k); + get_key_modifier_state(ke.macos_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); @@ -392,7 +392,7 @@ void DisplayServerOSX::_process_key_events() { k.instantiate(); k->set_window_id(ke.window_id); - get_key_modifier_state(ke.osx_state, k); + get_key_modifier_state(ke.macos_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(Key::NONE); @@ -405,7 +405,7 @@ void DisplayServerOSX::_process_key_events() { k.instantiate(); k->set_window_id(ke.window_id); - get_key_modifier_state(ke.osx_state, k); + get_key_modifier_state(ke.macos_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); @@ -423,7 +423,7 @@ void DisplayServerOSX::_process_key_events() { key_event_pos = 0; } -void DisplayServerOSX::_update_keyboard_layouts() { +void DisplayServerMacOS::_update_keyboard_layouts() { kbd_layouts.clear(); current_layout = 0; @@ -468,14 +468,14 @@ void DisplayServerOSX::_update_keyboard_layouts() { keyboard_layout_dirty = false; } -void DisplayServerOSX::_keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); +void DisplayServerMacOS::_keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) { + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { ds->keyboard_layout_dirty = true; } } -NSImage *DisplayServerOSX::_convert_to_nsimg(Ref<Image> &p_image) const { +NSImage *DisplayServerMacOS::_convert_to_nsimg(Ref<Image> &p_image) const { p_image->convert(Image::FORMAT_RGBA8); NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL @@ -509,7 +509,7 @@ NSImage *DisplayServerOSX::_convert_to_nsimg(Ref<Image> &p_image) const { return nsimg; } -NSCursor *DisplayServerOSX::_cursor_from_selector(SEL p_selector, SEL p_fallback) { +NSCursor *DisplayServerMacOS::_cursor_from_selector(SEL p_selector, SEL p_fallback) { if ([NSCursor respondsToSelector:p_selector]) { id object = [NSCursor performSelector:p_selector]; if ([object isKindOfClass:[NSCursor class]]) { @@ -523,11 +523,11 @@ NSCursor *DisplayServerOSX::_cursor_from_selector(SEL p_selector, SEL p_fallback return [NSCursor arrowCursor]; } -NSMenu *DisplayServerOSX::get_dock_menu() const { +NSMenu *DisplayServerMacOS::get_dock_menu() const { return dock_menu; } -void DisplayServerOSX::menu_callback(id p_sender) { +void DisplayServerMacOS::menu_callback(id p_sender) { if (![p_sender representedObject]) { return; } @@ -560,15 +560,15 @@ void DisplayServerOSX::menu_callback(id p_sender) { } } -bool DisplayServerOSX::has_window(WindowID p_window) const { +bool DisplayServerMacOS::has_window(WindowID p_window) const { return windows.has(p_window); } -DisplayServerOSX::WindowData &DisplayServerOSX::get_window(WindowID p_window) { +DisplayServerMacOS::WindowData &DisplayServerMacOS::get_window(WindowID p_window) { return windows[p_window]; } -void DisplayServerOSX::send_event(NSEvent *p_event) { +void DisplayServerMacOS::send_event(NSEvent *p_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 ([p_event type] == NSEventTypeKeyDown) { @@ -577,7 +577,7 @@ void DisplayServerOSX::send_event(NSEvent *p_event) { k.instantiate(); get_key_modifier_state([p_event modifierFlags], k); - k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); + k->set_window_id(DisplayServerMacOS::INVALID_WINDOW_ID); k->set_pressed(true); k->set_keycode(Key::PERIOD); k->set_physical_keycode(Key::PERIOD); @@ -588,7 +588,7 @@ void DisplayServerOSX::send_event(NSEvent *p_event) { } } -void DisplayServerOSX::send_window_event(const WindowData &wd, WindowEvent p_event) { +void DisplayServerMacOS::send_window_event(const WindowData &wd, WindowEvent p_event) { _THREAD_SAFE_METHOD_ if (!wd.event_callback.is_null()) { @@ -600,21 +600,21 @@ void DisplayServerOSX::send_window_event(const WindowData &wd, WindowEvent p_eve } } -void DisplayServerOSX::release_pressed_events() { +void DisplayServerMacOS::release_pressed_events() { _THREAD_SAFE_METHOD_ if (Input::get_singleton()) { Input::get_singleton()->release_pressed_events(); } } -void DisplayServerOSX::get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> r_state) const { - r_state->set_shift_pressed((p_osx_state & NSEventModifierFlagShift)); - r_state->set_ctrl_pressed((p_osx_state & NSEventModifierFlagControl)); - r_state->set_alt_pressed((p_osx_state & NSEventModifierFlagOption)); - r_state->set_meta_pressed((p_osx_state & NSEventModifierFlagCommand)); +void DisplayServerMacOS::get_key_modifier_state(unsigned int p_macos_state, Ref<InputEventWithModifiers> r_state) const { + r_state->set_shift_pressed((p_macos_state & NSEventModifierFlagShift)); + r_state->set_ctrl_pressed((p_macos_state & NSEventModifierFlagControl)); + r_state->set_alt_pressed((p_macos_state & NSEventModifierFlagOption)); + r_state->set_meta_pressed((p_macos_state & NSEventModifierFlagCommand)); } -void DisplayServerOSX::update_mouse_pos(DisplayServerOSX::WindowData &p_wd, NSPoint p_location_in_window) { +void DisplayServerMacOS::update_mouse_pos(DisplayServerMacOS::WindowData &p_wd, NSPoint p_location_in_window) { const NSRect content_rect = [p_wd.window_view frame]; const float scale = screen_get_max_scale(); p_wd.mouse_pos.x = p_location_in_window.x * scale; @@ -622,33 +622,33 @@ void DisplayServerOSX::update_mouse_pos(DisplayServerOSX::WindowData &p_wd, NSPo Input::get_singleton()->set_mouse_position(p_wd.mouse_pos); } -void DisplayServerOSX::push_to_key_event_buffer(const DisplayServerOSX::KeyEvent &p_event) { +void DisplayServerMacOS::push_to_key_event_buffer(const DisplayServerMacOS::KeyEvent &p_event) { if (key_event_pos >= key_event_buffer.size()) { key_event_buffer.resize(1 + key_event_pos); } key_event_buffer.write[key_event_pos++] = p_event; } -void DisplayServerOSX::update_im_text(const Point2i &p_selection, const String &p_text) { +void DisplayServerMacOS::update_im_text(const Point2i &p_selection, const String &p_text) { im_selection = p_selection; im_text = p_text; OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE); } -void DisplayServerOSX::set_last_focused_window(WindowID p_window) { +void DisplayServerMacOS::set_last_focused_window(WindowID p_window) { last_focused_window = p_window; } -void DisplayServerOSX::set_is_resizing(bool p_is_resizing) { +void DisplayServerMacOS::set_is_resizing(bool p_is_resizing) { is_resizing = p_is_resizing; } -bool DisplayServerOSX::get_is_resizing() const { +bool DisplayServerMacOS::get_is_resizing() const { return is_resizing; } -void DisplayServerOSX::window_update(WindowID p_window) { +void DisplayServerMacOS::window_update(WindowID p_window) { #if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->window_update(p_window); @@ -656,7 +656,7 @@ void DisplayServerOSX::window_update(WindowID p_window) { #endif } -void DisplayServerOSX::window_destroy(WindowID p_window) { +void DisplayServerMacOS::window_destroy(WindowID p_window) { #if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->window_destroy(p_window); @@ -670,7 +670,7 @@ void DisplayServerOSX::window_destroy(WindowID p_window) { windows.erase(p_window); } -void DisplayServerOSX::window_resize(WindowID p_window, int p_width, int p_height) { +void DisplayServerMacOS::window_resize(WindowID p_window, int p_width, int p_height) { #if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->window_resize(p_window, p_width, p_height); @@ -683,7 +683,7 @@ void DisplayServerOSX::window_resize(WindowID p_window, int p_width, int p_heigh #endif } -bool DisplayServerOSX::has_feature(Feature p_feature) const { +bool DisplayServerMacOS::has_feature(Feature p_feature) const { switch (p_feature) { case FEATURE_GLOBAL_MENU: case FEATURE_SUBWINDOWS: @@ -709,16 +709,16 @@ bool DisplayServerOSX::has_feature(Feature p_feature) const { return false; } -String DisplayServerOSX::get_name() const { - return "OSX"; +String DisplayServerMacOS::get_name() const { + return "macOS"; } -void DisplayServerOSX::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -731,17 +731,17 @@ void DisplayServerOSX::global_menu_add_item(const String &p_menu_root, const Str obj->checkable_type = CHECKABLE_TYPE_NONE; obj->max_states = 0; obj->state = 0; - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -754,17 +754,17 @@ void DisplayServerOSX::global_menu_add_check_item(const String &p_menu_root, con obj->checkable_type = CHECKABLE_TYPE_CHECK_BOX; obj->max_states = 0; obj->state = 0; - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_icon_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_icon_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -786,17 +786,17 @@ void DisplayServerOSX::global_menu_add_icon_item(const String &p_menu_root, cons obj->img->resize(16, 16, Image::INTERPOLATE_LANCZOS); [menu_item setImage:_convert_to_nsimg(obj->img)]; } - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_icon_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_icon_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -818,17 +818,17 @@ void DisplayServerOSX::global_menu_add_icon_check_item(const String &p_menu_root obj->img->resize(16, 16, Image::INTERPOLATE_LANCZOS); [menu_item setImage:_convert_to_nsimg(obj->img)]; } - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_radio_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_radio_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -841,17 +841,17 @@ void DisplayServerOSX::global_menu_add_radio_check_item(const String &p_menu_roo obj->checkable_type = CHECKABLE_TYPE_RADIO_BUTTON; obj->max_states = 0; obj->state = 0; - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_icon_radio_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_icon_radio_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -873,17 +873,17 @@ void DisplayServerOSX::global_menu_add_icon_radio_check_item(const String &p_men obj->img->resize(16, 16, Image::INTERPOLATE_LANCZOS); [menu_item setImage:_convert_to_nsimg(obj->img)]; } - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_multistate_item(const String &p_menu_root, const String &p_label, int p_max_states, int p_default_state, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { +void DisplayServerMacOS::global_menu_add_multistate_item(const String &p_menu_root, const String &p_label, int p_max_states, int p_default_state, const Callable &p_callback, const Variant &p_tag, Key p_accel, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); if (menu) { - String keycode = KeyMappingOSX::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); + String keycode = KeyMappingMacOS::keycode_get_native_string(p_accel & KeyModifierMask::CODE_MASK); NSMenuItem *menu_item; if (p_index != -1) { menu_item = [menu insertItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:[NSString stringWithUTF8String:keycode.utf8().get_data()] atIndex:p_index]; @@ -896,12 +896,12 @@ void DisplayServerOSX::global_menu_add_multistate_item(const String &p_menu_root obj->checkable_type = CHECKABLE_TYPE_NONE; obj->max_states = p_max_states; obj->state = p_default_state; - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_accel)]; + [menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)]; [menu_item setRepresentedObject:obj]; } } -void DisplayServerOSX::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu, int p_index) { +void DisplayServerMacOS::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -926,7 +926,7 @@ void DisplayServerOSX::global_menu_add_submenu_item(const String &p_menu_root, c } } -void DisplayServerOSX::global_menu_add_separator(const String &p_menu_root, int p_index) { +void DisplayServerMacOS::global_menu_add_separator(const String &p_menu_root, int p_index) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -939,7 +939,7 @@ void DisplayServerOSX::global_menu_add_separator(const String &p_menu_root, int } } -int DisplayServerOSX::global_menu_get_item_index_from_text(const String &p_menu_root, const String &p_text) const { +int DisplayServerMacOS::global_menu_get_item_index_from_text(const String &p_menu_root, const String &p_text) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -950,7 +950,7 @@ int DisplayServerOSX::global_menu_get_item_index_from_text(const String &p_menu_ return -1; } -int DisplayServerOSX::global_menu_get_item_index_from_tag(const String &p_menu_root, const Variant &p_tag) const { +int DisplayServerMacOS::global_menu_get_item_index_from_tag(const String &p_menu_root, const Variant &p_tag) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -969,7 +969,7 @@ int DisplayServerOSX::global_menu_get_item_index_from_tag(const String &p_menu_r return -1; } -bool DisplayServerOSX::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const { +bool DisplayServerMacOS::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -982,7 +982,7 @@ bool DisplayServerOSX::global_menu_is_item_checked(const String &p_menu_root, in return false; } -bool DisplayServerOSX::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const { +bool DisplayServerMacOS::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -998,7 +998,7 @@ bool DisplayServerOSX::global_menu_is_item_checkable(const String &p_menu_root, return false; } -bool DisplayServerOSX::global_menu_is_item_radio_checkable(const String &p_menu_root, int p_idx) const { +bool DisplayServerMacOS::global_menu_is_item_radio_checkable(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1014,7 +1014,7 @@ bool DisplayServerOSX::global_menu_is_item_radio_checkable(const String &p_menu_ return false; } -Callable DisplayServerOSX::global_menu_get_item_callback(const String &p_menu_root, int p_idx) const { +Callable DisplayServerMacOS::global_menu_get_item_callback(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1030,7 +1030,7 @@ Callable DisplayServerOSX::global_menu_get_item_callback(const String &p_menu_ro return Callable(); } -Variant DisplayServerOSX::global_menu_get_item_tag(const String &p_menu_root, int p_idx) const { +Variant DisplayServerMacOS::global_menu_get_item_tag(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1046,7 +1046,7 @@ Variant DisplayServerOSX::global_menu_get_item_tag(const String &p_menu_root, in return Variant(); } -String DisplayServerOSX::global_menu_get_item_text(const String &p_menu_root, int p_idx) const { +String DisplayServerMacOS::global_menu_get_item_text(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1059,7 +1059,7 @@ String DisplayServerOSX::global_menu_get_item_text(const String &p_menu_root, in return String(); } -String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) const { +String DisplayServerMacOS::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1079,7 +1079,7 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root, return String(); } -Key DisplayServerOSX::global_menu_get_item_accelerator(const String &p_menu_root, int p_idx) const { +Key DisplayServerMacOS::global_menu_get_item_accelerator(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1110,7 +1110,7 @@ Key DisplayServerOSX::global_menu_get_item_accelerator(const String &p_menu_root return Key::NONE; } -bool DisplayServerOSX::global_menu_is_item_disabled(const String &p_menu_root, int p_idx) const { +bool DisplayServerMacOS::global_menu_is_item_disabled(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1123,7 +1123,7 @@ bool DisplayServerOSX::global_menu_is_item_disabled(const String &p_menu_root, i return false; } -String DisplayServerOSX::global_menu_get_item_tooltip(const String &p_menu_root, int p_idx) const { +String DisplayServerMacOS::global_menu_get_item_tooltip(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1136,7 +1136,7 @@ String DisplayServerOSX::global_menu_get_item_tooltip(const String &p_menu_root, return String(); } -int DisplayServerOSX::global_menu_get_item_state(const String &p_menu_root, int p_idx) const { +int DisplayServerMacOS::global_menu_get_item_state(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1152,7 +1152,7 @@ int DisplayServerOSX::global_menu_get_item_state(const String &p_menu_root, int return 0; } -int DisplayServerOSX::global_menu_get_item_max_states(const String &p_menu_root, int p_idx) const { +int DisplayServerMacOS::global_menu_get_item_max_states(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1168,7 +1168,7 @@ int DisplayServerOSX::global_menu_get_item_max_states(const String &p_menu_root, return 0; } -Ref<Texture2D> DisplayServerOSX::global_menu_get_item_icon(const String &p_menu_root, int p_idx) const { +Ref<Texture2D> DisplayServerMacOS::global_menu_get_item_icon(const String &p_menu_root, int p_idx) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1186,7 +1186,7 @@ Ref<Texture2D> DisplayServerOSX::global_menu_get_item_icon(const String &p_menu_ return Ref<Texture2D>(); } -void DisplayServerOSX::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) { +void DisplayServerMacOS::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1205,7 +1205,7 @@ void DisplayServerOSX::global_menu_set_item_checked(const String &p_menu_root, i } } -void DisplayServerOSX::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) { +void DisplayServerMacOS::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1221,7 +1221,7 @@ void DisplayServerOSX::global_menu_set_item_checkable(const String &p_menu_root, } } -void DisplayServerOSX::global_menu_set_item_radio_checkable(const String &p_menu_root, int p_idx, bool p_checkable) { +void DisplayServerMacOS::global_menu_set_item_radio_checkable(const String &p_menu_root, int p_idx, bool p_checkable) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1237,7 +1237,7 @@ void DisplayServerOSX::global_menu_set_item_radio_checkable(const String &p_menu } } -void DisplayServerOSX::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) { +void DisplayServerMacOS::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1253,7 +1253,7 @@ void DisplayServerOSX::global_menu_set_item_callback(const String &p_menu_root, } } -void DisplayServerOSX::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) { +void DisplayServerMacOS::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1269,7 +1269,7 @@ void DisplayServerOSX::global_menu_set_item_tag(const String &p_menu_root, int p } } -void DisplayServerOSX::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) { +void DisplayServerMacOS::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1284,7 +1284,7 @@ void DisplayServerOSX::global_menu_set_item_text(const String &p_menu_root, int } } -void DisplayServerOSX::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) { +void DisplayServerMacOS::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1308,7 +1308,7 @@ void DisplayServerOSX::global_menu_set_item_submenu(const String &p_menu_root, i } } -void DisplayServerOSX::global_menu_set_item_accelerator(const String &p_menu_root, int p_idx, Key p_keycode) { +void DisplayServerMacOS::global_menu_set_item_accelerator(const String &p_menu_root, int p_idx, Key p_keycode) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1318,14 +1318,14 @@ void DisplayServerOSX::global_menu_set_item_accelerator(const String &p_menu_roo } NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { - [menu_item setKeyEquivalentModifierMask:KeyMappingOSX::keycode_get_native_mask(p_keycode)]; - String keycode = KeyMappingOSX::keycode_get_native_string(p_keycode & KeyModifierMask::CODE_MASK); + [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()]]; } } } -void DisplayServerOSX::global_menu_set_item_disabled(const String &p_menu_root, int p_idx, bool p_disabled) { +void DisplayServerMacOS::global_menu_set_item_disabled(const String &p_menu_root, int p_idx, bool p_disabled) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1340,7 +1340,7 @@ void DisplayServerOSX::global_menu_set_item_disabled(const String &p_menu_root, } } -void DisplayServerOSX::global_menu_set_item_tooltip(const String &p_menu_root, int p_idx, const String &p_tooltip) { +void DisplayServerMacOS::global_menu_set_item_tooltip(const String &p_menu_root, int p_idx, const String &p_tooltip) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1355,7 +1355,7 @@ void DisplayServerOSX::global_menu_set_item_tooltip(const String &p_menu_root, i } } -void DisplayServerOSX::global_menu_set_item_state(const String &p_menu_root, int p_idx, int p_state) { +void DisplayServerMacOS::global_menu_set_item_state(const String &p_menu_root, int p_idx, int p_state) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1373,7 +1373,7 @@ void DisplayServerOSX::global_menu_set_item_state(const String &p_menu_root, int } } -void DisplayServerOSX::global_menu_set_item_max_states(const String &p_menu_root, int p_idx, int p_max_states) { +void DisplayServerMacOS::global_menu_set_item_max_states(const String &p_menu_root, int p_idx, int p_max_states) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1391,7 +1391,7 @@ void DisplayServerOSX::global_menu_set_item_max_states(const String &p_menu_root } } -void DisplayServerOSX::global_menu_set_item_icon(const String &p_menu_root, int p_idx, const Ref<Texture2D> &p_icon) { +void DisplayServerMacOS::global_menu_set_item_icon(const String &p_menu_root, int p_idx, const Ref<Texture2D> &p_icon) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1418,7 +1418,7 @@ void DisplayServerOSX::global_menu_set_item_icon(const String &p_menu_root, int } } -int DisplayServerOSX::global_menu_get_item_count(const String &p_menu_root) const { +int DisplayServerMacOS::global_menu_get_item_count(const String &p_menu_root) const { _THREAD_SAFE_METHOD_ const NSMenu *menu = _get_menu_root(p_menu_root); @@ -1429,7 +1429,7 @@ int DisplayServerOSX::global_menu_get_item_count(const String &p_menu_root) cons } } -void DisplayServerOSX::global_menu_remove_item(const String &p_menu_root, int p_idx) { +void DisplayServerMacOS::global_menu_remove_item(const String &p_menu_root, int p_idx) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1441,7 +1441,7 @@ void DisplayServerOSX::global_menu_remove_item(const String &p_menu_root, int p_ } } -void DisplayServerOSX::global_menu_clear(const String &p_menu_root) { +void DisplayServerMacOS::global_menu_clear(const String &p_menu_root) { _THREAD_SAFE_METHOD_ NSMenu *menu = _get_menu_root(p_menu_root); @@ -1455,42 +1455,42 @@ void DisplayServerOSX::global_menu_clear(const String &p_menu_root) { } } -bool DisplayServerOSX::tts_is_speaking() const { +bool DisplayServerMacOS::tts_is_speaking() const { ERR_FAIL_COND_V(!tts, false); return [tts isSpeaking]; } -bool DisplayServerOSX::tts_is_paused() const { +bool DisplayServerMacOS::tts_is_paused() const { ERR_FAIL_COND_V(!tts, false); return [tts isPaused]; } -Array DisplayServerOSX::tts_get_voices() const { +Array DisplayServerMacOS::tts_get_voices() const { ERR_FAIL_COND_V(!tts, Array()); return [tts getVoices]; } -void DisplayServerOSX::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { +void DisplayServerMacOS::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { ERR_FAIL_COND(!tts); [tts speak:p_text voice:p_voice volume:p_volume pitch:p_pitch rate:p_rate utterance_id:p_utterance_id interrupt:p_interrupt]; } -void DisplayServerOSX::tts_pause() { +void DisplayServerMacOS::tts_pause() { ERR_FAIL_COND(!tts); [tts pauseSpeaking]; } -void DisplayServerOSX::tts_resume() { +void DisplayServerMacOS::tts_resume() { ERR_FAIL_COND(!tts); [tts resumeSpeaking]; } -void DisplayServerOSX::tts_stop() { +void DisplayServerMacOS::tts_stop() { ERR_FAIL_COND(!tts); [tts stopSpeaking]; } -Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) { +Error DisplayServerMacOS::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) { _THREAD_SAFE_METHOD_ NSAlert *window = [[NSAlert alloc] init]; @@ -1528,7 +1528,7 @@ Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector return OK; } -Error DisplayServerOSX::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) { +Error DisplayServerMacOS::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) { _THREAD_SAFE_METHOD_ NSAlert *window = [[NSAlert alloc] init]; @@ -1560,7 +1560,7 @@ Error DisplayServerOSX::dialog_input_text(String p_title, String p_description, return OK; } -void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { +void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) { _THREAD_SAFE_METHOD_ if (p_mode == mouse_mode) { @@ -1615,11 +1615,11 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { } } -DisplayServer::MouseMode DisplayServerOSX::mouse_get_mode() const { +DisplayServer::MouseMode DisplayServerMacOS::mouse_get_mode() const { return mouse_mode; } -bool DisplayServerOSX::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSPoint &r_mpos, NSTimeInterval p_timestamp) { +bool DisplayServerMacOS::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSPoint &r_mpos, NSTimeInterval p_timestamp) { _THREAD_SAFE_METHOD_ if (ignore_warp) { @@ -1641,7 +1641,7 @@ bool DisplayServerOSX::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSP List<WarpEvent>::Element *F = warp_events.front(); while (F) { if (F->get().timestamp < p_timestamp) { - List<DisplayServerOSX::WarpEvent>::Element *E = F; + List<DisplayServerMacOS::WarpEvent>::Element *E = F; r_delta.x -= E->get().delta.x; r_delta.y -= E->get().delta.y; F = F->next(); @@ -1669,7 +1669,7 @@ bool DisplayServerOSX::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSP // Save warp data. last_warp = [[NSProcessInfo processInfo] systemUptime]; - DisplayServerOSX::WarpEvent ev; + DisplayServerMacOS::WarpEvent ev; ev.timestamp = last_warp; ev.delta = r_delta; warp_events.push_back(ev); @@ -1678,7 +1678,7 @@ bool DisplayServerOSX::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSP return false; } -void DisplayServerOSX::warp_mouse(const Point2i &p_position) { +void DisplayServerMacOS::warp_mouse(const Point2i &p_position) { _THREAD_SAFE_METHOD_ if (mouse_mode != MOUSE_MODE_CAPTURED) { @@ -1705,7 +1705,7 @@ void DisplayServerOSX::warp_mouse(const Point2i &p_position) { } } -Point2i DisplayServerOSX::mouse_get_position() const { +Point2i DisplayServerMacOS::mouse_get_position() const { _THREAD_SAFE_METHOD_ const NSPoint mouse_pos = [NSEvent mouseLocation]; @@ -1724,15 +1724,15 @@ Point2i DisplayServerOSX::mouse_get_position() const { return Vector2i(); } -void DisplayServerOSX::mouse_set_button_state(MouseButton p_state) { +void DisplayServerMacOS::mouse_set_button_state(MouseButton p_state) { last_button_state = p_state; } -MouseButton DisplayServerOSX::mouse_get_button_state() const { +MouseButton DisplayServerMacOS::mouse_get_button_state() const { return last_button_state; } -void DisplayServerOSX::clipboard_set(const String &p_text) { +void DisplayServerMacOS::clipboard_set(const String &p_text) { _THREAD_SAFE_METHOD_ NSString *copiedString = [NSString stringWithUTF8String:p_text.utf8().get_data()]; @@ -1743,7 +1743,7 @@ void DisplayServerOSX::clipboard_set(const String &p_text) { [pasteboard writeObjects:copiedStringArray]; } -String DisplayServerOSX::clipboard_get() const { +String DisplayServerMacOS::clipboard_get() const { _THREAD_SAFE_METHOD_ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; @@ -1764,14 +1764,14 @@ String DisplayServerOSX::clipboard_get() const { return ret; } -int DisplayServerOSX::get_screen_count() const { +int DisplayServerMacOS::get_screen_count() const { _THREAD_SAFE_METHOD_ NSArray *screenArray = [NSScreen screens]; return [screenArray count]; } -Point2i DisplayServerOSX::screen_get_position(int p_screen) const { +Point2i DisplayServerMacOS::screen_get_position(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1785,7 +1785,7 @@ Point2i DisplayServerOSX::screen_get_position(int p_screen) const { return position; } -Size2i DisplayServerOSX::screen_get_size(int p_screen) const { +Size2i DisplayServerMacOS::screen_get_size(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1802,7 +1802,7 @@ Size2i DisplayServerOSX::screen_get_size(int p_screen) const { return Size2i(); } -int DisplayServerOSX::screen_get_dpi(int p_screen) const { +int DisplayServerMacOS::screen_get_dpi(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1826,7 +1826,7 @@ int DisplayServerOSX::screen_get_dpi(int p_screen) const { return 72; } -float DisplayServerOSX::screen_get_scale(int p_screen) const { +float DisplayServerMacOS::screen_get_scale(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1844,14 +1844,14 @@ float DisplayServerOSX::screen_get_scale(int p_screen) const { return 1.f; } -float DisplayServerOSX::screen_get_max_scale() const { +float DisplayServerMacOS::screen_get_max_scale() const { _THREAD_SAFE_METHOD_ // Note: Do not update max display scale on screen configuration change, existing editor windows can't be rescaled on the fly. return display_max_scale; } -Rect2i DisplayServerOSX::screen_get_usable_rect(int p_screen) const { +Rect2i DisplayServerMacOS::screen_get_usable_rect(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1873,7 +1873,7 @@ Rect2i DisplayServerOSX::screen_get_usable_rect(int p_screen) const { return Rect2i(); } -float DisplayServerOSX::screen_get_refresh_rate(int p_screen) const { +float DisplayServerMacOS::screen_get_refresh_rate(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -1891,7 +1891,7 @@ float DisplayServerOSX::screen_get_refresh_rate(int p_screen) const { return SCREEN_REFRESH_RATE_FALLBACK; } -Vector<DisplayServer::WindowID> DisplayServerOSX::get_window_list() const { +Vector<DisplayServer::WindowID> DisplayServerMacOS::get_window_list() const { _THREAD_SAFE_METHOD_ Vector<int> ret; @@ -1901,7 +1901,7 @@ Vector<DisplayServer::WindowID> DisplayServerOSX::get_window_list() const { return ret; } -DisplayServer::WindowID DisplayServerOSX::create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect) { +DisplayServer::WindowID DisplayServerMacOS::create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect) { _THREAD_SAFE_METHOD_ WindowID id = _create_window(p_mode, p_vsync_mode, p_rect); @@ -1914,7 +1914,7 @@ DisplayServer::WindowID DisplayServerOSX::create_sub_window(WindowMode p_mode, V return id; } -void DisplayServerOSX::show_window(WindowID p_id) { +void DisplayServerMacOS::show_window(WindowID p_id) { WindowData &wd = windows[p_id]; popup_open(p_id); @@ -1925,7 +1925,7 @@ void DisplayServerOSX::show_window(WindowID p_id) { } } -void DisplayServerOSX::delete_sub_window(WindowID p_id) { +void DisplayServerMacOS::delete_sub_window(WindowID p_id) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_id)); @@ -1937,7 +1937,7 @@ void DisplayServerOSX::delete_sub_window(WindowID p_id) { [wd.window_object close]; } -void DisplayServerOSX::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerMacOS::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -1945,7 +1945,7 @@ void DisplayServerOSX::window_set_rect_changed_callback(const Callable &p_callab wd.rect_changed_callback = p_callable; } -void DisplayServerOSX::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerMacOS::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -1953,7 +1953,7 @@ void DisplayServerOSX::window_set_window_event_callback(const Callable &p_callab wd.event_callback = p_callable; } -void DisplayServerOSX::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerMacOS::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -1961,21 +1961,21 @@ void DisplayServerOSX::window_set_input_event_callback(const Callable &p_callabl wd.input_event_callback = p_callable; } -void DisplayServerOSX::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerMacOS::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; wd.input_text_callback = p_callable; } -void DisplayServerOSX::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerMacOS::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; wd.drop_files_callback = p_callable; } -void DisplayServerOSX::window_set_title(const String &p_title, WindowID p_window) { +void DisplayServerMacOS::window_set_title(const String &p_title, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -1984,7 +1984,7 @@ void DisplayServerOSX::window_set_title(const String &p_title, WindowID p_window [wd.window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]]; } -void DisplayServerOSX::window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window) { +void DisplayServerMacOS::window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -1993,7 +1993,7 @@ void DisplayServerOSX::window_set_mouse_passthrough(const Vector<Vector2> &p_reg wd.mpath = p_region; } -int DisplayServerOSX::window_get_current_screen(WindowID p_window) const { +int DisplayServerMacOS::window_get_current_screen(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), -1); const WindowData &wd = windows[p_window]; @@ -2002,12 +2002,16 @@ int DisplayServerOSX::window_get_current_screen(WindowID p_window) const { return (index == NSNotFound) ? 0 : index; } -void DisplayServerOSX::window_set_current_screen(int p_screen, WindowID p_window) { +void DisplayServerMacOS::window_set_current_screen(int p_screen, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; + if (window_get_current_screen(p_window) == p_screen) { + return; + } + bool was_fullscreen = false; if (wd.fullscreen) { // Temporary exit fullscreen mode to move window. @@ -2024,7 +2028,7 @@ void DisplayServerOSX::window_set_current_screen(int p_screen, WindowID p_window } } -void DisplayServerOSX::window_set_exclusive(WindowID p_window, bool p_exclusive) { +void DisplayServerMacOS::window_set_exclusive(WindowID p_window, bool p_exclusive) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; @@ -2042,7 +2046,7 @@ void DisplayServerOSX::window_set_exclusive(WindowID p_window, bool p_exclusive) } } -Point2i DisplayServerOSX::window_get_position(WindowID p_window) const { +Point2i DisplayServerMacOS::window_get_position(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Point2i()); @@ -2065,7 +2069,7 @@ Point2i DisplayServerOSX::window_get_position(WindowID p_window) const { return pos; } -void DisplayServerOSX::window_set_position(const Point2i &p_position, WindowID p_window) { +void DisplayServerMacOS::window_set_position(const Point2i &p_position, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2093,7 +2097,7 @@ void DisplayServerOSX::window_set_position(const Point2i &p_position, WindowID p update_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]); } -void DisplayServerOSX::window_set_transient(WindowID p_window, WindowID p_parent) { +void DisplayServerMacOS::window_set_transient(WindowID p_window, WindowID p_parent) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(p_window == p_parent); @@ -2132,7 +2136,7 @@ void DisplayServerOSX::window_set_transient(WindowID p_window, WindowID p_parent } } -void DisplayServerOSX::window_set_max_size(const Size2i p_size, WindowID p_window) { +void DisplayServerMacOS::window_set_max_size(const Size2i p_size, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2152,7 +2156,7 @@ void DisplayServerOSX::window_set_max_size(const Size2i p_size, WindowID p_windo } } -Size2i DisplayServerOSX::window_get_max_size(WindowID p_window) const { +Size2i DisplayServerMacOS::window_get_max_size(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Size2i()); @@ -2160,7 +2164,7 @@ Size2i DisplayServerOSX::window_get_max_size(WindowID p_window) const { return wd.max_size; } -void DisplayServerOSX::window_set_min_size(const Size2i p_size, WindowID p_window) { +void DisplayServerMacOS::window_set_min_size(const Size2i p_size, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2180,7 +2184,7 @@ void DisplayServerOSX::window_set_min_size(const Size2i p_size, WindowID p_windo } } -Size2i DisplayServerOSX::window_get_min_size(WindowID p_window) const { +Size2i DisplayServerMacOS::window_get_min_size(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Size2i()); @@ -2189,7 +2193,7 @@ Size2i DisplayServerOSX::window_get_min_size(WindowID p_window) const { return wd.min_size; } -void DisplayServerOSX::window_set_size(const Size2i p_size, WindowID p_window) { +void DisplayServerMacOS::window_set_size(const Size2i p_size, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2213,7 +2217,7 @@ void DisplayServerOSX::window_set_size(const Size2i p_size, WindowID p_window) { _update_window_style(wd); } -Size2i DisplayServerOSX::window_get_size(WindowID p_window) const { +Size2i DisplayServerMacOS::window_get_size(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Size2i()); @@ -2221,7 +2225,7 @@ Size2i DisplayServerOSX::window_get_size(WindowID p_window) const { return wd.size; } -Size2i DisplayServerOSX::window_get_real_size(WindowID p_window) const { +Size2i DisplayServerMacOS::window_get_real_size(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Size2i()); @@ -2230,7 +2234,7 @@ Size2i DisplayServerOSX::window_get_real_size(WindowID p_window) const { return Size2i(frame.size.width, frame.size.height) * screen_get_max_scale(); } -void DisplayServerOSX::window_set_mode(WindowMode p_mode, WindowID p_window) { +void DisplayServerMacOS::window_set_mode(WindowMode p_mode, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2299,7 +2303,7 @@ void DisplayServerOSX::window_set_mode(WindowMode p_mode, WindowID p_window) { } } -DisplayServer::WindowMode DisplayServerOSX::window_get_mode(WindowID p_window) const { +DisplayServer::WindowMode DisplayServerMacOS::window_get_mode(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED); @@ -2321,11 +2325,11 @@ DisplayServer::WindowMode DisplayServerOSX::window_get_mode(WindowID p_window) c return WINDOW_MODE_WINDOWED; } -bool DisplayServerOSX::window_is_maximize_allowed(WindowID p_window) const { +bool DisplayServerMacOS::window_is_maximize_allowed(WindowID p_window) const { return true; } -void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) { +void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2400,7 +2404,7 @@ void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo } } -bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) const { +bool DisplayServerMacOS::window_get_flag(WindowFlags p_flag, WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), false); @@ -2436,12 +2440,12 @@ bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) co return false; } -void DisplayServerOSX::window_request_attention(WindowID p_window) { +void DisplayServerMacOS::window_request_attention(WindowID p_window) { // It's app global, ignore window id. [NSApp requestUserAttention:NSCriticalRequest]; } -void DisplayServerOSX::window_move_to_foreground(WindowID p_window) { +void DisplayServerMacOS::window_move_to_foreground(WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2455,11 +2459,11 @@ void DisplayServerOSX::window_move_to_foreground(WindowID p_window) { } } -bool DisplayServerOSX::window_can_draw(WindowID p_window) const { +bool DisplayServerMacOS::window_can_draw(WindowID p_window) const { return window_get_mode(p_window) != WINDOW_MODE_MINIMIZED; } -bool DisplayServerOSX::can_any_window_draw() const { +bool DisplayServerMacOS::can_any_window_draw() const { _THREAD_SAFE_METHOD_ for (const KeyValue<WindowID, WindowData> &E : windows) { @@ -2470,7 +2474,7 @@ bool DisplayServerOSX::can_any_window_draw() const { return false; } -void DisplayServerOSX::window_set_ime_active(const bool p_active, WindowID p_window) { +void DisplayServerMacOS::window_set_ime_active(const bool p_active, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2483,7 +2487,7 @@ void DisplayServerOSX::window_set_ime_active(const bool p_active, WindowID p_win } } -void DisplayServerOSX::window_set_ime_position(const Point2i &p_pos, WindowID p_window) { +void DisplayServerMacOS::window_set_ime_position(const Point2i &p_pos, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -2492,7 +2496,7 @@ void DisplayServerOSX::window_set_ime_position(const Point2i &p_pos, WindowID p_ wd.im_position = p_pos; } -DisplayServer::WindowID DisplayServerOSX::get_window_at_screen_position(const Point2i &p_position) const { +DisplayServer::WindowID DisplayServerMacOS::get_window_at_screen_position(const Point2i &p_position) const { Point2i position = p_position; position.y *= -1; position += _get_screens_origin(); @@ -2507,7 +2511,7 @@ DisplayServer::WindowID DisplayServerOSX::get_window_at_screen_position(const Po return INVALID_WINDOW_ID; } -int64_t DisplayServerOSX::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const { +int64_t DisplayServerMacOS::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const { ERR_FAIL_COND_V(!windows.has(p_window), 0); switch (p_handle_type) { case DISPLAY_HANDLE: { @@ -2525,27 +2529,27 @@ int64_t DisplayServerOSX::window_get_native_handle(HandleType p_handle_type, Win } } -void DisplayServerOSX::window_attach_instance_id(ObjectID p_instance, WindowID p_window) { +void DisplayServerMacOS::window_attach_instance_id(ObjectID p_instance, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); windows[p_window].instance_id = p_instance; } -ObjectID DisplayServerOSX::window_get_attached_instance_id(WindowID p_window) const { +ObjectID DisplayServerMacOS::window_get_attached_instance_id(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), ObjectID()); return windows[p_window].instance_id; } -void DisplayServerOSX::gl_window_make_current(DisplayServer::WindowID p_window_id) { +void DisplayServerMacOS::gl_window_make_current(DisplayServer::WindowID p_window_id) { #if defined(GLES3_ENABLED) gl_manager->window_make_current(p_window_id); #endif } -void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { +void DisplayServerMacOS::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { _THREAD_SAFE_METHOD_ #if defined(GLES3_ENABLED) if (gl_manager) { @@ -2559,7 +2563,7 @@ void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo #endif } -DisplayServer::VSyncMode DisplayServerOSX::window_get_vsync_mode(WindowID p_window) const { +DisplayServer::VSyncMode DisplayServerMacOS::window_get_vsync_mode(WindowID p_window) const { _THREAD_SAFE_METHOD_ #if defined(GLES3_ENABLED) if (gl_manager) { @@ -2574,15 +2578,15 @@ DisplayServer::VSyncMode DisplayServerOSX::window_get_vsync_mode(WindowID p_wind return DisplayServer::VSYNC_ENABLED; } -Point2i DisplayServerOSX::ime_get_selection() const { +Point2i DisplayServerMacOS::ime_get_selection() const { return im_selection; } -String DisplayServerOSX::ime_get_text() const { +String DisplayServerMacOS::ime_get_text() const { return im_text; } -void DisplayServerOSX::cursor_update_shape() { +void DisplayServerMacOS::cursor_update_shape() { _THREAD_SAFE_METHOD_ if (cursors[cursor_shape] != nullptr) { @@ -2646,7 +2650,7 @@ void DisplayServerOSX::cursor_update_shape() { } } -void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) { +void DisplayServerMacOS::cursor_set_shape(CursorShape p_shape) { _THREAD_SAFE_METHOD_ ERR_FAIL_INDEX(p_shape, CURSOR_MAX); @@ -2664,11 +2668,11 @@ void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) { cursor_update_shape(); } -DisplayServerOSX::CursorShape DisplayServerOSX::cursor_get_shape() const { +DisplayServerMacOS::CursorShape DisplayServerMacOS::cursor_get_shape() const { return cursor_shape; } -void DisplayServerOSX::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { +void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { _THREAD_SAFE_METHOD_ if (p_cursor.is_valid()) { @@ -2780,20 +2784,20 @@ void DisplayServerOSX::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu } } -bool DisplayServerOSX::get_swap_cancel_ok() { +bool DisplayServerMacOS::get_swap_cancel_ok() { return false; } -int DisplayServerOSX::keyboard_get_layout_count() const { +int DisplayServerMacOS::keyboard_get_layout_count() const { if (keyboard_layout_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_keyboard_layouts(); + const_cast<DisplayServerMacOS *>(this)->_update_keyboard_layouts(); } return kbd_layouts.size(); } -void DisplayServerOSX::keyboard_set_current_layout(int p_index) { +void DisplayServerMacOS::keyboard_set_current_layout(int p_index) { if (keyboard_layout_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_keyboard_layouts(); + const_cast<DisplayServerMacOS *>(this)->_update_keyboard_layouts(); } ERR_FAIL_INDEX(p_index, kbd_layouts.size()); @@ -2821,44 +2825,44 @@ void DisplayServerOSX::keyboard_set_current_layout(int p_index) { } } -int DisplayServerOSX::keyboard_get_current_layout() const { +int DisplayServerMacOS::keyboard_get_current_layout() const { if (keyboard_layout_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_keyboard_layouts(); + const_cast<DisplayServerMacOS *>(this)->_update_keyboard_layouts(); } return current_layout; } -String DisplayServerOSX::keyboard_get_layout_language(int p_index) const { +String DisplayServerMacOS::keyboard_get_layout_language(int p_index) const { if (keyboard_layout_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_keyboard_layouts(); + const_cast<DisplayServerMacOS *>(this)->_update_keyboard_layouts(); } ERR_FAIL_INDEX_V(p_index, kbd_layouts.size(), ""); return kbd_layouts[p_index].code; } -String DisplayServerOSX::keyboard_get_layout_name(int p_index) const { +String DisplayServerMacOS::keyboard_get_layout_name(int p_index) const { if (keyboard_layout_dirty) { - const_cast<DisplayServerOSX *>(this)->_update_keyboard_layouts(); + const_cast<DisplayServerMacOS *>(this)->_update_keyboard_layouts(); } ERR_FAIL_INDEX_V(p_index, kbd_layouts.size(), ""); return kbd_layouts[p_index].name; } -Key DisplayServerOSX::keyboard_get_keycode_from_physical(Key p_keycode) const { +Key DisplayServerMacOS::keyboard_get_keycode_from_physical(Key p_keycode) const { if (p_keycode == Key::PAUSE) { return p_keycode; } Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK; Key keycode_no_mod = p_keycode & KeyModifierMask::CODE_MASK; - unsigned int osx_keycode = KeyMappingOSX::unmap_key((Key)keycode_no_mod); - return (Key)(KeyMappingOSX::remap_key(osx_keycode, 0) | modifiers); + unsigned int macos_keycode = KeyMappingMacOS::unmap_key((Key)keycode_no_mod); + return (Key)(KeyMappingMacOS::remap_key(macos_keycode, 0) | modifiers); } -void DisplayServerOSX::process_events() { +void DisplayServerMacOS::process_events() { _THREAD_SAFE_METHOD_ while (true) { @@ -2901,7 +2905,7 @@ void DisplayServerOSX::process_events() { } } -void DisplayServerOSX::force_process_and_drop_events() { +void DisplayServerMacOS::force_process_and_drop_events() { _THREAD_SAFE_METHOD_ drop_events = true; @@ -2909,13 +2913,13 @@ void DisplayServerOSX::force_process_and_drop_events() { drop_events = false; } -void DisplayServerOSX::release_rendering_thread() { +void DisplayServerMacOS::release_rendering_thread() { } -void DisplayServerOSX::make_rendering_thread() { +void DisplayServerMacOS::make_rendering_thread() { } -void DisplayServerOSX::swap_buffers() { +void DisplayServerMacOS::swap_buffers() { #if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->swap_buffers(); @@ -2923,7 +2927,7 @@ void DisplayServerOSX::swap_buffers() { #endif } -void DisplayServerOSX::set_native_icon(const String &p_filename) { +void DisplayServerMacOS::set_native_icon(const String &p_filename) { _THREAD_SAFE_METHOD_ Ref<FileAccess> f = FileAccess::open(p_filename, FileAccess::READ); @@ -2943,7 +2947,7 @@ void DisplayServerOSX::set_native_icon(const String &p_filename) { [NSApp setApplicationIconImage:icon]; } -void DisplayServerOSX::set_icon(const Ref<Image> &p_icon) { +void DisplayServerMacOS::set_icon(const Ref<Image> &p_icon) { _THREAD_SAFE_METHOD_ Ref<Image> img = p_icon; @@ -2982,15 +2986,15 @@ void DisplayServerOSX::set_icon(const Ref<Image> &p_icon) { [NSApp setApplicationIconImage:nsimg]; } -DisplayServer *DisplayServerOSX::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { - DisplayServer *ds = memnew(DisplayServerOSX(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); +DisplayServer *DisplayServerMacOS::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { + DisplayServer *ds = memnew(DisplayServerMacOS(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan or OpenGL versions.", "Unable to initialize Video driver"); } return ds; } -Vector<String> DisplayServerOSX::get_rendering_drivers_func() { +Vector<String> DisplayServerMacOS::get_rendering_drivers_func() { Vector<String> drivers; #if defined(VULKAN_ENABLED) @@ -3003,11 +3007,11 @@ Vector<String> DisplayServerOSX::get_rendering_drivers_func() { return drivers; } -void DisplayServerOSX::register_osx_driver() { - register_create_function("osx", create_func, get_rendering_drivers_func); +void DisplayServerMacOS::register_macos_driver() { + register_create_function("macos", create_func, get_rendering_drivers_func); } -DisplayServer::WindowID DisplayServerOSX::window_get_active_popup() const { +DisplayServer::WindowID DisplayServerMacOS::window_get_active_popup() const { const List<WindowID>::Element *E = popup_list.back(); if (E) { return E->get(); @@ -3016,7 +3020,7 @@ DisplayServer::WindowID DisplayServerOSX::window_get_active_popup() const { } } -void DisplayServerOSX::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) { +void DisplayServerMacOS::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); @@ -3024,7 +3028,7 @@ void DisplayServerOSX::window_set_popup_safe_rect(WindowID p_window, const Rect2 wd.parent_safe_rect = p_rect; } -Rect2i DisplayServerOSX::window_get_popup_safe_rect(WindowID p_window) const { +Rect2i DisplayServerMacOS::window_get_popup_safe_rect(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), Rect2i()); @@ -3032,7 +3036,7 @@ Rect2i DisplayServerOSX::window_get_popup_safe_rect(WindowID p_window) const { return wd.parent_safe_rect; } -void DisplayServerOSX::popup_open(WindowID p_window) { +void DisplayServerMacOS::popup_open(WindowID p_window) { _THREAD_SAFE_METHOD_ WindowData &wd = windows[p_window]; @@ -3050,7 +3054,7 @@ void DisplayServerOSX::popup_open(WindowID p_window) { } } if (C) { - send_window_event(windows[C->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + send_window_event(windows[C->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); } if (was_empty && popup_list.is_empty()) { @@ -3062,7 +3066,7 @@ void DisplayServerOSX::popup_open(WindowID p_window) { } } -void DisplayServerOSX::popup_close(WindowID p_window) { +void DisplayServerMacOS::popup_close(WindowID p_window) { _THREAD_SAFE_METHOD_ bool was_empty = popup_list.is_empty(); @@ -3072,7 +3076,7 @@ void DisplayServerOSX::popup_close(WindowID p_window) { WindowID win_id = E->get(); popup_list.erase(E); - send_window_event(windows[win_id], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + send_window_event(windows[win_id], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); E = F; } if (!was_empty && popup_list.is_empty()) { @@ -3081,7 +3085,7 @@ void DisplayServerOSX::popup_close(WindowID p_window) { } } -bool DisplayServerOSX::mouse_process_popups(bool p_close) { +bool DisplayServerMacOS::mouse_process_popups(bool p_close) { _THREAD_SAFE_METHOD_ bool was_empty = popup_list.is_empty(); @@ -3090,7 +3094,7 @@ bool DisplayServerOSX::mouse_process_popups(bool p_close) { // Close all popups. List<WindowID>::Element *E = popup_list.front(); if (E) { - send_window_event(windows[E->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + send_window_event(windows[E->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); closed = true; } if (!was_empty) { @@ -3122,7 +3126,7 @@ bool DisplayServerOSX::mouse_process_popups(bool p_close) { } } if (C) { - send_window_event(windows[C->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + send_window_event(windows[C->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); closed = true; } if (!was_empty && popup_list.is_empty()) { @@ -3133,7 +3137,7 @@ bool DisplayServerOSX::mouse_process_popups(bool p_close) { return closed; } -DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { +DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events); r_error = OK; @@ -3160,7 +3164,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode CGDisplayRegisterReconfigurationCallback(_displays_arrangement_changed, nullptr); // Init TTS - tts = [[TTS_OSX alloc] init]; + tts = [[TTS_MacOS alloc] init]; NSMenuItem *menu_item; NSString *title; @@ -3214,8 +3218,8 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode #if defined(GLES3_ENABLED) if (rendering_driver == "opengl3") { - GLManager_OSX::ContextType opengl_api_type = GLManager_OSX::GLES_3_0_COMPATIBLE; - gl_manager = memnew(GLManager_OSX(opengl_api_type)); + GLManager_MacOS::ContextType opengl_api_type = GLManager_MacOS::GLES_3_0_COMPATIBLE; + gl_manager = memnew(GLManager_MacOS(opengl_api_type)); if (gl_manager->initialize() != OK) { memdelete(gl_manager); gl_manager = nullptr; @@ -3227,7 +3231,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode #endif #if defined(VULKAN_ENABLED) if (rendering_driver == "vulkan") { - context_vulkan = memnew(VulkanContextOSX); + context_vulkan = memnew(VulkanContextMacOS); if (context_vulkan->initialize() != OK) { memdelete(context_vulkan); context_vulkan = nullptr; @@ -3264,7 +3268,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode #endif } -DisplayServerOSX::~DisplayServerOSX() { +DisplayServerMacOS::~DisplayServerMacOS() { // Destroy all windows. for (HashMap<WindowID, WindowData>::Iterator E = windows.begin(); E;) { HashMap<WindowID, WindowData>::Iterator F = E; diff --git a/platform/osx/export/codesign.cpp b/platform/macos/export/codesign.cpp index fd044c00cc..fd044c00cc 100644 --- a/platform/osx/export/codesign.cpp +++ b/platform/macos/export/codesign.cpp diff --git a/platform/osx/export/codesign.h b/platform/macos/export/codesign.h index 3a08c0ea86..3a08c0ea86 100644 --- a/platform/osx/export/codesign.h +++ b/platform/macos/export/codesign.h diff --git a/platform/osx/export/export.cpp b/platform/macos/export/export.cpp index bd35b39e9e..ff7457081f 100644 --- a/platform/osx/export/export.cpp +++ b/platform/macos/export/export.cpp @@ -32,11 +32,11 @@ #include "export_plugin.h" -void register_osx_exporter() { +void register_macos_exporter() { EDITOR_DEF("export/macos/force_builtin_codesign", false); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::BOOL, "export/macos/force_builtin_codesign", PROPERTY_HINT_NONE)); - Ref<EditorExportPlatformOSX> platform; + Ref<EditorExportPlatformMacOS> platform; platform.instantiate(); EditorExport::get_singleton()->add_export_platform(platform); diff --git a/platform/iphone/export/export.h b/platform/macos/export/export.h index adb3c23957..260c691209 100644 --- a/platform/iphone/export/export.h +++ b/platform/macos/export/export.h @@ -28,9 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IPHONE_EXPORT_H -#define IPHONE_EXPORT_H +#ifndef MACOS_EXPORT_H +#define MACOS_EXPORT_H -void register_iphone_exporter(); +void register_macos_exporter(); -#endif // IPHONE_EXPORT_H +#endif // MACOS_EXPORT_H diff --git a/platform/osx/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index a22d7e5e3d..8cb69997d9 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -37,7 +37,7 @@ #include "modules/modules_enabled.gen.h" // For regex. -void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { +void EditorExportPlatformMacOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { if (p_preset->get("texture_format/s3tc")) { r_features->push_back("s3tc"); } @@ -51,7 +51,7 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> r_features->push_back("64"); } -bool EditorExportPlatformOSX::get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { +bool EditorExportPlatformMacOS::get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { // These options are not supported by built-in codesign, used on non macOS host. if (!OS::get_singleton()->has_feature("macos")) { if (p_option == "codesign/identity" || p_option == "codesign/timestamp" || p_option == "codesign/hardened_runtime" || p_option == "codesign/custom_options" || p_option.begins_with("notarization/")) { @@ -68,7 +68,7 @@ bool EditorExportPlatformOSX::get_export_option_visibility(const String &p_optio return true; } -void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) { +void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options) { r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); @@ -214,7 +214,7 @@ void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source, memcpy(&p_dest.write[ofs], result.ptr(), res_size); } -void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) { +void EditorExportPlatformMacOS::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) { Ref<ImageTexture> it = memnew(ImageTexture); Vector<uint8_t> data; @@ -320,7 +320,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ p_data = data; } -void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) { +void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) { String str; String strnew; str.parse_utf8((const char *)plist.ptr(), plist.size()); @@ -407,14 +407,14 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset } /** - * If we're running the OSX version of the Godot editor we'll: + * If we're running the macOS version of the Godot editor we'll: * - export our application bundle to a temporary folder * - attempt to code sign it * - and then wrap it up in a DMG */ -Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path) { -#ifdef OSX_ENABLED +Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path) { +#ifdef MACOS_ENABLED List<String> args; args.push_back("altool"); @@ -468,7 +468,7 @@ Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset return OK; } -Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn) { +Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn) { bool force_builtin_codesign = EditorSettings::get_singleton()->get("export/macos/force_builtin_codesign"); bool ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-"); @@ -476,7 +476,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese print_verbose("using built-in codesign..."); #ifdef MODULE_REGEX_ENABLED -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED if (p_preset->get("codesign/timestamp") && p_warn) { add_message(EXPORT_MESSAGE_INFO, TTR("Code Signing"), TTR("Timestamping is not compatible with ad-hoc signature, and was disabled!")); } @@ -566,9 +566,9 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese } } -Error EditorExportPlatformOSX::_code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, +Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_should_error_on_non_code) { -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED static Vector<String> extensions_to_sign; if (extensions_to_sign.is_empty()) { @@ -615,7 +615,7 @@ Error EditorExportPlatformOSX::_code_sign_directory(const Ref<EditorExportPreset return OK; } -Error EditorExportPlatformOSX::_copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, +Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path, bool p_should_error_on_non_code_sign) { @@ -644,14 +644,14 @@ Error EditorExportPlatformOSX::_copy_and_sign_files(Ref<DirAccess> &dir_access, return err; } -Error EditorExportPlatformOSX::_export_osx_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, +Error EditorExportPlatformMacOS::_export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name, Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path) { Error error{ OK }; - const Vector<String> &osx_plugins{ p_editor_export_plugin->get_osx_plugin_files() }; - for (int i = 0; i < osx_plugins.size(); ++i) { - String src_path{ ProjectSettings::get_singleton()->globalize_path(osx_plugins[i]) }; + const Vector<String> &macos_plugins{ p_editor_export_plugin->get_macos_plugin_files() }; + for (int i = 0; i < macos_plugins.size(); ++i) { + String src_path{ ProjectSettings::get_singleton()->globalize_path(macos_plugins[i]) }; String path_in_app{ p_app_path_name + "/Contents/PlugIns/" + src_path.get_file() }; error = _copy_and_sign_files(dir_access, src_path, path_in_app, p_sign_enabled, p_preset, p_ent_path, false); if (error != OK) { @@ -661,7 +661,7 @@ Error EditorExportPlatformOSX::_export_osx_plugins_for(Ref<EditorExportPlugin> p return error; } -Error EditorExportPlatformOSX::_create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name) { +Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name) { List<String> args; if (FileAccess::exists(p_dmg_path)) { @@ -697,7 +697,7 @@ Error EditorExportPlatformOSX::_create_dmg(const String &p_dmg_path, const Strin return OK; } -Error EditorExportPlatformOSX::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) { +Error EditorExportPlatformMacOS::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) { Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE); if (f.is_null()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), vformat(TTR("Could not open file \"%s\"."), p_path)); @@ -706,19 +706,30 @@ Error EditorExportPlatformOSX::_export_debug_script(const Ref<EditorExportPreset f->store_line("#!/bin/sh"); f->store_line("echo -ne '\\033c\\033]0;" + p_app_name + "\\a'"); - f->store_line("function realpath() { python -c \"import os,sys; print(os.path.realpath(sys.argv[1]))\" \"$0\"; }"); - f->store_line("base_path=\"$(dirname \"$(realpath \"$0\")\")\""); - f->store_line("\"$base_path/" + p_pkg_name + "\" \"$@\""); + f->store_line(""); + f->store_line("function app_realpath() {"); + f->store_line(" SOURCE=$1"); + f->store_line(" while [ -h \"$SOURCE\" ]; do"); + f->store_line(" DIR=$(dirname \"$SOURCE\")"); + f->store_line(" SOURCE=$(readlink \"$SOURCE\")"); + f->store_line(" [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE"); + f->store_line(" done"); + f->store_line(" echo \"$( cd -P \"$( dirname \"$SOURCE\" )\" >/dev/null 2>&1 && pwd )\""); + f->store_line("}"); + f->store_line(""); + f->store_line("BASE_PATH=\"$(app_realpath \"${BASH_SOURCE[0]}\")\""); + f->store_line("\"$BASE_PATH/" + p_pkg_name + "\" \"$@\""); + f->store_line(""); return OK; } -Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { +Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); String src_pkg_name; - EditorProgress ep("export", "Exporting for OSX", 3, true); + EditorProgress ep("export", "Exporting for macOS", 3, true); if (p_debug) { src_pkg_name = p_preset->get("custom_template/debug"); @@ -728,7 +739,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (src_pkg_name.is_empty()) { String err; - src_pkg_name = find_export_template("osx.zip", &err); + src_pkg_name = find_export_template("macos.zip", &err); if (src_pkg_name.is_empty()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("Export template not found.")); return ERR_FILE_NOT_FOUND; @@ -755,7 +766,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p int ret = unzGoToFirstFile(src_pkg_zip); - String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".64"; + String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + ".64"; String pkg_name; if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") { @@ -984,7 +995,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p unzCloseCurrentFile(src_pkg_zip); // Write. - file = file.replace_first("osx_template.app/", ""); + file = file.replace_first("macos_template.app/", ""); if (((info.external_fa >> 16L) & 0120000) == 0120000) { #ifndef UNIX_ENABLED @@ -1053,19 +1064,19 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } if (data.size() > 0) { - if (file.find("/data.mono.osx.64.release_debug/") != -1) { + if (file.find("/data.mono.macos.64.release_debug/") != -1) { if (!p_debug) { ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release_debug/", "/GodotSharp/"); + file = file.replace("/data.mono.macos.64.release_debug/", "/GodotSharp/"); } - if (file.find("/data.mono.osx.64.release/") != -1) { + if (file.find("/data.mono.macos.64.release/") != -1) { if (p_debug) { ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release/", "/GodotSharp/"); + file = file.replace("/data.mono.macos.64.release/", "/GodotSharp/"); } if (file.ends_with(".dylib")) { @@ -1299,7 +1310,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p bool ad_hoc = true; if (err == OK) { -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED String sign_identity = p_preset->get("codesign/identity"); #else String sign_identity = "-"; @@ -1330,7 +1341,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p Vector<Ref<EditorExportPlugin>> export_plugins{ EditorExport::get_singleton()->get_export_plugins() }; for (int i = 0; i < export_plugins.size(); ++i) { - err = _export_osx_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path); + err = _export_macos_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path); if (err != OK) { break; } @@ -1387,7 +1398,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } } -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED bool noto_enabled = p_preset->get("notarization/enable"); if (err == OK && noto_enabled) { if (export_format == "app") { @@ -1420,7 +1431,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p return err; } -void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) { +void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) { String dir = p_folder.is_empty() ? p_root_path : p_root_path.plus_file(p_folder); Ref<DirAccess> da = DirAccess::open(dir); @@ -1537,7 +1548,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String da->list_dir_end(); } -bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { +bool EditorExportPlatformMacOS::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { String err; bool valid = false; @@ -1560,7 +1571,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset // Look for export templates (official templates, check only is custom templates are not set). if (!dvalid || !rvalid) { - dvalid = exists_export_template("osx.zip", &err); + dvalid = exists_export_template("macos.zip", &err); rvalid = dvalid; // Both in the same ZIP. } @@ -1576,7 +1587,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset bool sign_enabled = p_preset->get("codesign/enable"); -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED bool noto_enabled = p_preset->get("notarization/enable"); bool ad_hoc = ((p_preset->get("codesign/identity") == "") || (p_preset->get("codesign/identity") == "-")); @@ -1665,9 +1676,9 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset return valid; } -EditorExportPlatformOSX::EditorExportPlatformOSX() { - logo = ImageTexture::create_from_image(memnew(Image(_osx_logo))); +EditorExportPlatformMacOS::EditorExportPlatformMacOS() { + logo = ImageTexture::create_from_image(memnew(Image(_macos_logo))); } -EditorExportPlatformOSX::~EditorExportPlatformOSX() { +EditorExportPlatformMacOS::~EditorExportPlatformMacOS() { } diff --git a/platform/osx/export/export_plugin.h b/platform/macos/export/export_plugin.h index ec97d4139f..410ec22545 100644 --- a/platform/osx/export/export_plugin.h +++ b/platform/macos/export/export_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OSX_EXPORT_PLUGIN_H -#define OSX_EXPORT_PLUGIN_H +#ifndef MACOS_EXPORT_PLUGIN_H +#define MACOS_EXPORT_PLUGIN_H #include "core/config/project_settings.h" #include "core/io/dir_access.h" @@ -41,12 +41,12 @@ #include "core/version.h" #include "editor/editor_export.h" #include "editor/editor_settings.h" -#include "platform/osx/logo.gen.h" +#include "platform/macos/logo.gen.h" #include <sys/stat.h> -class EditorExportPlatformOSX : public EditorExportPlatform { - GDCLASS(EditorExportPlatformOSX, EditorExportPlatform); +class EditorExportPlatformMacOS : public EditorExportPlatform { + GDCLASS(EditorExportPlatformMacOS, EditorExportPlatform); int version_code = 0; @@ -61,7 +61,7 @@ class EditorExportPlatformOSX : public EditorExportPlatform { Error _copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path, const String &p_in_app_path, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path, bool p_should_error_on_non_code_sign); - Error _export_osx_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name, + Error _export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin, const String &p_app_path_name, Ref<DirAccess> &dir_access, bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset, const String &p_ent_path); Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name); @@ -69,7 +69,7 @@ class EditorExportPlatformOSX : public EditorExportPlatform { Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path); bool use_codesign() const { return true; } -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED bool use_dmg() const { return true; } #else bool use_dmg() const { return false; } @@ -130,8 +130,8 @@ public: virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override { } - EditorExportPlatformOSX(); - ~EditorExportPlatformOSX(); + EditorExportPlatformMacOS(); + ~EditorExportPlatformMacOS(); }; #endif diff --git a/platform/osx/export/lipo.cpp b/platform/macos/export/lipo.cpp index 82baf18c52..82baf18c52 100644 --- a/platform/osx/export/lipo.cpp +++ b/platform/macos/export/lipo.cpp diff --git a/platform/osx/export/lipo.h b/platform/macos/export/lipo.h index 0e419be17e..0e419be17e 100644 --- a/platform/osx/export/lipo.h +++ b/platform/macos/export/lipo.h diff --git a/platform/osx/export/macho.cpp b/platform/macos/export/macho.cpp index e6e67eff06..e6e67eff06 100644 --- a/platform/osx/export/macho.cpp +++ b/platform/macos/export/macho.cpp diff --git a/platform/osx/export/macho.h b/platform/macos/export/macho.h index 6cfc3c44f5..6cfc3c44f5 100644 --- a/platform/osx/export/macho.h +++ b/platform/macos/export/macho.h diff --git a/platform/osx/export/plist.cpp b/platform/macos/export/plist.cpp index 36de9dd34b..36de9dd34b 100644 --- a/platform/osx/export/plist.cpp +++ b/platform/macos/export/plist.cpp diff --git a/platform/osx/export/plist.h b/platform/macos/export/plist.h index ba9eaec196..ba9eaec196 100644 --- a/platform/osx/export/plist.h +++ b/platform/macos/export/plist.h diff --git a/platform/osx/gl_manager_osx_legacy.h b/platform/macos/gl_manager_macos_legacy.h index 2d4913a7a6..9f866f2b32 100644 --- a/platform/osx/gl_manager_osx_legacy.h +++ b/platform/macos/gl_manager_macos_legacy.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gl_manager_osx_legacy.h */ +/* gl_manager_macos_legacy.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GL_MANAGER_OSX_LEGACY_H -#define GL_MANAGER_OSX_LEGACY_H +#ifndef GL_MANAGER_MACOS_LEGACY_H +#define GL_MANAGER_MACOS_LEGACY_H -#if defined(OSX_ENABLED) && defined(GLES3_ENABLED) +#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED) #include "core/error/error_list.h" #include "core/os/os.h" @@ -42,7 +42,7 @@ #import <ApplicationServices/ApplicationServices.h> #import <CoreVideo/CoreVideo.h> -class GLManager_OSX { +class GLManager_MacOS { public: enum ContextType { GLES_3_0_COMPATIBLE, @@ -89,9 +89,9 @@ public: void set_use_vsync(bool p_use); bool is_using_vsync() const; - GLManager_OSX(ContextType p_context_type); - ~GLManager_OSX(); + GLManager_MacOS(ContextType p_context_type); + ~GLManager_MacOS(); }; -#endif // OSX_ENABLED && GLES3_ENABLED -#endif // GL_MANAGER_OSX_LEGACY_H +#endif // MACOS_ENABLED && GLES3_ENABLED +#endif // GL_MANAGER_MACOS_LEGACY_H diff --git a/platform/osx/gl_manager_osx_legacy.mm b/platform/macos/gl_manager_macos_legacy.mm index c769d7f5c5..e6bb7aaa85 100644 --- a/platform/osx/gl_manager_osx_legacy.mm +++ b/platform/macos/gl_manager_macos_legacy.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gl_manager_osx_legacy.mm */ +/* gl_manager_macos_legacy.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gl_manager_osx_legacy.h" +#include "gl_manager_macos_legacy.h" -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED #ifdef GLES3_ENABLED #include <stdio.h> #include <stdlib.h> -Error GLManager_OSX::create_context(GLWindow &win) { +Error GLManager_MacOS::create_context(GLWindow &win) { NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAClosestPolicy, @@ -62,7 +62,7 @@ Error GLManager_OSX::create_context(GLWindow &win) { return OK; } -Error GLManager_OSX::window_create(DisplayServer::WindowID p_window_id, id p_view, int p_width, int p_height) { +Error GLManager_MacOS::window_create(DisplayServer::WindowID p_window_id, id p_view, int p_width, int p_height) { GLWindow win; win.width = p_width; win.height = p_height; @@ -78,7 +78,7 @@ Error GLManager_OSX::window_create(DisplayServer::WindowID p_window_id, id p_vie return OK; } -void GLManager_OSX::window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height) { +void GLManager_MacOS::window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height) { if (!windows.has(p_window_id)) { return; } @@ -102,7 +102,7 @@ void GLManager_OSX::window_resize(DisplayServer::WindowID p_window_id, int p_wid [win.context update]; } -int GLManager_OSX::window_get_width(DisplayServer::WindowID p_window_id) { +int GLManager_MacOS::window_get_width(DisplayServer::WindowID p_window_id) { if (!windows.has(p_window_id)) { return 0; } @@ -111,7 +111,7 @@ int GLManager_OSX::window_get_width(DisplayServer::WindowID p_window_id) { return win.width; } -int GLManager_OSX::window_get_height(DisplayServer::WindowID p_window_id) { +int GLManager_MacOS::window_get_height(DisplayServer::WindowID p_window_id) { if (!windows.has(p_window_id)) { return 0; } @@ -120,7 +120,7 @@ int GLManager_OSX::window_get_height(DisplayServer::WindowID p_window_id) { return win.height; } -void GLManager_OSX::window_destroy(DisplayServer::WindowID p_window_id) { +void GLManager_MacOS::window_destroy(DisplayServer::WindowID p_window_id) { if (!windows.has(p_window_id)) { return; } @@ -132,7 +132,7 @@ void GLManager_OSX::window_destroy(DisplayServer::WindowID p_window_id) { windows.erase(p_window_id); } -void GLManager_OSX::release_current() { +void GLManager_MacOS::release_current() { if (current_window == DisplayServer::INVALID_WINDOW_ID) { return; } @@ -140,7 +140,7 @@ void GLManager_OSX::release_current() { [NSOpenGLContext clearCurrentContext]; } -void GLManager_OSX::window_make_current(DisplayServer::WindowID p_window_id) { +void GLManager_MacOS::window_make_current(DisplayServer::WindowID p_window_id) { if (current_window == p_window_id) { return; } @@ -154,7 +154,7 @@ void GLManager_OSX::window_make_current(DisplayServer::WindowID p_window_id) { current_window = p_window_id; } -void GLManager_OSX::make_current() { +void GLManager_MacOS::make_current() { if (current_window == DisplayServer::INVALID_WINDOW_ID) { return; } @@ -166,13 +166,13 @@ void GLManager_OSX::make_current() { [win.context makeCurrentContext]; } -void GLManager_OSX::swap_buffers() { +void GLManager_MacOS::swap_buffers() { for (const KeyValue<DisplayServer::WindowID, GLWindow> &E : windows) { [E.value.context flushBuffer]; } } -void GLManager_OSX::window_update(DisplayServer::WindowID p_window_id) { +void GLManager_MacOS::window_update(DisplayServer::WindowID p_window_id) { if (!windows.has(p_window_id)) { return; } @@ -181,7 +181,7 @@ void GLManager_OSX::window_update(DisplayServer::WindowID p_window_id) { [win.context update]; } -void GLManager_OSX::window_set_per_pixel_transparency_enabled(DisplayServer::WindowID p_window_id, bool p_enabled) { +void GLManager_MacOS::window_set_per_pixel_transparency_enabled(DisplayServer::WindowID p_window_id, bool p_enabled) { if (!windows.has(p_window_id)) { return; } @@ -197,11 +197,11 @@ void GLManager_OSX::window_set_per_pixel_transparency_enabled(DisplayServer::Win [win.context update]; } -Error GLManager_OSX::initialize() { +Error GLManager_MacOS::initialize() { return OK; } -void GLManager_OSX::set_use_vsync(bool p_use) { +void GLManager_MacOS::set_use_vsync(bool p_use) { use_vsync = p_use; CGLContextObj ctx = CGLGetCurrentContext(); @@ -212,17 +212,17 @@ void GLManager_OSX::set_use_vsync(bool p_use) { } } -bool GLManager_OSX::is_using_vsync() const { +bool GLManager_MacOS::is_using_vsync() const { return use_vsync; } -GLManager_OSX::GLManager_OSX(ContextType p_context_type) { +GLManager_MacOS::GLManager_MacOS(ContextType p_context_type) { context_type = p_context_type; } -GLManager_OSX::~GLManager_OSX() { +GLManager_MacOS::~GLManager_MacOS() { release_current(); } #endif // GLES3_ENABLED -#endif // OSX +#endif // MACOS_ENABLED diff --git a/platform/osx/godot_application.h b/platform/macos/godot_application.h index 8d48a659f3..8d48a659f3 100644 --- a/platform/osx/godot_application.h +++ b/platform/macos/godot_application.h diff --git a/platform/osx/godot_application.mm b/platform/macos/godot_application.mm index 13313a025a..3f71c77fd1 100644 --- a/platform/osx/godot_application.mm +++ b/platform/macos/godot_application.mm @@ -30,12 +30,12 @@ #include "godot_application.h" -#include "display_server_osx.h" +#include "display_server_macos.h" @implementation GodotApplication - (void)sendEvent:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { if ([event type] == NSEventTypeLeftMouseDown || [event type] == NSEventTypeRightMouseDown || [event type] == NSEventTypeOtherMouseDown) { if (ds->mouse_process_popups()) { diff --git a/platform/osx/godot_application_delegate.h b/platform/macos/godot_application_delegate.h index f5b67b580f..f5b67b580f 100644 --- a/platform/osx/godot_application_delegate.h +++ b/platform/macos/godot_application_delegate.h diff --git a/platform/osx/godot_application_delegate.mm b/platform/macos/godot_application_delegate.mm index 4d3558b273..bacdcc2bc4 100644 --- a/platform/osx/godot_application_delegate.mm +++ b/platform/macos/godot_application_delegate.mm @@ -30,8 +30,8 @@ #include "godot_application_delegate.h" -#include "display_server_osx.h" -#include "os_osx.h" +#include "display_server_macos.h" +#include "os_macos.h" @implementation GodotApplicationDelegate @@ -78,7 +78,7 @@ } - (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { - OS_OSX *os = (OS_OSX *)OS::get_singleton(); + OS_MacOS *os = (OS_MacOS *)OS::get_singleton(); if (!event || !os) { return; } @@ -114,7 +114,7 @@ } - (void)applicationDidResignActive:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { ds->mouse_process_popups(true); } @@ -130,14 +130,14 @@ } - (void)globalMenuCallback:(id)sender { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { return ds->menu_callback(sender); } } - (NSMenu *)applicationDockMenu:(NSApplication *)sender { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { return ds->get_dock_menu(); } else { @@ -146,15 +146,15 @@ } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { - ds->send_window_event(ds->get_window(DisplayServerOSX::MAIN_WINDOW_ID), DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + ds->send_window_event(ds->get_window(DisplayServerMacOS::MAIN_WINDOW_ID), DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); } return NSTerminateCancel; } - (void)showAbout:(id)sender { - OS_OSX *os = (OS_OSX *)OS::get_singleton(); + OS_MacOS *os = (OS_MacOS *)OS::get_singleton(); if (os && os->get_main_loop()) { os->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT); } diff --git a/platform/osx/godot_content_view.h b/platform/macos/godot_content_view.h index 353305aec1..353305aec1 100644 --- a/platform/osx/godot_content_view.h +++ b/platform/macos/godot_content_view.h diff --git a/platform/osx/godot_content_view.mm b/platform/macos/godot_content_view.mm index 018b90e629..9ca7498a15 100644 --- a/platform/osx/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -30,8 +30,8 @@ #include "godot_content_view.h" -#include "display_server_osx.h" -#include "key_mapping_osx.h" +#include "display_server_macos.h" +#include "key_mapping_macos.h" @implementation GodotContentView @@ -56,7 +56,7 @@ return self; } -- (void)setWindowID:(DisplayServerOSX::WindowID)wid { +- (void)setWindowID:(DisplayServerMacOS::WindowID)wid { window_id = wid; } @@ -67,7 +67,7 @@ } - (void)updateLayer { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); ds->window_update(window_id); [super updateLayer]; } @@ -106,12 +106,12 @@ return; } - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (wd.im_active) { ime_input_event_in_progress = true; ds->update_im_text(Point2i(selectedRange.location, selectedRange.length), String::utf8([[marked_text mutableString] UTF8String])); @@ -126,12 +126,12 @@ ime_input_event_in_progress = false; [[marked_text mutableString] setString:@""]; - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (wd.im_active) { ds->update_im_text(Point2i(), String()); } @@ -150,12 +150,12 @@ } - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return NSMakeRect(0, 0, 0, 0); } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); const NSRect content_rect = [wd.window_view frame]; const float scale = ds->screen_get_max_scale(); NSRect point_in_window_rect = NSMakeRect(wd.im_position.x / scale, content_rect.size.height - (wd.im_position.y / scale) - 1, 0, 0); @@ -191,7 +191,7 @@ return; } - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { [self cancelComposition]; return; @@ -210,10 +210,10 @@ continue; } - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.osx_state = [event modifierFlags]; + ke.macos_state = [event modifierFlags]; ke.pressed = true; ke.echo = false; ke.raw = false; // IME input event. @@ -237,12 +237,12 @@ } - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return NO; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (!wd.drop_files_callback.is_null()) { Vector<String> files; NSPasteboard *pboard = [sender draggingPasteboard]; @@ -276,12 +276,12 @@ // MARK: Focus - (BOOL)canBecomeKeyView { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return YES; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); return !wd.no_focus && !wd.is_popup; } @@ -292,7 +292,7 @@ // MARK: Mouse - (void)cursorUpdate:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds) { return; } @@ -301,12 +301,12 @@ } - (void)processMouseEvent:(NSEvent *)event index:(MouseButton)index mask:(MouseButton)mask pressed:(bool)pressed { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); MouseButton last_button_state = ds->mouse_get_button_state(); if (pressed) { @@ -356,12 +356,12 @@ } - (void)mouseMoved:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); NSPoint delta = NSMakePoint([event deltaX], [event deltaY]); NSPoint mpos = [event locationInWindow]; @@ -438,38 +438,38 @@ } - (void)mouseExited:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) { - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_MOUSE_EXIT); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_MOUSE_EXIT); } } - (void)mouseEntered:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) { - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_MOUSE_ENTER); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_MOUSE_ENTER); } ds->cursor_update_shape(); } - (void)magnifyWithEvent:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); Ref<InputEventMagnifyGesture> ev; ev.instantiate(); @@ -497,12 +497,12 @@ // MARK: Keyboard - (void)keyDown:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ignore_momentum_scroll = true; @@ -511,7 +511,7 @@ NSString *characters = [event characters]; NSUInteger length = [characters length]; - if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]))) { + if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]))) { // Fallback unicode character handler used if IME is not active. Char16String text; text.resize([characters length] + 1); @@ -523,28 +523,28 @@ for (int i = 0; i < u32text.length(); i++) { const char32_t codepoint = u32text[i]; - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.osx_state = [event modifierFlags]; + ke.macos_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingOSX::translate_key([event keyCode]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); ke.raw = true; ke.unicode = codepoint; ds->push_to_key_event_buffer(ke); } } else { - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.osx_state = [event modifierFlags]; + ke.macos_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingOSX::translate_key([event keyCode]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); ke.raw = false; ke.unicode = 0; @@ -559,7 +559,7 @@ } - (void)flagsChanged:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } @@ -567,7 +567,7 @@ // Ignore all input if IME input is in progress if (!ime_input_event_in_progress) { - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; ke.echo = false; @@ -608,9 +608,9 @@ return; } - ke.osx_state = mod; - ke.keycode = KeyMappingOSX::remap_key(key, mod); - ke.physical_keycode = KeyMappingOSX::translate_key(key); + ke.macos_state = mod; + ke.keycode = KeyMappingMacOS::remap_key(key, mod); + ke.physical_keycode = KeyMappingMacOS::translate_key(key); ke.unicode = 0; ds->push_to_key_event_buffer(ke); @@ -618,12 +618,12 @@ } - (void)keyUp:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); // Ignore all input if IME input is in progress. if (!ime_input_event_in_progress) { @@ -631,7 +631,7 @@ NSUInteger length = [characters length]; // Fallback unicode character handler used if IME is not active. - if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]))) { + if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]))) { Char16String text; text.resize([characters length] + 1); [characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])]; @@ -641,28 +641,28 @@ for (int i = 0; i < u32text.length(); i++) { const char32_t codepoint = u32text[i]; - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.osx_state = [event modifierFlags]; + ke.macos_state = [event modifierFlags]; ke.pressed = false; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingOSX::translate_key([event keyCode]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); ke.raw = true; ke.unicode = codepoint; ds->push_to_key_event_buffer(ke); } } else { - DisplayServerOSX::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.osx_state = [event modifierFlags]; + ke.macos_state = [event modifierFlags]; ke.pressed = false; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingOSX::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingOSX::translate_key([event keyCode]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); ke.raw = true; ke.unicode = 0; @@ -674,12 +674,12 @@ // MARK: Scroll and pan - (void)processScrollEvent:(NSEvent *)event button:(MouseButton)button factor:(double)factor { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); MouseButton mask = mouse_button_to_mask(button); Ref<InputEventMouseButton> sc; @@ -713,12 +713,12 @@ } - (void)processPanEvent:(NSEvent *)event dx:(double)dx dy:(double)dy { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); Ref<InputEventPanGesture> pg; pg.instantiate(); @@ -732,12 +732,12 @@ } - (void)scrollWheel:(NSEvent *)event { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ds->update_mouse_pos(wd, [event locationInWindow]); double delta_x = [event scrollingDeltaX]; diff --git a/platform/osx/godot_main_osx.mm b/platform/macos/godot_main_macos.mm index 722928ad60..66071f1404 100644 --- a/platform/osx/godot_main_osx.mm +++ b/platform/macos/godot_main_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_main_osx.mm */ +/* godot_main_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,7 +30,7 @@ #include "main/main.h" -#include "os_osx.h" +#include "os_macos.h" #include <string.h> #include <unistd.h> @@ -68,7 +68,7 @@ int main(int argc, char **argv) { printf("Current path: %s\n", cwd); #endif - OS_OSX os; + OS_MacOS os; Error err; // We must override main when testing is enabled. diff --git a/platform/osx/godot_menu_item.h b/platform/macos/godot_menu_item.h index 2c12897f10..2c12897f10 100644 --- a/platform/osx/godot_menu_item.h +++ b/platform/macos/godot_menu_item.h diff --git a/platform/osx/godot_window.h b/platform/macos/godot_window.h index 16ff101142..16ff101142 100644 --- a/platform/osx/godot_window.h +++ b/platform/macos/godot_window.h diff --git a/platform/osx/godot_window.mm b/platform/macos/godot_window.mm index d43853a94b..e205e7546d 100644 --- a/platform/osx/godot_window.mm +++ b/platform/macos/godot_window.mm @@ -30,7 +30,7 @@ #include "godot_window.h" -#include "display_server_osx.h" +#include "display_server_macos.h" @implementation GodotWindow @@ -40,29 +40,29 @@ return self; } -- (void)setWindowID:(DisplayServerOSX::WindowID)wid { +- (void)setWindowID:(DisplayServerMacOS::WindowID)wid { window_id = wid; } - (BOOL)canBecomeKeyWindow { // Required for NSWindowStyleMaskBorderless windows. - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return YES; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); return !wd.no_focus && !wd.is_popup; } - (BOOL)canBecomeMainWindow { // Required for NSWindowStyleMaskBorderless windows. - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return YES; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); return !wd.no_focus && !wd.is_popup; } diff --git a/platform/osx/godot_window_delegate.h b/platform/macos/godot_window_delegate.h index 8a1f681fcd..8a1f681fcd 100644 --- a/platform/osx/godot_window_delegate.h +++ b/platform/macos/godot_window_delegate.h diff --git a/platform/osx/godot_window_delegate.mm b/platform/macos/godot_window_delegate.mm index 521127f01b..e1e88274f0 100644 --- a/platform/osx/godot_window_delegate.mm +++ b/platform/macos/godot_window_delegate.mm @@ -30,7 +30,7 @@ #include "godot_window_delegate.h" -#include "display_server_osx.h" +#include "display_server_macos.h" @implementation GodotWindowDelegate @@ -39,42 +39,42 @@ } - (BOOL)windowShouldClose:(id)sender { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return YES; } - ds->send_window_event(ds->get_window(window_id), DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + ds->send_window_event(ds->get_window(window_id), DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); return NO; } - (void)windowWillClose:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } ds->popup_close(window_id); - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); while (wd.transient_children.size()) { - ds->window_set_transient(*wd.transient_children.begin(), DisplayServerOSX::INVALID_WINDOW_ID); + ds->window_set_transient(*wd.transient_children.begin(), DisplayServerMacOS::INVALID_WINDOW_ID); } - if (wd.transient_parent != DisplayServerOSX::INVALID_WINDOW_ID) { - ds->window_set_transient(window_id, DisplayServerOSX::INVALID_WINDOW_ID); + if (wd.transient_parent != DisplayServerMacOS::INVALID_WINDOW_ID) { + ds->window_set_transient(window_id, DisplayServerMacOS::INVALID_WINDOW_ID); } ds->window_destroy(window_id); } - (void)windowDidEnterFullScreen:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); wd.fullscreen = true; // Reset window size limits. [wd.window_object setContentMinSize:NSMakeSize(0, 0)]; @@ -85,12 +85,12 @@ } - (void)windowDidExitFullScreen:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); wd.fullscreen = false; // Set window size limits. @@ -119,12 +119,12 @@ } - (void)windowDidChangeBackingProperties:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); CGFloat new_scale_factor = [wd.window_object backingScaleFactor]; CGFloat old_scale_factor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue]; @@ -137,7 +137,7 @@ wd.size.width = content_rect.size.width * scale; wd.size.height = content_rect.size.height * scale; - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_DPI_CHANGE); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_DPI_CHANGE); CALayer *layer = [wd.window_view layer]; if (layer) { @@ -150,26 +150,26 @@ } - (void)windowWillStartLiveResize:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { ds->set_is_resizing(true); } } - (void)windowDidEndLiveResize:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { ds->set_is_resizing(false); } } - (void)windowDidResize:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); const NSRect content_rect = [wd.window_view frame]; const float scale = ds->screen_get_max_scale(); wd.size.width = content_rect.size.width * scale; @@ -192,12 +192,12 @@ } - (void)windowDidMove:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ds->release_pressed_events(); if (!wd.rect_changed_callback.is_null()) { @@ -210,12 +210,12 @@ } - (void)windowDidBecomeKey:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (ds->mouse_get_mode() == DisplayServer::MOUSE_MODE_CAPTURED) { const NSRect content_rect = [wd.window_view frame]; @@ -228,43 +228,43 @@ } ds->set_last_focused_window(window_id); - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_IN); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_IN); } - (void)windowDidResignKey:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ds->release_pressed_events(); - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_OUT); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_OUT); } - (void)windowDidMiniaturize:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ds->release_pressed_events(); - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_OUT); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_OUT); } - (void)windowDidDeminiaturize:(NSNotification *)notification { - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (!ds || !ds->has_window(window_id)) { return; } - DisplayServerOSX::WindowData &wd = ds->get_window(window_id); + DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); ds->set_last_focused_window(window_id); - ds->send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_IN); + ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_FOCUS_IN); } @end diff --git a/platform/osx/joypad_osx.cpp b/platform/macos/joypad_macos.cpp index be9567e17c..1ddcfec1b5 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/macos/joypad_macos.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad_osx.cpp */ +/* joypad_macos.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joypad_osx.h" +#include "joypad_macos.h" #include <machine/endian.h> #define GODOT_JOY_LOOP_RUN_MODE CFSTR("GodotJoypad") -static JoypadOSX *self = nullptr; +static JoypadMacOS *self = nullptr; joypad::joypad() { ff_constant_force.lMagnitude = 10000; @@ -235,7 +235,7 @@ static bool is_joypad(IOHIDDeviceRef p_device_ref) { return true; } -void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { +void JoypadMacOS::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { if (p_res != kIOReturnSuccess || have_device(p_device)) { return; } @@ -258,7 +258,7 @@ void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { IOHIDDeviceScheduleWithRunLoop(p_device, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE); } -void JoypadOSX::_device_removed(IOReturn p_res, IOHIDDeviceRef p_device) { +void JoypadMacOS::_device_removed(IOReturn p_res, IOHIDDeviceRef p_device) { int device = get_joy_ref(p_device); ERR_FAIL_COND(device == -1); @@ -278,7 +278,7 @@ static String _hex_str(uint8_t p_byte) { return ret; } -bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { +bool JoypadMacOS::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { p_joy->device_ref = p_device_ref; // Get device name. String name; @@ -445,7 +445,7 @@ static HatMask process_hat_value(int p_min, int p_max, int p_value, bool p_offse return hat_value; } -void JoypadOSX::poll_joypads() const { +void JoypadMacOS::poll_joypads() const { while (CFRunLoopRunInMode(GODOT_JOY_LOOP_RUN_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { // No-op. Pending callbacks will fire. } @@ -456,7 +456,7 @@ static float axis_correct(int p_value, int p_min, int p_max) { return 2.0f * (p_value - p_min) / (p_max - p_min) - 1.0f; } -void JoypadOSX::process_joypads() { +void JoypadMacOS::process_joypads() { poll_joypads(); for (int i = 0; i < device_list.size(); i++) { @@ -494,7 +494,7 @@ void JoypadOSX::process_joypads() { } } -void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) { +void JoypadMacOS::joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) { joypad *joy = &device_list.write[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; joy->ff_effect.dwDuration = p_duration * FF_SECONDS; @@ -503,13 +503,13 @@ void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_dura FFEffectStart(joy->ff_object, 1, 0); } -void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { +void JoypadMacOS::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { joypad *joy = &device_list.write[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; FFEffectStop(joy->ff_object); } -int JoypadOSX::get_joy_index(int p_id) const { +int JoypadMacOS::get_joy_index(int p_id) const { for (int i = 0; i < device_list.size(); i++) { if (device_list[i].id == p_id) { return i; @@ -518,7 +518,7 @@ int JoypadOSX::get_joy_index(int p_id) const { return -1; } -int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const { +int JoypadMacOS::get_joy_ref(IOHIDDeviceRef p_device) const { for (int i = 0; i < device_list.size(); i++) { if (device_list[i].device_ref == p_device) { return i; @@ -527,7 +527,7 @@ int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const { return -1; } -bool JoypadOSX::have_device(IOHIDDeviceRef p_device) const { +bool JoypadMacOS::have_device(IOHIDDeviceRef p_device) const { for (int i = 0; i < device_list.size(); i++) { if (device_list[i].device_ref == p_device) { return true; @@ -561,7 +561,7 @@ static CFDictionaryRef create_match_dictionary(const UInt32 page, const UInt32 u return retval; } -void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const { +void JoypadMacOS::config_hid_manager(CFArrayRef p_matching_array) const { CFRunLoopRef runloop = CFRunLoopGetCurrent(); IOReturn ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone); ERR_FAIL_COND(ret != kIOReturnSuccess); @@ -576,7 +576,7 @@ void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const { } } -JoypadOSX::JoypadOSX(Input *in) { +JoypadMacOS::JoypadMacOS(Input *in) { self = this; input = in; @@ -604,7 +604,7 @@ JoypadOSX::JoypadOSX(Input *in) { } } -JoypadOSX::~JoypadOSX() { +JoypadMacOS::~JoypadMacOS() { for (int i = 0; i < device_list.size(); i++) { device_list.write[i].free(); } diff --git a/platform/osx/joypad_osx.h b/platform/macos/joypad_macos.h index 3f89048ce6..4b14fed6d5 100644 --- a/platform/osx/joypad_osx.h +++ b/platform/macos/joypad_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad_osx.h */ +/* joypad_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYPADOSX_H -#define JOYPADOSX_H +#ifndef JOYPAD_MACOS_H +#define JOYPAD_MACOS_H #ifdef MACOS_10_0_4 #import <IOKit/hidsystem/IOHIDUsageTables.h> @@ -88,7 +88,7 @@ struct joypad { joypad(); }; -class JoypadOSX { +class JoypadMacOS { enum { JOYPADS_MAX = 16, }; @@ -117,8 +117,8 @@ public: void _device_added(IOReturn p_res, IOHIDDeviceRef p_device); void _device_removed(IOReturn p_res, IOHIDDeviceRef p_device); - JoypadOSX(Input *in); - ~JoypadOSX(); + JoypadMacOS(Input *in); + ~JoypadMacOS(); }; -#endif // JOYPADOSX_H +#endif // JOYPAD_MACOS_H diff --git a/platform/osx/key_mapping_osx.h b/platform/macos/key_mapping_macos.h index 252cc907bb..fc5b791e44 100644 --- a/platform/osx/key_mapping_osx.h +++ b/platform/macos/key_mapping_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* key_mapping_osx.h */ +/* key_mapping_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef KEY_MAPPING_OSX_H -#define KEY_MAPPING_OSX_H +#ifndef KEY_MAPPING_MACOS_H +#define KEY_MAPPING_MACOS_H #include "core/os/keyboard.h" -class KeyMappingOSX { - KeyMappingOSX() {} +class KeyMappingMacOS { + KeyMappingMacOS() {} static bool is_numpad_key(unsigned int key); @@ -49,4 +49,4 @@ public: static unsigned int keycode_get_native_mask(Key p_keycode); }; -#endif // KEY_MAPPING_OSX_H +#endif // KEY_MAPPING_MACOS_H diff --git a/platform/osx/key_mapping_osx.mm b/platform/macos/key_mapping_macos.mm index 0bf6bc7d1c..f6cff7124b 100644 --- a/platform/osx/key_mapping_osx.mm +++ b/platform/macos/key_mapping_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* key_mapping_osx.mm */ +/* key_mapping_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "key_mapping_osx.h" +#include "key_mapping_macos.h" #import <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> -bool KeyMappingOSX::is_numpad_key(unsigned int key) { +bool KeyMappingMacOS::is_numpad_key(unsigned int key) { static const unsigned int table[] = { 0x41, /* kVK_ANSI_KeypadDecimal */ 0x43, /* kVK_ANSI_KeypadMultiply */ @@ -65,7 +65,7 @@ bool KeyMappingOSX::is_numpad_key(unsigned int key) { } // Keyboard symbol translation table. -static const Key _osx_to_godot_table[128] = { +static const Key _macos_to_godot_table[128] = { /* 00 */ Key::A, /* 01 */ Key::S, /* 02 */ Key::D, @@ -197,18 +197,18 @@ static const Key _osx_to_godot_table[128] = { }; // Translates a OS X keycode to a Godot keycode. -Key KeyMappingOSX::translate_key(unsigned int key) { +Key KeyMappingMacOS::translate_key(unsigned int key) { if (key >= 128) { return Key::UNKNOWN; } - return _osx_to_godot_table[key]; + return _macos_to_godot_table[key]; } -// Translates a Godot keycode back to a OSX keycode. -unsigned int KeyMappingOSX::unmap_key(Key key) { +// Translates a Godot keycode back to a macOS keycode. +unsigned int KeyMappingMacOS::unmap_key(Key key) { for (int i = 0; i <= 126; i++) { - if (_osx_to_godot_table[i] == key) { + if (_macos_to_godot_table[i] == key) { return i; } } @@ -279,7 +279,7 @@ static const _KeyCodeMap _keycodes[55] = { }; // Remap key according to current keyboard layout. -Key KeyMappingOSX::remap_key(unsigned int key, unsigned int state) { +Key KeyMappingMacOS::remap_key(unsigned int key, unsigned int state) { if (is_numpad_key(key)) { return translate_key(key); } @@ -463,7 +463,7 @@ static const _KeyCodeText _native_keycodes[] = { /* clang-format on */ }; -String KeyMappingOSX::keycode_get_native_string(Key p_keycode) { +String KeyMappingMacOS::keycode_get_native_string(Key p_keycode) { const _KeyCodeText *kct = &_native_keycodes[0]; while (kct->text) { @@ -475,7 +475,7 @@ String KeyMappingOSX::keycode_get_native_string(Key p_keycode) { return String(); } -unsigned int KeyMappingOSX::keycode_get_native_mask(Key p_keycode) { +unsigned int KeyMappingMacOS::keycode_get_native_mask(Key p_keycode) { unsigned int mask = 0; if ((p_keycode & KeyModifierMask::CTRL) != Key::NONE) { mask |= NSEventModifierFlagControl; diff --git a/platform/osx/logo.png b/platform/macos/logo.png Binary files differindex b5a660b165..b5a660b165 100644 --- a/platform/osx/logo.png +++ b/platform/macos/logo.png diff --git a/platform/osx/osx_terminal_logger.h b/platform/macos/macos_terminal_logger.h index 8413509c4b..bad2c1d657 100644 --- a/platform/osx/osx_terminal_logger.h +++ b/platform/macos/macos_terminal_logger.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* osx_terminal_logger.h */ +/* macos_terminal_logger.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,17 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OSX_TERMINAL_LOGGER_H -#define OSX_TERMINAL_LOGGER_H +#ifndef MACOS_TERMINAL_LOGGER_H +#define MACOS_TERMINAL_LOGGER_H -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED #include "core/io/logger.h" -class OSXTerminalLogger : public StdLogger { +class MacOSTerminalLogger : public StdLogger { public: virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) override; }; -#endif // OSX_ENABLED -#endif // OSX_TERMINAL_LOGGER_H +#endif // MACOS_ENABLED +#endif // MACOS_TERMINAL_LOGGER_H diff --git a/platform/osx/osx_terminal_logger.mm b/platform/macos/macos_terminal_logger.mm index 48e26f42bf..b5ea2938ee 100644 --- a/platform/osx/osx_terminal_logger.mm +++ b/platform/macos/macos_terminal_logger.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* osx_terminal_logger.mm */ +/* macos_terminal_logger.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "osx_terminal_logger.h" +#include "macos_terminal_logger.h" -#ifdef OSX_ENABLED +#ifdef MACOS_ENABLED #include <os/log.h> -void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type) { +void MacOSTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type) { if (!should_log(true)) { return; } @@ -79,4 +79,4 @@ void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, in } } -#endif // OSX_ENABLED +#endif // MACOS_ENABLED diff --git a/platform/osx/os_osx.h b/platform/macos/os_macos.h index b105be4a06..914cdb9af7 100644 --- a/platform/osx/os_osx.h +++ b/platform/macos/os_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_osx.h */ +/* os_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,21 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OS_OSX_H -#define OS_OSX_H +#ifndef OS_MACOS_H +#define OS_MACOS_H #include "core/input/input.h" -#include "crash_handler_osx.h" +#include "crash_handler_macos.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/coremidi/midi_driver_coremidi.h" #include "drivers/unix/os_unix.h" -#include "joypad_osx.h" +#include "joypad_macos.h" #include "servers/audio_server.h" -class OS_OSX : public OS_Unix { +class OS_MacOS : public OS_Unix { bool force_quit = false; - JoypadOSX *joypad_osx = nullptr; + JoypadMacOS *joypad_macos = nullptr; #ifdef COREAUDIO_ENABLED AudioDriverCoreAudio audio_driver; @@ -113,8 +113,8 @@ public: void run(); - OS_OSX(); - ~OS_OSX(); + OS_MacOS(); + ~OS_MacOS(); }; #endif diff --git a/platform/osx/os_osx.mm b/platform/macos/os_macos.mm index 5230ed4155..2c6cd7de0b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/macos/os_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_osx.mm */ +/* os_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "os_osx.h" +#include "os_macos.h" #include "core/version_generated.gen.h" #include "main/main.h" -#include "dir_access_osx.h" -#include "display_server_osx.h" +#include "dir_access_macos.h" +#include "display_server_macos.h" #include "godot_application.h" #include "godot_application_delegate.h" -#include "osx_terminal_logger.h" +#include "macos_terminal_logger.h" #include <dlfcn.h> #include <libproc.h> @@ -45,7 +45,7 @@ #include <os/log.h> #include <sys/sysctl.h> -_FORCE_INLINE_ String OS_OSX::get_framework_executable(const String &p_path) { +_FORCE_INLINE_ String OS_MacOS::get_framework_executable(const String &p_path) { // Append framework executable name, or return as is if p_path is not a framework. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (da->dir_exists(p_path) && da->file_exists(p_path.plus_file(p_path.get_file().get_basename()))) { @@ -55,10 +55,10 @@ _FORCE_INLINE_ String OS_OSX::get_framework_executable(const String &p_path) { } } -void OS_OSX::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context) { +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 resize / modal popups. - DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton(); + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (get_singleton()->get_main_loop() && ds && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD || !ds->get_is_resizing())) { Main::force_redraw(); if (!Main::is_iterating()) { // Avoid cyclic loop. @@ -69,13 +69,13 @@ void OS_OSX::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActi CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping. } -void OS_OSX::initialize() { +void OS_MacOS::initialize() { crash_handler.initialize(); initialize_core(); } -String OS_OSX::get_processor_name() const { +String OS_MacOS::get_processor_name() const { char buffer[256]; size_t buffer_len = 256; if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) { @@ -84,35 +84,35 @@ String OS_OSX::get_processor_name() const { ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); } -void OS_OSX::initialize_core() { +void OS_MacOS::initialize_core() { OS_Unix::initialize_core(); - DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES); - DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA); - DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM); + DirAccess::make_default<DirAccessMacOS>(DirAccess::ACCESS_RESOURCES); + DirAccess::make_default<DirAccessMacOS>(DirAccess::ACCESS_USERDATA); + DirAccess::make_default<DirAccessMacOS>(DirAccess::ACCESS_FILESYSTEM); } -void OS_OSX::finalize() { +void OS_MacOS::finalize() { #ifdef COREMIDI_ENABLED midi_driver.close(); #endif delete_main_loop(); - if (joypad_osx) { - memdelete(joypad_osx); + if (joypad_macos) { + memdelete(joypad_macos); } } -void OS_OSX::initialize_joypads() { - joypad_osx = memnew(JoypadOSX(Input::get_singleton())); +void OS_MacOS::initialize_joypads() { + joypad_macos = memnew(JoypadMacOS(Input::get_singleton())); } -void OS_OSX::set_main_loop(MainLoop *p_main_loop) { +void OS_MacOS::set_main_loop(MainLoop *p_main_loop) { main_loop = p_main_loop; } -void OS_OSX::delete_main_loop() { +void OS_MacOS::delete_main_loop() { if (!main_loop) { return; } @@ -121,19 +121,19 @@ void OS_OSX::delete_main_loop() { main_loop = nullptr; } -void OS_OSX::set_cmdline_platform_args(const List<String> &p_args) { +void OS_MacOS::set_cmdline_platform_args(const List<String> &p_args) { launch_service_args = p_args; } -List<String> OS_OSX::get_cmdline_platform_args() const { +List<String> OS_MacOS::get_cmdline_platform_args() const { return launch_service_args; } -String OS_OSX::get_name() const { +String OS_MacOS::get_name() const { return "macOS"; } -void OS_OSX::alert(const String &p_alert, const String &p_title) { +void OS_MacOS::alert(const String &p_alert, const String &p_title) { NSAlert *window = [[NSAlert alloc] init]; NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; @@ -150,7 +150,7 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) { } } -Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { +Error OS_MacOS::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { String path = get_framework_executable(p_path); if (!FileAccess::exists(path)) { @@ -173,11 +173,11 @@ Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, return OK; } -MainLoop *OS_OSX::get_main_loop() const { +MainLoop *OS_MacOS::get_main_loop() const { return main_loop; } -String OS_OSX::get_config_path() const { +String OS_MacOS::get_config_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CONFIG_HOME")) { if (get_environment("XDG_CONFIG_HOME").is_absolute_path()) { @@ -192,7 +192,7 @@ String OS_OSX::get_config_path() const { return "."; } -String OS_OSX::get_data_path() const { +String OS_MacOS::get_data_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_DATA_HOME")) { if (get_environment("XDG_DATA_HOME").is_absolute_path()) { @@ -204,7 +204,7 @@ String OS_OSX::get_data_path() const { return get_config_path(); } -String OS_OSX::get_cache_path() const { +String OS_MacOS::get_cache_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CACHE_HOME")) { if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { @@ -219,7 +219,7 @@ String OS_OSX::get_cache_path() const { return get_config_path(); } -String OS_OSX::get_bundle_resource_dir() const { +String OS_MacOS::get_bundle_resource_dir() const { String ret; NSBundle *main = [NSBundle mainBundle]; @@ -230,7 +230,7 @@ String OS_OSX::get_bundle_resource_dir() const { return ret; } -String OS_OSX::get_bundle_icon_path() const { +String OS_MacOS::get_bundle_icon_path() const { String ret; NSBundle *main = [NSBundle mainBundle]; @@ -244,11 +244,11 @@ String OS_OSX::get_bundle_icon_path() const { } // Get properly capitalized engine name for system paths -String OS_OSX::get_godot_dir_name() const { +String OS_MacOS::get_godot_dir_name() const { return String(VERSION_SHORT_NAME).capitalize(); } -String OS_OSX::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { +String OS_MacOS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { NSSearchPathDirectory id; bool found = true; @@ -287,7 +287,7 @@ String OS_OSX::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { return ret; } -Error OS_OSX::shell_open(String p_uri) { +Error OS_MacOS::shell_open(String p_uri) { NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()]; NSURL *uri = [[NSURL alloc] initWithString:string]; // Escape special characters in filenames @@ -298,12 +298,12 @@ Error OS_OSX::shell_open(String p_uri) { return OK; } -String OS_OSX::get_locale() const { +String OS_MacOS::get_locale() const { NSString *locale_code = [[NSLocale preferredLanguages] objectAtIndex:0]; return String([locale_code UTF8String]).replace("-", "_"); } -String OS_OSX::get_executable_path() const { +String OS_MacOS::get_executable_path() const { char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; int pid = getpid(); pid_t ret = proc_pidpath(pid, pathbuf, sizeof(pathbuf)); @@ -317,7 +317,7 @@ String OS_OSX::get_executable_path() const { } } -Error OS_OSX::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { +Error OS_MacOS::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { // Use NSWorkspace if path is an .app bundle. NSURL *url = [NSURL fileURLWithPath:@(p_path.utf8().get_data())]; NSBundle *bundle = [NSBundle bundleWithURL:url]; @@ -375,7 +375,7 @@ Error OS_OSX::create_process(const String &p_path, const List<String> &p_argumen } } -Error OS_OSX::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) { +Error OS_MacOS::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) { // 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) { @@ -387,7 +387,7 @@ Error OS_OSX::create_instance(const List<String> &p_arguments, ProcessID *r_chil } } -String OS_OSX::get_unique_id() const { +String OS_MacOS::get_unique_id() const { static String serial_number; if (serial_number.is_empty()) { @@ -412,19 +412,19 @@ String OS_OSX::get_unique_id() const { return serial_number; } -bool OS_OSX::_check_internal_feature_support(const String &p_feature) { +bool OS_MacOS::_check_internal_feature_support(const String &p_feature) { return p_feature == "pc"; } -void OS_OSX::disable_crash_handler() { +void OS_MacOS::disable_crash_handler() { crash_handler.disable(); } -bool OS_OSX::is_disable_crash_handler() const { +bool OS_MacOS::is_disable_crash_handler() const { return crash_handler.is_disabled(); } -Error OS_OSX::move_to_trash(const String &p_path) { +Error OS_MacOS::move_to_trash(const String &p_path) { NSFileManager *fm = [NSFileManager defaultManager]; NSURL *url = [NSURL fileURLWithPath:@(p_path.utf8().get_data())]; NSError *err; @@ -437,7 +437,7 @@ Error OS_OSX::move_to_trash(const String &p_path) { return OK; } -void OS_OSX::run() { +void OS_MacOS::run() { force_quit = false; if (!main_loop) { @@ -452,7 +452,7 @@ void OS_OSX::run() { if (DisplayServer::get_singleton()) { DisplayServer::get_singleton()->process_events(); // Get rid of pending events. } - joypad_osx->process_joypads(); + joypad_macos->process_joypads(); if (Main::iteration()) { quit = true; @@ -465,19 +465,19 @@ void OS_OSX::run() { main_loop->finalize(); } -OS_OSX::OS_OSX() { +OS_MacOS::OS_MacOS() { main_loop = nullptr; force_quit = false; Vector<Logger *> loggers; - loggers.push_back(memnew(OSXTerminalLogger)); + loggers.push_back(memnew(MacOSTerminalLogger)); _set_logger(memnew(CompositeLogger(loggers))); #ifdef COREAUDIO_ENABLED AudioDriverManager::add_driver(&audio_driver); #endif - DisplayServerOSX::register_osx_driver(); + DisplayServerMacOS::register_macos_driver(); // Implicitly create shared NSApplication instance. [GodotApplication sharedApplication]; @@ -518,7 +518,7 @@ OS_OSX::OS_OSX() { [NSApp activateIgnoringOtherApps:YES]; } -OS_OSX::~OS_OSX() { +OS_MacOS::~OS_MacOS() { CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes); CFRelease(pre_wait_observer); } diff --git a/platform/osx/platform_config.h b/platform/macos/platform_config.h index e114606b82..e114606b82 100644 --- a/platform/osx/platform_config.h +++ b/platform/macos/platform_config.h diff --git a/platform/osx/platform_osx_builders.py b/platform/macos/platform_macos_builders.py index 953ed479db..3a1cc92bd2 100644 --- a/platform/osx/platform_osx_builders.py +++ b/platform/macos/platform_macos_builders.py @@ -7,7 +7,7 @@ import os from platform_methods import subprocess_main -def make_debug_osx(target, source, env): +def make_debug_macos(target, source, env): if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] diff --git a/platform/osx/tts_osx.h b/platform/macos/tts_macos.h index 449418e48f..344676868a 100644 --- a/platform/osx/tts_osx.h +++ b/platform/macos/tts_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* tts_osx.h */ +/* tts_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef TTS_OSX_H -#define TTS_OSX_H +#ifndef TTS_MACOS_H +#define TTS_MACOS_H #include "core/string/ustring.h" #include "core/templates/list.h" @@ -45,7 +45,7 @@ #import <AVFoundation/AVFoundation.h> #endif -@interface TTS_OSX : NSObject <AVSpeechSynthesizerDelegate> { +@interface TTS_MacOS : NSObject <AVSpeechSynthesizerDelegate> { // AVSpeechSynthesizer bool speaking; HashMap<id, int> ids; @@ -68,4 +68,4 @@ - (Array)getVoices; @end -#endif // TTS_OSX_H +#endif // TTS_MACOS_H diff --git a/platform/osx/tts_osx.mm b/platform/macos/tts_macos.mm index e6a5236cd9..3c101b9531 100644 --- a/platform/osx/tts_osx.mm +++ b/platform/macos/tts_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* tts_osx.mm */ +/* tts_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "tts_osx.h" +#include "tts_macos.h" -@implementation TTS_OSX +@implementation TTS_MacOS - (id)init { self = [super init]; diff --git a/platform/osx/vulkan_context_osx.h b/platform/macos/vulkan_context_macos.h index ade0f4a4c9..4dc6a12756 100644 --- a/platform/osx/vulkan_context_osx.h +++ b/platform/macos/vulkan_context_macos.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_osx.h */ +/* vulkan_context_macos.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,20 +28,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VULKAN_DEVICE_OSX_H -#define VULKAN_DEVICE_OSX_H +#ifndef VULKAN_DEVICE_MACOS_H +#define VULKAN_DEVICE_MACOS_H #include "drivers/vulkan/vulkan_context.h" #import <AppKit/AppKit.h> -class VulkanContextOSX : public VulkanContext { +class VulkanContextMacOS : public VulkanContext { virtual const char *_get_platform_surface_extension() const; public: Error window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, id p_window, int p_width, int p_height); - VulkanContextOSX(); - ~VulkanContextOSX(); + VulkanContextMacOS(); + ~VulkanContextMacOS(); }; -#endif // VULKAN_DEVICE_OSX_H +#endif // VULKAN_DEVICE_MACOS_H diff --git a/platform/osx/vulkan_context_osx.mm b/platform/macos/vulkan_context_macos.mm index bdabc24c28..cf317f3c68 100644 --- a/platform/osx/vulkan_context_osx.mm +++ b/platform/macos/vulkan_context_macos.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_osx.mm */ +/* vulkan_context_macos.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,18 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "vulkan_context_osx.h" +#include "vulkan_context_macos.h" #ifdef USE_VOLK #include <volk.h> #else #include <vulkan/vulkan.h> #endif -const char *VulkanContextOSX::_get_platform_surface_extension() const { +const char *VulkanContextMacOS::_get_platform_surface_extension() const { return VK_MVK_MACOS_SURFACE_EXTENSION_NAME; } -Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, id p_window, int p_width, int p_height) { +Error VulkanContextMacOS::window_create(DisplayServer::WindowID p_window_id, DisplayServer::VSyncMode p_vsync_mode, id p_window, int p_width, int p_height) { VkMacOSSurfaceCreateInfoMVK createInfo; createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; createInfo.pNext = nullptr; @@ -52,8 +52,8 @@ Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, Displ return _window_create(p_window_id, p_vsync_mode, surface, p_width, p_height); } -VulkanContextOSX::VulkanContextOSX() { +VulkanContextMacOS::VulkanContextMacOS() { } -VulkanContextOSX::~VulkanContextOSX() { +VulkanContextMacOS::~VulkanContextMacOS() { } diff --git a/platform/osx/SCsub b/platform/osx/SCsub deleted file mode 100644 index 3a4c95613d..0000000000 --- a/platform/osx/SCsub +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python - -Import("env") - -from platform_methods import run_in_subprocess -import platform_osx_builders - -files = [ - "os_osx.mm", - "godot_application.mm", - "godot_application_delegate.mm", - "crash_handler_osx.mm", - "osx_terminal_logger.mm", - "display_server_osx.mm", - "godot_content_view.mm", - "godot_window_delegate.mm", - "godot_window.mm", - "key_mapping_osx.mm", - "godot_main_osx.mm", - "dir_access_osx.mm", - "tts_osx.mm", - "joypad_osx.cpp", - "vulkan_context_osx.mm", - "gl_manager_osx_legacy.mm", -] - -prog = env.add_program("#bin/godot", files) - -if env["debug_symbols"] and env["separate_debug_symbols"]: - env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 1614bfdcc3..f37759c66f 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -557,6 +557,7 @@ uint64_t OS_UWP::get_ticks_usec() const { void OS_UWP::process_events() { joypad->process_controllers(); process_key_events(); + input->flush_buffered_events(); } void OS_UWP::process_key_events() { diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index e66fa142a7..f9988b23bc 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -2382,7 +2382,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } case WM_MOUSELEAVE: { old_invalid = true; - outside = true; + windows[window_id].mouse_outside = true; _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT); @@ -2612,7 +2612,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } } - if (outside) { + if (windows[window_id].mouse_outside) { // Mouse enter. if (mouse_mode != MOUSE_MODE_CAPTURED) { @@ -2622,7 +2622,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; cursor_set_shape(c); - outside = false; + windows[window_id].mouse_outside = false; // Once-off notification, must call again. track_mouse_leave_event(hWnd); @@ -2713,7 +2713,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } } - if (outside) { + if (windows[window_id].mouse_outside) { // Mouse enter. if (mouse_mode != MOUSE_MODE_CAPTURED) { @@ -2723,7 +2723,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; cursor_set_shape(c); - outside = false; + windows[window_id].mouse_outside = false; // Once-off notification, must call again. track_mouse_leave_event(hWnd); @@ -3458,6 +3458,12 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, windows.erase(id); ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Failed to create Windows OS window."); } + if (p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) { + wd.fullscreen = true; + if (p_mode == WINDOW_MODE_FULLSCREEN) { + wd.multiwindow_fs = true; + } + } if (p_mode != WINDOW_MODE_FULLSCREEN && p_mode != WINDOW_MODE_EXCLUSIVE_FULLSCREEN) { wd.pre_fs_valid = true; } @@ -3608,8 +3614,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win old_invalid = true; mouse_mode = MOUSE_MODE_VISIBLE; - outside = true; - rendering_driver = p_rendering_driver; // Init TTS diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 0429bed3a0..ddbf674c64 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -313,7 +313,6 @@ class DisplayServerWindows : public DisplayServer { int key_event_pos; bool old_invalid; - bool outside; int old_x, old_y; Point2i center; @@ -387,6 +386,7 @@ class DisplayServerWindows : public DisplayServer { Size2 window_rect; Point2 last_pos; + bool mouse_outside = true; ObjectID instance_id; diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis index bb855e4ac8..899956d65a 100644 --- a/platform/windows/godot.natvis +++ b/platform/windows/godot.natvis @@ -41,10 +41,12 @@ <DisplayString Condition="type == Variant::AABB">{_data._aabb}</DisplayString> <DisplayString Condition="type == Variant::BASIS">{_data._basis}</DisplayString> <DisplayString Condition="type == Variant::TRANSFORM3D">{_data._transform}</DisplayString> + <DisplayString Condition="type == Variant::PROJECTION">{_data._projection}</DisplayString> <DisplayString Condition="type == Variant::STRING">{*(String *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString> + <DisplayString Condition="type == Variant::VECTOR4">{*(Vector4 *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::QUATERNION">{*(Quaternion *)_data._mem}</DisplayString> <DisplayString Condition="type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString> diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 6f414c094c..b5423e62bf 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -951,9 +951,9 @@ String OS_Windows::get_user_data_dir() const { } String OS_Windows::get_unique_id() const { - HW_PROFILE_INFO HwProfInfo; - ERR_FAIL_COND_V(!GetCurrentHwProfile(&HwProfInfo), ""); - return String::utf16((const char16_t *)(HwProfInfo.szHwProfileGuid), HW_PROFILE_GUIDLEN); + HW_PROFILE_INFOA HwProfInfo; + ERR_FAIL_COND_V(!GetCurrentHwProfileA(&HwProfInfo), ""); + return String((HwProfInfo.szHwProfileGuid), HW_PROFILE_GUIDLEN); } bool OS_Windows::_check_internal_feature_support(const String &p_feature) { |