diff options
Diffstat (limited to 'platform')
123 files changed, 686 insertions, 351 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 1f3bbc2350..dfc921cc54 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -21,7 +21,7 @@ android_files = [ "android_keys_utils.cpp", "display_server_android.cpp", "plugin/godot_plugin_jni.cpp", - "vulkan/vulkan_context_android.cpp", + "vulkan_context_android.cpp", ] env_android = env.Clone() diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h index bdfaaa3215..5cf5628a8b 100644 --- a/platform/android/android_keys_utils.h +++ b/platform/android/android_keys_utils.h @@ -31,8 +31,9 @@ #ifndef ANDROID_KEYS_UTILS_H #define ANDROID_KEYS_UTILS_H +#include "core/os/keyboard.h" + #include <android/input.h> -#include <core/os/keyboard.h> #define AKEYCODE_MAX 0xFFFF diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp index 757ca315a7..60c369951c 100644 --- a/platform/android/api/api.cpp +++ b/platform/android/api/api.cpp @@ -30,10 +30,11 @@ #include "api.h" -#include "core/config/engine.h" #include "java_class_wrapper.h" #include "jni_singleton.h" +#include "core/config/engine.h" + #if !defined(ANDROID_ENABLED) static JavaClassWrapper *java_class_wrapper = nullptr; #endif diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index 455ed259ec..a2d1c08168 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -33,8 +33,9 @@ #include "core/config/engine.h" #include "core/variant/variant.h" + #ifdef ANDROID_ENABLED -#include "platform/android/jni_utils.h" +#include "jni_utils.h" #endif class JNISingleton : public Object { diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 7b41ad87bd..6bd09fe00a 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -30,10 +30,11 @@ #include "dir_access_jandroid.h" -#include "core/string/print_string.h" #include "string_android.h" #include "thread_jandroid.h" +#include "core/string/print_string.h" + jobject DirAccessJAndroid::dir_access_handler = nullptr; jclass DirAccessJAndroid::cls = nullptr; jmethodID DirAccessJAndroid::_dir_open = nullptr; diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 05b7d47957..5ee4c85659 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -31,9 +31,11 @@ #ifndef DIR_ACCESS_JANDROID_H #define DIR_ACCESS_JANDROID_H +#include "java_godot_lib_jni.h" + #include "core/io/dir_access.h" #include "drivers/unix/dir_access_unix.h" -#include "java_godot_lib_jni.h" + #include <stdio.h> /// Android implementation of the DirAccess interface used to provide access to diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index e07e0e1149..4d9a49c35c 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -30,19 +30,23 @@ #include "display_server_android.h" -#include "core/config/project_settings.h" #include "java_godot_io_wrapper.h" #include "java_godot_wrapper.h" #include "os_android.h" #include "tts_android.h" +#include "core/config/project_settings.h" + #if defined(VULKAN_ENABLED) +#include "vulkan_context_android.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/android/vulkan/vulkan_context_android.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #endif + #ifdef GLES3_ENABLED #include "drivers/gles3/rasterizer_gles3.h" + #include <EGL/egl.h> #endif diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1e048100d1..32b46271fd 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -30,10 +30,11 @@ #include "export.h" +#include "export_plugin.h" + #include "core/os/os.h" #include "editor/editor_settings.h" #include "editor/export/editor_export.h" -#include "export_plugin.h" void register_android_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid); diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 71b8a2b09b..6030239695 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -30,6 +30,8 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" #include "gradle_export_util.h" #include "core/config/project_settings.h" @@ -46,8 +48,6 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "main/splash.gen.h" -#include "platform/android/logo_svg.gen.h" -#include "platform/android/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED diff --git a/platform/android/export/godot_plugin_config.cpp b/platform/android/export/godot_plugin_config.cpp index 56431c25de..b64cca3254 100644 --- a/platform/android/export/godot_plugin_config.cpp +++ b/platform/android/export/godot_plugin_config.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "godot_plugin_config.h" + /* * Set of prebuilt plugins. * Currently unused, this is just for future reference: diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index b8f45628e5..7ff5c4d117 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -32,6 +32,7 @@ #define FILE_ACCESS_ANDROID_H #include "core/io/file_access.h" + #include <android/asset_manager.h> #include <android/log.h> #include <stdio.h> diff --git a/platform/android/file_access_filesystem_jandroid.cpp b/platform/android/file_access_filesystem_jandroid.cpp index ea8459d1ed..a1865fb1d4 100644 --- a/platform/android/file_access_filesystem_jandroid.cpp +++ b/platform/android/file_access_filesystem_jandroid.cpp @@ -30,9 +30,10 @@ #include "file_access_filesystem_jandroid.h" +#include "thread_jandroid.h" + #include "core/os/os.h" #include "core/templates/local_vector.h" -#include "thread_jandroid.h" #include <unistd.h> diff --git a/platform/android/file_access_filesystem_jandroid.h b/platform/android/file_access_filesystem_jandroid.h index 5e74d9de24..739c8a0925 100644 --- a/platform/android/file_access_filesystem_jandroid.h +++ b/platform/android/file_access_filesystem_jandroid.h @@ -31,9 +31,10 @@ #ifndef FILE_ACCESS_FILESYSTEM_JANDROID_H #define FILE_ACCESS_FILESYSTEM_JANDROID_H -#include "core/io/file_access.h" #include "java_godot_lib_jni.h" +#include "core/io/file_access.h" + class FileAccessFilesystemJAndroid : public FileAccess { static jobject file_access_handler; static jclass cls; diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml index 2bb6b43503..c7b2c8ad67 100644 --- a/platform/android/java/editor/src/main/AndroidManifest.xml +++ b/platform/android/java/editor/src/main/AndroidManifest.xml @@ -35,7 +35,7 @@ <activity android:name=".GodotProjectManager" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:screenOrientation="userLandscape" android:exported="true" android:process=":GodotProjectManager"> @@ -53,7 +53,7 @@ android:name=".GodotEditor" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:process=":GodotEditor" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:screenOrientation="userLandscape" android:exported="false"> <layout android:defaultHeight="@dimen/editor_default_window_height" @@ -65,7 +65,7 @@ android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:label="@string/godot_project_name_string" android:process=":GodotGame" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:exported="false" android:screenOrientation="userLandscape"> <layout android:defaultHeight="@dimen/editor_default_window_height" diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt index ce485afd91..3d1d4d22ce 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt @@ -62,7 +62,8 @@ open class GodotEditor : FullScreenGodotApp() { private const val WAIT_FOR_DEBUGGER = false - private const val COMMAND_LINE_PARAMS = "command_line_params" + private const val EXTRA_FORCE_QUIT = "force_quit_requested" + private const val EXTRA_COMMAND_LINE_PARAMS = "command_line_params" private const val EDITOR_ID = 777 private const val EDITOR_ARG = "--editor" @@ -76,6 +77,16 @@ open class GodotEditor : FullScreenGodotApp() { private const val PROJECT_MANAGER_ARG = "--project-manager" private const val PROJECT_MANAGER_ARG_SHORT = "-p" private const val PROJECT_MANAGER_PROCESS_NAME_SUFFIX = ":GodotProjectManager" + + /** + * Sets of constants to specify the window to use to run the project. + * + * Should match the values in 'editor/editor_settings.cpp' for the + * 'run/window_placement/android_window' setting. + */ + private const val ANDROID_WINDOW_AUTO = 0 + private const val ANDROID_WINDOW_SAME_AS_EDITOR = 1 + private const val ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR = 2 } private val commandLineParams = ArrayList<String>() @@ -85,8 +96,7 @@ open class GodotEditor : FullScreenGodotApp() { // requested on demand based on use-cases. PermissionsUtil.requestManifestPermissions(this, setOf(Manifest.permission.RECORD_AUDIO)) - val params = intent.getStringArrayExtra(COMMAND_LINE_PARAMS) - updateCommandLineParams(params) + handleIntentParams(intent) if (BuildConfig.BUILD_TYPE == "dev" && WAIT_FOR_DEBUGGER) { Debug.waitForDebugger() @@ -95,6 +105,25 @@ open class GodotEditor : FullScreenGodotApp() { super.onCreate(savedInstanceState) } + override fun onNewIntent(newIntent: Intent) { + intent = newIntent + handleIntentParams(newIntent) + super.onNewIntent(newIntent) + } + + private fun handleIntentParams(receivedIntent: Intent) { + val forceQuitRequested = receivedIntent.getBooleanExtra(EXTRA_FORCE_QUIT, false) + if (forceQuitRequested) { + Log.d(TAG, "Force quit requested, terminating..") + ProcessPhoenix.forceQuit(this) + return + } + + val params = receivedIntent.getStringArrayExtra(EXTRA_COMMAND_LINE_PARAMS) + Log.d(TAG, "Received parameters ${params.contentToString()}") + updateCommandLineParams(params) + } + override fun onGodotSetupCompleted() { super.onGodotSetupCompleted() val longPressEnabled = enableLongPressGestures() @@ -142,8 +171,7 @@ open class GodotEditor : FullScreenGodotApp() { // Whether we should launch the new godot instance in an adjacent window // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT - var launchAdjacent = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode || isLargeScreen) + var launchAdjacent = shouldGameLaunchAdjacent() for (arg in args) { if (EDITOR_ARG == arg || EDITOR_ARG_SHORT == arg) { @@ -164,33 +192,48 @@ open class GodotEditor : FullScreenGodotApp() { // Launch a new activity val newInstance = Intent(this, targetClass) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .putExtra(COMMAND_LINE_PARAMS, args) + .putExtra(EXTRA_COMMAND_LINE_PARAMS, args) if (launchAdjacent) { newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT) } if (targetClass == javaClass) { - Log.d(TAG, "Restarting $targetClass") + Log.d(TAG, "Restarting $targetClass with parameters ${args.contentToString()}") ProcessPhoenix.triggerRebirth(this, newInstance) } else { - Log.d(TAG, "Starting $targetClass") + Log.d(TAG, "Starting $targetClass with parameters ${args.contentToString()}") startActivity(newInstance) } return instanceId } override fun onGodotForceQuit(godotInstanceId: Int): Boolean { - val processNameSuffix = when (godotInstanceId) { + val targetClass: Class<*>? + val processNameSuffix: String + when (godotInstanceId) { GAME_ID -> { - GAME_PROCESS_NAME_SUFFIX + processNameSuffix = GAME_PROCESS_NAME_SUFFIX + targetClass = GodotGame::class.java } EDITOR_ID -> { - EDITOR_PROCESS_NAME_SUFFIX + processNameSuffix = EDITOR_PROCESS_NAME_SUFFIX + targetClass = GodotEditor::class.java } PROJECT_MANAGER_ID -> { - PROJECT_MANAGER_PROCESS_NAME_SUFFIX + processNameSuffix = PROJECT_MANAGER_PROCESS_NAME_SUFFIX + targetClass = GodotProjectManager::class.java + } + else -> { + processNameSuffix = "" + targetClass = null } - else -> "" } + + if (targetClass == javaClass) { + Log.d(TAG, "Force quitting $targetClass") + ProcessPhoenix.forceQuit(this) + return true + } + if (processNameSuffix.isBlank()) { return false } @@ -199,8 +242,16 @@ open class GodotEditor : FullScreenGodotApp() { val runningProcesses = activityManager.runningAppProcesses for (runningProcess in runningProcesses) { if (runningProcess.processName.endsWith(processNameSuffix)) { - Log.v(TAG, "Killing Godot process ${runningProcess.processName}") - Process.killProcess(runningProcess.pid) + if (targetClass == null) { + // Killing process directly + Log.v(TAG, "Killing Godot process ${runningProcess.processName}") + Process.killProcess(runningProcess.pid) + } else { + // Activity is running; sending a request for self termination. + Log.v(TAG, "Sending force quit request to $targetClass running on process ${runningProcess.processName}") + val forceQuitIntent = Intent(this, targetClass).putExtra(EXTRA_FORCE_QUIT, true) + startActivity(forceQuitIntent) + } return true } } @@ -246,6 +297,26 @@ open class GodotEditor : FullScreenGodotApp() { protected open fun enablePanAndScaleGestures() = java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_pan_and_scale_gestures")) + private fun shouldGameLaunchAdjacent(): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + try { + when (Integer.parseInt(GodotLib.getEditorSetting("run/window_placement/android_window"))) { + ANDROID_WINDOW_SAME_AS_EDITOR -> false + ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR -> true + else -> { + // ANDROID_WINDOW_AUTO + isInMultiWindowMode || isLargeScreen + } + } + } catch (e: NumberFormatException) { + // Fall-back to the 'Auto' behavior + isInMultiWindowMode || isLargeScreen + } + } else { + false + } + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) // Check if we got the MANAGE_EXTERNAL_STORAGE permission diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt index e9bc435689..e26c9d39c2 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt @@ -231,7 +231,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi val x = terminusEvent.x val y = terminusEvent.y - if (terminusEvent.pointerCount >= 2 && panningAndScalingEnabled && !pointerCaptureInProgress) { + if (terminusEvent.pointerCount >= 2 && panningAndScalingEnabled && !pointerCaptureInProgress && !dragInProgress) { GodotLib.pan(x, y, distanceX / 5f, distanceY / 5f) } else if (!scaleInProgress){ dragInProgress = true @@ -241,7 +241,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi } override fun onScale(detector: ScaleGestureDetector): Boolean { - if (!panningAndScalingEnabled || pointerCaptureInProgress) { + if (!panningAndScalingEnabled || pointerCaptureInProgress || dragInProgress) { return false } @@ -256,7 +256,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi } override fun onScaleBegin(detector: ScaleGestureDetector): Boolean { - if (!panningAndScalingEnabled || pointerCaptureInProgress) { + if (!panningAndScalingEnabled || pointerCaptureInProgress || dragInProgress) { return false } scaleInProgress = true diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java b/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java index 3ee3478fcb..b1bce45fbb 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java @@ -90,7 +90,7 @@ public final class ProcessPhoenix extends Activity { */ public static void forceQuit(Activity activity, int pid) { Process.killProcess(pid); // Kill original main process - activity.finish(); + activity.finishAndRemoveTask(); Runtime.getRuntime().exit(0); // Kill kill kill! } diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h index 99e29bb53d..c113a13040 100644 --- a/platform/android/java_godot_io_wrapper.h +++ b/platform/android/java_godot_io_wrapper.h @@ -31,12 +31,13 @@ #ifndef JAVA_GODOT_IO_WRAPPER_H #define JAVA_GODOT_IO_WRAPPER_H -#include <android/log.h> -#include <jni.h> +#include "string_android.h" #include "core/math/rect2i.h" #include "core/variant/typed_array.h" -#include "string_android.h" + +#include <android/log.h> +#include <jni.h> // Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++ class GodotIOJavaWrapper { diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 63435853e9..7c1b6023c7 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -30,37 +30,36 @@ #include "java_godot_lib_jni.h" -#include "java_godot_io_wrapper.h" -#include "java_godot_wrapper.h" - -#include "android/asset_manager_jni.h" #include "android_input_handler.h" #include "api/java_class_wrapper.h" #include "api/jni_singleton.h" -#include "core/config/engine.h" -#include "core/config/project_settings.h" -#include "core/input/input.h" #include "dir_access_jandroid.h" #include "display_server_android.h" #include "file_access_android.h" #include "file_access_filesystem_jandroid.h" +#include "java_godot_io_wrapper.h" +#include "java_godot_wrapper.h" #include "jni_utils.h" -#include "main/main.h" #include "net_socket_android.h" #include "os_android.h" #include "string_android.h" #include "thread_jandroid.h" #include "tts_android.h" -#include <android/input.h> -#include <unistd.h> - -#include <android/native_window_jni.h> +#include "core/config/engine.h" +#include "core/config/project_settings.h" +#include "core/input/input.h" +#include "main/main.h" #ifdef TOOLS_ENABLED #include "editor/editor_settings.h" #endif +#include <android/asset_manager_jni.h> +#include <android/input.h> +#include <android/native_window_jni.h> +#include <unistd.h> + static JavaClassWrapper *java_class_wrapper = nullptr; static OS_Android *os_android = nullptr; static AndroidInputHandler *input_handler = nullptr; diff --git a/platform/android/java_godot_view_wrapper.h b/platform/android/java_godot_view_wrapper.h index 07742d6bb0..e5b04e4866 100644 --- a/platform/android/java_godot_view_wrapper.h +++ b/platform/android/java_godot_view_wrapper.h @@ -31,12 +31,13 @@ #ifndef JAVA_GODOT_VIEW_WRAPPER_H #define JAVA_GODOT_VIEW_WRAPPER_H +#include "string_android.h" + #include "core/math/vector2.h" + #include <android/log.h> #include <jni.h> -#include "string_android.h" - // Class that makes functions in java/src/org/godotengine/godot/GodotView.java callable from C++ class GodotJavaViewWrapper { private: diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index 245ab33dcf..1efdffd71b 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -31,13 +31,14 @@ #ifndef JAVA_GODOT_WRAPPER_H #define JAVA_GODOT_WRAPPER_H -#include <android/log.h> -#include <jni.h> - -#include "core/templates/list.h" #include "java_godot_view_wrapper.h" #include "string_android.h" +#include "core/templates/list.h" + +#include <android/log.h> +#include <jni.h> + // Class that makes functions in java/src/org/godotengine/godot/Godot.java callable from C++ class GodotJavaWrapper { private: diff --git a/platform/android/jni_utils.h b/platform/android/jni_utils.h index d1a4082ae5..c608f9ebaa 100644 --- a/platform/android/jni_utils.h +++ b/platform/android/jni_utils.h @@ -32,8 +32,10 @@ #define JNI_UTILS_H #include "string_android.h" -#include <core/config/engine.h> -#include <core/variant/variant.h> + +#include "core/config/engine.h" +#include "core/variant/variant.h" + #include <jni.h> struct jvalret { diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index a96dcca3b3..c3a7d70034 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -30,25 +30,24 @@ #include "os_android.h" +#include "dir_access_jandroid.h" +#include "display_server_android.h" +#include "file_access_android.h" +#include "file_access_filesystem_jandroid.h" +#include "java_godot_io_wrapper.h" +#include "java_godot_wrapper.h" +#include "net_socket_android.h" + #include "core/config/project_settings.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" -#include "platform/android/display_server_android.h" #include "scene/main/scene_tree.h" #include "servers/rendering_server.h" -#include "dir_access_jandroid.h" -#include "file_access_android.h" -#include "file_access_filesystem_jandroid.h" -#include "net_socket_android.h" - #include <dlfcn.h> #include <sys/system_properties.h> -#include "java_godot_io_wrapper.h" -#include "java_godot_wrapper.h" - const char *OS_Android::ANDROID_EXEC_PATH = "apk"; String _remove_symlink(const String &dir) { diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 99fe501975..abcc412588 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -32,6 +32,7 @@ #define OS_ANDROID_H #include "audio_driver_opensl.h" + #include "core/os/main_loop.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp index 843c015d49..5d48c4e248 100644 --- a/platform/android/plugin/godot_plugin_jni.cpp +++ b/platform/android/plugin/godot_plugin_jni.cpp @@ -30,12 +30,13 @@ #include "godot_plugin_jni.h" -#include <core/config/engine.h> -#include <core/config/project_settings.h> -#include <core/error/error_macros.h> -#include <platform/android/api/jni_singleton.h> -#include <platform/android/jni_utils.h> -#include <platform/android/string_android.h> +#include "api/jni_singleton.h" +#include "jni_utils.h" +#include "string_android.h" + +#include "core/config/engine.h" +#include "core/config/project_settings.h" +#include "core/error/error_macros.h" static HashMap<String, JNISingleton *> jni_singletons; diff --git a/platform/android/string_android.h b/platform/android/string_android.h index fe2f2e20a7..3f30b8ec3d 100644 --- a/platform/android/string_android.h +++ b/platform/android/string_android.h @@ -31,8 +31,10 @@ #ifndef STRING_ANDROID_H #define STRING_ANDROID_H -#include "core/string/ustring.h" #include "thread_jandroid.h" + +#include "core/string/ustring.h" + #include <jni.h> /** diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 5051c179ed..9f4140f70f 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -30,10 +30,10 @@ #include "thread_jandroid.h" -#include <android/log.h> - #include "core/os/thread.h" +#include <android/log.h> + static JavaVM *java_vm = nullptr; static thread_local JNIEnv *env = nullptr; diff --git a/platform/android/vulkan/vulkan_context_android.cpp b/platform/android/vulkan_context_android.cpp index ce4b1b7967..01e6d14438 100644 --- a/platform/android/vulkan/vulkan_context_android.cpp +++ b/platform/android/vulkan_context_android.cpp @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef VULKAN_ENABLED - #include "vulkan_context_android.h" +#ifdef VULKAN_ENABLED + #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/android/vulkan/vulkan_context_android.h b/platform/android/vulkan_context_android.h index f253149ef6..f253149ef6 100644 --- a/platform/android/vulkan/vulkan_context_android.h +++ b/platform/android/vulkan_context_android.h diff --git a/platform/ios/api/api.cpp b/platform/ios/api/api.cpp index 51afe05310..b8c9e7e9aa 100644 --- a/platform/ios/api/api.cpp +++ b/platform/ios/api/api.cpp @@ -45,4 +45,4 @@ void unregister_ios_api() { void register_ios_api() {} void unregister_ios_api() {} -#endif +#endif // IOS_ENABLED diff --git a/platform/ios/app_delegate.mm b/platform/ios/app_delegate.mm index 45f74e6b7b..38846e7508 100644 --- a/platform/ios/app_delegate.mm +++ b/platform/ios/app_delegate.mm @@ -30,13 +30,14 @@ #import "app_delegate.h" -#include "core/config/project_settings.h" -#include "drivers/coreaudio/audio_driver_coreaudio.h" #import "godot_view.h" -#include "main/main.h" -#include "os_ios.h" +#import "os_ios.h" #import "view_controller.h" +#include "core/config/project_settings.h" +#import "drivers/coreaudio/audio_driver_coreaudio.h" +#include "main/main.h" + #import <AVFoundation/AVFoundation.h> #import <AudioToolbox/AudioServices.h> diff --git a/platform/ios/display_layer.mm b/platform/ios/display_layer.mm index 3129ebb276..27cde1c6c2 100644 --- a/platform/ios/display_layer.mm +++ b/platform/ios/display_layer.mm @@ -30,11 +30,12 @@ #import "display_layer.h" +#import "display_server_ios.h" +#import "os_ios.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" -#include "display_server_ios.h" #include "main/main.h" -#include "os_ios.h" #include "servers/audio_server.h" #import <AudioToolbox/AudioServices.h> diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h index 57f601a858..b29bdeec62 100644 --- a/platform/ios/display_server_ios.h +++ b/platform/ios/display_server_ios.h @@ -35,17 +35,17 @@ #include "servers/display_server.h" #if defined(VULKAN_ENABLED) +#import "vulkan_context_ios.h" + #include "drivers/vulkan/rendering_device_vulkan.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" -#include "vulkan_context_ios.h" - #ifdef USE_VOLK #include <volk.h> #else #include <vulkan/vulkan.h> #endif -#endif +#endif // VULKAN_ENABLED #if defined(GLES3_ENABLED) #include "drivers/gles3/rasterizer_gles3.h" diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index a52d2b185d..bfb09b6861 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -28,20 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "display_server_ios.h" +#import "display_server_ios.h" #import "app_delegate.h" -#include "core/config/project_settings.h" -#include "core/io/file_access_pack.h" #import "device_metrics.h" #import "godot_view.h" -#include "ios.h" +#import "ios.h" #import "key_mapping_ios.h" #import "keyboard_input_view.h" -#include "os_ios.h" -#include "tts_ios.h" +#import "os_ios.h" +#import "tts_ios.h" #import "view_controller.h" +#include "core/config/project_settings.h" +#include "core/io/file_access_pack.h" + #import <sys/utsname.h> static const float kDisplayServerIOSAcceleration = 1.f; @@ -567,6 +568,11 @@ float DisplayServerIOS::screen_get_max_scale() const { void DisplayServerIOS::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) { screen_orientation = p_orientation; + if (@available(iOS 16.0, *)) { + [AppDelegate.viewController setNeedsUpdateOfSupportedInterfaceOrientations]; + } else { + [UIViewController attemptRotationToDeviceOrientation]; + } } DisplayServer::ScreenOrientation DisplayServerIOS::screen_get_orientation(int p_screen) const { diff --git a/platform/ios/export/export.cpp b/platform/ios/export/export.cpp index f4b90d8883..e07a135861 100644 --- a/platform/ios/export/export.cpp +++ b/platform/ios/export/export.cpp @@ -30,9 +30,10 @@ #include "export.h" -#include "editor/export/editor_export.h" #include "export_plugin.h" +#include "editor/export/editor_export.h" + void register_ios_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformIOS); } diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 06741a12e4..ae0d120513 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -30,11 +30,12 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" + #include "core/string/translation.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/export/editor_export.h" -#include "platform/ios/logo_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 9afefef121..2e461c8ed6 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -31,6 +31,8 @@ #ifndef IOS_EXPORT_PLUGIN_H #define IOS_EXPORT_PLUGIN_H +#include "godot_plugin_config.h" + #include "core/config/project_settings.h" #include "core/io/file_access.h" #include "core/io/image_loader.h" @@ -43,10 +45,8 @@ #include "editor/editor_settings.h" #include "editor/export/editor_export_platform.h" #include "main/splash.gen.h" -#include "string.h" - -#include "godot_plugin_config.h" +#include <string.h> #include <sys/stat.h> // Optional environment variables for defining confidential information. If any diff --git a/platform/ios/godot_ios.mm b/platform/ios/godot_ios.mm index b01e339211..5e66c8b47b 100644 --- a/platform/ios/godot_ios.mm +++ b/platform/ios/godot_ios.mm @@ -28,9 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#import "os_ios.h" + #include "core/string/ustring.h" #include "main/main.h" -#include "os_ios.h" #include <stdio.h> #include <string.h> diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index ff04ea9838..4c9a75fdc0 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -30,12 +30,13 @@ #import "godot_view.h" +#import "display_layer.h" +#import "display_server_ios.h" +#import "godot_view_renderer.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" #include "core/string/ustring.h" -#import "display_layer.h" -#include "display_server_ios.h" -#import "godot_view_renderer.h" #import <CoreMotion/CoreMotion.h> diff --git a/platform/ios/godot_view_renderer.mm b/platform/ios/godot_view_renderer.mm index 714952943b..9c56ca342f 100644 --- a/platform/ios/godot_view_renderer.mm +++ b/platform/ios/godot_view_renderer.mm @@ -30,11 +30,12 @@ #import "godot_view_renderer.h" +#import "display_server_ios.h" +#import "os_ios.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" -#import "display_server_ios.h" #include "main/main.h" -#include "os_ios.h" #include "servers/audio_server.h" #import <AudioToolbox/AudioServices.h> diff --git a/platform/ios/ios.h b/platform/ios/ios.h index ec2dbd5bf2..d488cde257 100644 --- a/platform/ios/ios.h +++ b/platform/ios/ios.h @@ -32,6 +32,7 @@ #define IOS_H #include "core/object/class_db.h" + #import <CoreHaptics/CoreHaptics.h> class iOS : public Object { diff --git a/platform/ios/ios.mm b/platform/ios/ios.mm index c911a512a5..0a2e1fd5cd 100644 --- a/platform/ios/ios.mm +++ b/platform/ios/ios.mm @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "ios.h" +#import "ios.h" #import "app_delegate.h" #import "view_controller.h" diff --git a/platform/ios/joypad_ios.mm b/platform/ios/joypad_ios.mm index 421c82dfc4..38d3ce728a 100644 --- a/platform/ios/joypad_ios.mm +++ b/platform/ios/joypad_ios.mm @@ -30,13 +30,12 @@ #import "joypad_ios.h" -#include "core/config/project_settings.h" -#include "drivers/coreaudio/audio_driver_coreaudio.h" -#include "main/main.h" - #import "godot_view.h" +#import "os_ios.h" -#include "os_ios.h" +#include "core/config/project_settings.h" +#import "drivers/coreaudio/audio_driver_coreaudio.h" +#include "main/main.h" JoypadIOS::JoypadIOS() { observer = [[JoypadIOSObserver alloc] init]; diff --git a/platform/ios/key_mapping_ios.mm b/platform/ios/key_mapping_ios.mm index c378186778..d2c84884d1 100644 --- a/platform/ios/key_mapping_ios.mm +++ b/platform/ios/key_mapping_ios.mm @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "key_mapping_ios.h" +#import "key_mapping_ios.h" #include "core/templates/hash_map.h" diff --git a/platform/ios/keyboard_input_view.mm b/platform/ios/keyboard_input_view.mm index 2764403d68..bc6eb63ed5 100644 --- a/platform/ios/keyboard_input_view.mm +++ b/platform/ios/keyboard_input_view.mm @@ -30,9 +30,10 @@ #import "keyboard_input_view.h" +#import "display_server_ios.h" +#import "os_ios.h" + #include "core/os/keyboard.h" -#include "display_server_ios.h" -#include "os_ios.h" @interface GodotKeyboardInputView () <UITextViewDelegate> diff --git a/platform/ios/os_ios.h b/platform/ios/os_ios.h index cc95e4cdde..9dc5e11497 100644 --- a/platform/ios/os_ios.h +++ b/platform/ios/os_ios.h @@ -33,16 +33,18 @@ #ifdef IOS_ENABLED -#include "drivers/coreaudio/audio_driver_coreaudio.h" +#import "ios.h" +#import "joypad_ios.h" + +#import "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/unix/os_unix.h" -#include "ios.h" -#include "joypad_ios.h" #include "servers/audio_server.h" #include "servers/rendering/renderer_compositor.h" #if defined(VULKAN_ENABLED) +#import "vulkan_context_ios.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/ios/vulkan_context_ios.h" #endif class OS_IOS : public OS_Unix { diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 739db419a3..461c226070 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -28,20 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef IOS_ENABLED +#import "os_ios.h" -#include "os_ios.h" +#ifdef IOS_ENABLED #import "app_delegate.h" +#import "display_server_ios.h" +#import "godot_view.h" +#import "view_controller.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_ios.h" #include "drivers/unix/syslog_logger.h" -#import "godot_view.h" #include "main/main.h" -#import "view_controller.h" #import <AudioToolbox/AudioServices.h> #import <CoreText/CoreText.h> @@ -51,6 +52,7 @@ #if defined(VULKAN_ENABLED) #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" + #import <QuartzCore/CAMetalLayer.h> #ifdef USE_VOLK #include <volk.h> diff --git a/platform/ios/tts_ios.h b/platform/ios/tts_ios.h index 7f9d30b22b..217f55da66 100644 --- a/platform/ios/tts_ios.h +++ b/platform/ios/tts_ios.h @@ -31,18 +31,18 @@ #ifndef TTS_IOS_H #define TTS_IOS_H -#if __has_include(<AVFAudio/AVSpeechSynthesis.h>) -#import <AVFAudio/AVSpeechSynthesis.h> -#else -#import <AVFoundation/AVFoundation.h> -#endif - #include "core/string/ustring.h" #include "core/templates/hash_map.h" #include "core/templates/list.h" #include "core/variant/array.h" #include "servers/display_server.h" +#if __has_include(<AVFAudio/AVSpeechSynthesis.h>) +#import <AVFAudio/AVSpeechSynthesis.h> +#else +#import <AVFoundation/AVFoundation.h> +#endif + @interface TTS_IOS : NSObject <AVSpeechSynthesizerDelegate> { bool speaking; HashMap<id, int> ids; diff --git a/platform/ios/tts_ios.mm b/platform/ios/tts_ios.mm index ee0d6e8591..33b30b17c9 100644 --- a/platform/ios/tts_ios.mm +++ b/platform/ios/tts_ios.mm @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "tts_ios.h" +#import "tts_ios.h" @implementation TTS_IOS diff --git a/platform/ios/view_controller.mm b/platform/ios/view_controller.mm index 8709252623..0ef61da646 100644 --- a/platform/ios/view_controller.mm +++ b/platform/ios/view_controller.mm @@ -29,13 +29,15 @@ /**************************************************************************/ #import "view_controller.h" -#include "core/config/project_settings.h" -#include "display_server_ios.h" + +#import "display_server_ios.h" #import "godot_view.h" #import "godot_view_renderer.h" #import "key_mapping_ios.h" #import "keyboard_input_view.h" -#include "os_ios.h" +#import "os_ios.h" + +#include "core/config/project_settings.h" #import <AVFoundation/AVFoundation.h> #import <GameController/GameController.h> diff --git a/platform/ios/vulkan_context_ios.mm b/platform/ios/vulkan_context_ios.mm index c48ff841f2..56f1894e06 100644 --- a/platform/ios/vulkan_context_ios.mm +++ b/platform/ios/vulkan_context_ios.mm @@ -28,9 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#import "vulkan_context_ios.h" + #ifdef VULKAN_ENABLED -#include "vulkan_context_ios.h" #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml b/platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml index 4ab2464929..77a6ece756 100644 --- a/platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml +++ b/platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml @@ -23,8 +23,8 @@ <member name="custom_template/release" type="String" setter="" getter=""> Path to the custom export template. If left empty, default template is used. </member> - <member name="debug/export_console_script" type="int" setter="" getter=""> - If [code]true[/code], a console wrapper script is exported alongside the main executable, which allows running the project with enabled console output. + <member name="debug/export_console_wrapper" type="int" setter="" getter=""> + If [code]true[/code], a console wrapper is exported alongside the main executable, which allows running the project with enabled console output. </member> <member name="ssh_remote_deploy/cleanup_script" type="String" setter="" getter=""> Script code to execute on the remote host when app is finished. diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp index 09f354246d..f72c079d1d 100644 --- a/platform/linuxbsd/export/export.cpp +++ b/platform/linuxbsd/export/export.cpp @@ -30,9 +30,10 @@ #include "export.h" -#include "editor/export/editor_export.h" #include "export_plugin.h" +#include "editor/export/editor_export.h" + void register_linuxbsd_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformLinuxBSD); } diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index 9544cc761d..082040c8d6 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -30,13 +30,14 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" + #include "core/config/project_settings.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/export/editor_export.h" -#include "platform/linuxbsd/logo_svg.gen.h" -#include "platform/linuxbsd/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED @@ -94,15 +95,15 @@ Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset> return err; } - // Save console script. + // Save console wrapper. if (err == OK) { - int con_scr = p_preset->get("debug/export_console_script"); + int con_scr = p_preset->get("debug/export_console_wrapper"); if ((con_scr == 1 && p_debug) || (con_scr == 2)) { String scr_path = path.get_basename() + ".sh"; err = _export_debug_script(p_preset, pkg_name, path.get_file(), scr_path); FileAccess::set_unix_permissions(scr_path, 0755); if (err != OK) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), TTR("Could not create console script.")); + add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Console Export"), TTR("Could not create console wrapper.")); } } } diff --git a/platform/linuxbsd/freedesktop_portal_desktop.cpp b/platform/linuxbsd/freedesktop_portal_desktop.cpp index 6dfa8ed93c..c3cb0f411d 100644 --- a/platform/linuxbsd/freedesktop_portal_desktop.cpp +++ b/platform/linuxbsd/freedesktop_portal_desktop.cpp @@ -35,6 +35,7 @@ #include "core/error/error_macros.h" #include "core/os/os.h" #include "core/string/ustring.h" +#include "core/variant/variant.h" #ifdef SOWRAP_ENABLED #include "dbus-so_wrap.h" @@ -42,8 +43,6 @@ #include <dbus/dbus.h> #endif -#include "core/variant/variant.h" - #define BUS_OBJECT_NAME "org.freedesktop.portal.Desktop" #define BUS_OBJECT_PATH "/org/freedesktop/portal/desktop" diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp index 76d579dd53..d059d60b72 100644 --- a/platform/linuxbsd/godot_linuxbsd.cpp +++ b/platform/linuxbsd/godot_linuxbsd.cpp @@ -28,6 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#include "os_linuxbsd.h" + +#include "main/main.h" + #include <limits.h> #include <locale.h> #include <stdlib.h> @@ -37,9 +41,6 @@ #include <sys/resource.h> #endif -#include "main/main.h" -#include "os_linuxbsd.h" - int main(int argc, char *argv[]) { #if defined(SANITIZERS_ENABLED) // Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times. diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h index 6661abdb37..26a9908d4e 100644 --- a/platform/linuxbsd/joypad_linux.h +++ b/platform/linuxbsd/joypad_linux.h @@ -32,6 +32,7 @@ #define JOYPAD_LINUX_H #ifdef JOYDEV_ENABLED + #include "core/input/input.h" #include "core/os/mutex.h" #include "core/os/thread.h" diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 2c093b00e7..ebdbd061d1 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -35,17 +35,13 @@ #include "main/main.h" #include "servers/display_server.h" -#include "modules/modules_enabled.gen.h" // For regex. -#ifdef MODULE_REGEX_ENABLED -#include "modules/regex/regex.h" -#endif - #ifdef X11_ENABLED #include "x11/display_server_x11.h" #endif -#ifdef HAVE_MNTENT -#include <mntent.h> +#include "modules/modules_enabled.gen.h" // For regex. +#ifdef MODULE_REGEX_ENABLED +#include "modules/regex/regex.h" #endif #include <dlfcn.h> @@ -57,6 +53,10 @@ #include <sys/utsname.h> #include <unistd.h> +#ifdef HAVE_MNTENT +#include <mntent.h> +#endif + void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) { const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; @@ -252,7 +252,7 @@ String OS_LinuxBSD::get_version() const { } Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const { - if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) { + if (RenderingServer::get_singleton() == nullptr) { return Vector<String>(); } @@ -261,8 +261,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const { return info; } - const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); // e.g. `NVIDIA GeForce GTX 970` - const String rendering_device_vendor = RenderingServer::get_singleton()->get_rendering_device()->get_device_vendor_name(); // e.g. `NVIDIA` + const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); // e.g. `NVIDIA GeForce GTX 970` + const String rendering_device_vendor = RenderingServer::get_singleton()->get_video_adapter_vendor(); // e.g. `NVIDIA` const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970` String vendor_device_id_mappings; diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index c1e735b0d4..007b90b82b 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -31,13 +31,14 @@ #ifndef OS_LINUXBSD_H #define OS_LINUXBSD_H -#include "core/input/input.h" #include "crash_handler_linuxbsd.h" +#include "joypad_linux.h" + +#include "core/input/input.h" #include "drivers/alsa/audio_driver_alsa.h" #include "drivers/alsamidi/midi_driver_alsamidi.h" #include "drivers/pulseaudio/audio_driver_pulseaudio.h" #include "drivers/unix/os_unix.h" -#include "joypad_linux.h" #include "servers/audio_server.h" #ifdef FONTCONFIG_ENABLED diff --git a/platform/linuxbsd/x11/detect_prime_x11.cpp b/platform/linuxbsd/x11/detect_prime_x11.cpp index 78778a8b56..2b5776ce54 100644 --- a/platform/linuxbsd/x11/detect_prime_x11.cpp +++ b/platform/linuxbsd/x11/detect_prime_x11.cpp @@ -28,29 +28,26 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef X11_ENABLED -#if defined(GLES3_ENABLED) +#if defined(X11_ENABLED) && defined(GLES3_ENABLED) #include "detect_prime_x11.h" #include "core/string/print_string.h" #include "core/string/ustring.h" -#include <stdlib.h> - #include "thirdparty/glad/glad/gl.h" #include "thirdparty/glad/glad/glx.h" #ifdef SOWRAP_ENABLED -#include "dynwrappers/xlib-so_wrap.h" +#include "x11/dynwrappers/xlib-so_wrap.h" #else #include <X11/XKBlib.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #endif -#include <cstring> - +#include <stdlib.h> +#include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> @@ -265,5 +262,4 @@ int detect_prime() { return preferred; } -#endif -#endif +#endif // X11_ENABLED && GLES3_ENABLED diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index fa35340ebb..83b6fb7628 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -32,12 +32,13 @@ #ifdef X11_ENABLED +#include "x11/detect_prime_x11.h" +#include "x11/key_mapping_x11.h" + #include "core/config/project_settings.h" #include "core/math/math_funcs.h" #include "core/string/print_string.h" #include "core/string/ustring.h" -#include "detect_prime_x11.h" -#include "key_mapping_x11.h" #include "main/main.h" #include "scene/resources/texture.h" @@ -58,6 +59,9 @@ #include <sys/types.h> #include <unistd.h> +#undef CursorShape +#include <X11/XKBlib.h> + // ICCCM #define WM_NormalState 1L // window normal state #define WM_IconicState 3L // window minimized @@ -65,9 +69,6 @@ #define _NET_WM_STATE_REMOVE 0L // remove/unset property #define _NET_WM_STATE_ADD 1L // add/set property -#undef CursorShape -#include <X11/XKBlib.h> - // 2.2 is the first release with multitouch #define XINPUT_CLIENT_VERSION_MAJOR 2 #define XINPUT_CLIENT_VERSION_MINOR 2 @@ -869,7 +870,7 @@ int default_window_error_handler(Display *display, XErrorEvent *error) { "\n Major opcode of failed request: %d" "\n Serial number of failed request: %d" "\n Current serial number in output stream: %d", - String::utf8(message), error->request_code, error->minor_code, error->serial)); + String::utf8(message), (uint64_t)error->request_code, (uint64_t)error->minor_code, (uint64_t)error->serial)); return 0; } diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h index fd3a5dccfa..176a1ffb9a 100644 --- a/platform/linuxbsd/x11/display_server_x11.h +++ b/platform/linuxbsd/x11/display_server_x11.h @@ -33,7 +33,7 @@ #ifdef X11_ENABLED -#include "servers/display_server.h" +#include "joypad_linux.h" #include "core/input/input.h" #include "core/os/mutex.h" @@ -43,27 +43,28 @@ #include "drivers/alsamidi/midi_driver_alsamidi.h" #include "drivers/pulseaudio/audio_driver_pulseaudio.h" #include "drivers/unix/os_unix.h" -#include "joypad_linux.h" #include "servers/audio_server.h" +#include "servers/display_server.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering_server.h" #if defined(SPEECHD_ENABLED) -#include "../tts_linux.h" +#include "tts_linux.h" #endif #if defined(GLES3_ENABLED) -#include "gl_manager_x11.h" +#include "x11/gl_manager_x11.h" #endif #if defined(VULKAN_ENABLED) +#include "x11/vulkan_context_x11.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "vulkan_context_x11.h" #endif #if defined(DBUS_ENABLED) -#include "../freedesktop_portal_desktop.h" -#include "../freedesktop_screensaver.h" +#include "freedesktop_portal_desktop.h" +#include "freedesktop_screensaver.h" #endif #include <X11/Xatom.h> @@ -72,16 +73,16 @@ #include <X11/keysym.h> #ifdef SOWRAP_ENABLED -#include "dynwrappers/xlib-so_wrap.h" +#include "x11/dynwrappers/xlib-so_wrap.h" -#include "dynwrappers/xcursor-so_wrap.h" -#include "dynwrappers/xext-so_wrap.h" -#include "dynwrappers/xinerama-so_wrap.h" -#include "dynwrappers/xinput2-so_wrap.h" -#include "dynwrappers/xrandr-so_wrap.h" -#include "dynwrappers/xrender-so_wrap.h" +#include "x11/dynwrappers/xcursor-so_wrap.h" +#include "x11/dynwrappers/xext-so_wrap.h" +#include "x11/dynwrappers/xinerama-so_wrap.h" +#include "x11/dynwrappers/xinput2-so_wrap.h" +#include "x11/dynwrappers/xrandr-so_wrap.h" +#include "x11/dynwrappers/xrender-so_wrap.h" -#include "../xkbcommon-so_wrap.h" +#include "xkbcommon-so_wrap.h" #else #include <X11/XKBlib.h> #include <X11/Xlib.h> @@ -521,6 +522,6 @@ public: ~DisplayServerX11(); }; -#endif // X11 enabled +#endif // X11_ENABLED #endif // DISPLAY_SERVER_X11_H diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index 1e579c9f01..f24bac5e19 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -30,15 +30,14 @@ #include "gl_manager_x11.h" -#ifdef X11_ENABLED -#if defined(GLES3_ENABLED) +#if defined(X11_ENABLED) && defined(GLES3_ENABLED) + +#include "thirdparty/glad/glad/glx.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include "thirdparty/glad/glad/glx.h" - #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 @@ -403,5 +402,4 @@ GLManager_X11::~GLManager_X11() { release_current(); } -#endif -#endif +#endif // X11_ENABLED && GLES3_ENABLED diff --git a/platform/linuxbsd/x11/gl_manager_x11.h b/platform/linuxbsd/x11/gl_manager_x11.h index 0203dff679..59e20fec45 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.h +++ b/platform/linuxbsd/x11/gl_manager_x11.h @@ -31,12 +31,11 @@ #ifndef GL_MANAGER_X11_H #define GL_MANAGER_X11_H -#ifdef X11_ENABLED - -#ifdef GLES3_ENABLED +#if defined(X11_ENABLED) && defined(GLES3_ENABLED) #include "core/os/os.h" #include "core/templates/local_vector.h" +#include "servers/display_server.h" #ifdef SOWRAP_ENABLED #include "dynwrappers/xlib-so_wrap.h" @@ -53,8 +52,6 @@ #include <X11/extensions/shape.h> #endif -#include "servers/display_server.h" - struct GLManager_X11_Private; class GLManager_X11 { @@ -136,7 +133,6 @@ public: ~GLManager_X11(); }; -#endif // GLES3_ENABLED -#endif // X11_ENABLED +#endif // X11_ENABLED && GLES3_ENABLED #endif // GL_MANAGER_X11_H diff --git a/platform/linuxbsd/x11/key_mapping_x11.h b/platform/linuxbsd/x11/key_mapping_x11.h index 48beefff4c..ae8fd67f27 100644 --- a/platform/linuxbsd/x11/key_mapping_x11.h +++ b/platform/linuxbsd/x11/key_mapping_x11.h @@ -31,16 +31,17 @@ #ifndef KEY_MAPPING_X11_H #define KEY_MAPPING_X11_H +#include "core/os/keyboard.h" +#include "core/templates/hash_map.h" + #include <X11/XF86keysym.h> #include <X11/Xlib.h> + #define XK_MISCELLANY #define XK_LATIN1 #define XK_XKB_KEYS #include <X11/keysymdef.h> -#include "core/os/keyboard.h" -#include "core/templates/hash_map.h" - class KeyMappingX11 { struct HashMapHasherKeys { static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } diff --git a/platform/linuxbsd/x11/vulkan_context_x11.h b/platform/linuxbsd/x11/vulkan_context_x11.h index d093bca853..294fdc710e 100644 --- a/platform/linuxbsd/x11/vulkan_context_x11.h +++ b/platform/linuxbsd/x11/vulkan_context_x11.h @@ -34,6 +34,7 @@ #ifdef VULKAN_ENABLED #include "drivers/vulkan/vulkan_context.h" + #include <X11/Xlib.h> class VulkanContextX11 : public VulkanContext { diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index 495dc43c55..5944cc8abd 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -31,8 +31,6 @@ #ifndef DISPLAY_SERVER_MACOS_H #define DISPLAY_SERVER_MACOS_H -#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition. - #include "core/input/input.h" #include "servers/display_server.h" @@ -41,10 +39,13 @@ #endif // GLES3_ENABLED #if defined(VULKAN_ENABLED) +#include "vulkan_context_macos.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/macos/vulkan_context_macos.h" #endif // VULKAN_ENABLED +#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition. + #import <AppKit/AppKit.h> #import <AppKit/NSCursor.h> #import <ApplicationServices/ApplicationServices.h> diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index c24115d705..b77715d648 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -38,7 +38,6 @@ #include "godot_window_delegate.h" #include "key_mapping_macos.h" #include "os_macos.h" - #include "tts_macos.h" #include "core/config/project_settings.h" @@ -48,13 +47,6 @@ #include "main/main.h" #include "scene/resources/texture.h" -#import <Carbon/Carbon.h> -#import <Cocoa/Cocoa.h> -#import <IOKit/IOCFPlugIn.h> -#import <IOKit/IOKitLib.h> -#import <IOKit/hid/IOHIDKeys.h> -#import <IOKit/hid/IOHIDLib.h> - #if defined(GLES3_ENABLED) #include "drivers/gles3/rasterizer_gles3.h" #endif @@ -63,6 +55,13 @@ #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #endif +#import <Carbon/Carbon.h> +#import <Cocoa/Cocoa.h> +#import <IOKit/IOCFPlugIn.h> +#import <IOKit/IOKitLib.h> +#import <IOKit/hid/IOHIDKeys.h> +#import <IOKit/hid/IOHIDLib.h> + const NSMenu *DisplayServerMacOS::_get_menu_root(const String &p_menu_root) const { const NSMenu *menu = nullptr; if (p_menu_root == "" || p_menu_root.to_lower() == "_main") { @@ -2339,7 +2338,7 @@ void DisplayServerMacOS::show_window(WindowID p_id) { popup_open(p_id); if ([wd.window_object isMiniaturized]) { return; - } else if (wd.no_focus || wd.is_popup) { + } else if (wd.no_focus) { [wd.window_object orderFront:nil]; } else { [wd.window_object makeKeyAndOrderFront:nil]; @@ -2973,7 +2972,7 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win if ([wd.window_object isVisible]) { if ([wd.window_object isMiniaturized]) { return; - } else if (wd.no_focus || wd.is_popup) { + } else if (wd.no_focus) { [wd.window_object orderFront:nil]; } else { [wd.window_object makeKeyAndOrderFront:nil]; diff --git a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml index d030995ee7..cef837de07 100644 --- a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml +++ b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml @@ -148,8 +148,8 @@ <member name="custom_template/release" type="String" setter="" getter=""> Path to the custom export template. If left empty, default template is used. </member> - <member name="debug/export_console_script" type="int" setter="" getter=""> - If enabled, a script file that can be used to run the application with console output is created alongside the exported application. + <member name="debug/export_console_wrapper" type="int" setter="" getter=""> + If enabled, a wrapper that can be used to run the application with console output is created alongside the exported application. </member> <member name="display/high_res" type="bool" setter="" getter=""> If [code]true[/code], the application is rendered at native display resolution, otherwise it is always rendered at loHPI resolution and upscaled by OS when required. diff --git a/platform/macos/export/codesign.h b/platform/macos/export/codesign.h index 3be15b4ac0..3e61751a96 100644 --- a/platform/macos/export/codesign.h +++ b/platform/macos/export/codesign.h @@ -41,6 +41,8 @@ // - Requirements code generator is not implemented (only hard-coded requirements for the ad-hoc signing is supported). // - RFC5652/CMS blob generation is not implemented, supports ad-hoc signing only. +#include "plist.h" + #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" @@ -51,8 +53,6 @@ #include "modules/regex/regex.h" #endif -#include "plist.h" - #ifdef MODULE_REGEX_ENABLED /*************************************************************************/ diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index f0fa5f2d36..802c8d42c3 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -30,6 +30,8 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" #include "codesign.h" #include "lipo.h" #include "macho.h" @@ -39,8 +41,6 @@ #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" -#include "platform/macos/logo_svg.gen.h" -#include "platform/macos/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg and regex. #ifdef MODULE_SVG_ENABLED @@ -368,7 +368,7 @@ 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"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_wrapper", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.icns,*.png,*.webp,*.svg"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "", false, true)); @@ -1739,14 +1739,14 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p err = ERR_FILE_NOT_FOUND; } - // Save console script. + // Save console wrapper. if (err == OK) { - int con_scr = p_preset->get("debug/export_console_script"); + int con_scr = p_preset->get("debug/export_console_wrapper"); if ((con_scr == 1 && p_debug) || (con_scr == 2)) { err = _export_debug_script(p_preset, pkg_name, tmp_app_path_name.get_file() + "/Contents/MacOS/" + pkg_name, scr_path); FileAccess::set_unix_permissions(scr_path, 0755); if (err != OK) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Could not create console script.")); + add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Could not create console wrapper.")); } } } diff --git a/platform/macos/export/lipo.h b/platform/macos/export/lipo.h index 6a54e47026..e375fc5a66 100644 --- a/platform/macos/export/lipo.h +++ b/platform/macos/export/lipo.h @@ -33,11 +33,11 @@ // Universal / Universal 2 fat binary file creator and extractor. +#include "macho.h" + #include "core/io/file_access.h" #include "core/object/ref_counted.h" -#include "macho.h" - class LipO : public RefCounted { struct FatArch { uint32_t cputype; diff --git a/platform/macos/gl_manager_macos_legacy.h b/platform/macos/gl_manager_macos_legacy.h index c33b803d81..94d966f4ed 100644 --- a/platform/macos/gl_manager_macos_legacy.h +++ b/platform/macos/gl_manager_macos_legacy.h @@ -33,9 +33,6 @@ #if defined(MACOS_ENABLED) && defined(GLES3_ENABLED) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14 - #include "core/error/error_list.h" #include "core/os/os.h" #include "core/templates/local_vector.h" @@ -45,6 +42,9 @@ #import <ApplicationServices/ApplicationServices.h> #import <CoreVideo/CoreVideo.h> +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14 + class GLManager_MacOS { public: enum ContextType { diff --git a/platform/macos/gl_manager_macos_legacy.mm b/platform/macos/gl_manager_macos_legacy.mm index 65e978bfe6..550e2d5c59 100644 --- a/platform/macos/gl_manager_macos_legacy.mm +++ b/platform/macos/gl_manager_macos_legacy.mm @@ -30,15 +30,14 @@ #include "gl_manager_macos_legacy.h" -#ifdef MACOS_ENABLED -#ifdef GLES3_ENABLED - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14 +#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED) #include <stdio.h> #include <stdlib.h> +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14 + Error GLManager_MacOS::create_context(GLWindow &win) { NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFADoubleBuffer, @@ -237,5 +236,4 @@ GLManager_MacOS::~GLManager_MacOS() { #pragma clang diagnostic pop -#endif // GLES3_ENABLED -#endif // MACOS_ENABLED +#endif // MACOS_ENABLED && GLES3_ENABLED diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index 9f5bb2ef5c..3467bf90a1 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -32,6 +32,7 @@ #include "display_server_macos.h" #include "key_mapping_macos.h" + #include "main/main.h" @implementation GodotContentLayerDelegate @@ -341,7 +342,7 @@ } DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); - return !wd.no_focus && !wd.is_popup; + return !wd.no_focus; } - (BOOL)acceptsFirstResponder { diff --git a/platform/macos/godot_main_macos.mm b/platform/macos/godot_main_macos.mm index e98ab08127..58263471b0 100644 --- a/platform/macos/godot_main_macos.mm +++ b/platform/macos/godot_main_macos.mm @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "main/main.h" - #include "os_macos.h" +#include "main/main.h" + #include <string.h> #include <unistd.h> diff --git a/platform/macos/godot_window.mm b/platform/macos/godot_window.mm index 43495e069a..f4516e5c85 100644 --- a/platform/macos/godot_window.mm +++ b/platform/macos/godot_window.mm @@ -65,7 +65,7 @@ } DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); - return !wd.no_focus && !wd.is_popup; + return !wd.no_focus; } - (BOOL)canBecomeMainWindow { diff --git a/platform/macos/joypad_macos.h b/platform/macos/joypad_macos.h index d266af7b0d..6a2af11b51 100644 --- a/platform/macos/joypad_macos.h +++ b/platform/macos/joypad_macos.h @@ -31,13 +31,13 @@ #ifndef JOYPAD_MACOS_H #define JOYPAD_MACOS_H +#include "core/input/input.h" + #import <ForceFeedback/ForceFeedback.h> #import <ForceFeedback/ForceFeedbackConstants.h> #import <IOKit/hid/IOHIDLib.h> #import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h> -#include "core/input/input.h" - struct rec_element { IOHIDElementRef ref; IOHIDElementCookie cookie; diff --git a/platform/macos/key_mapping_macos.mm b/platform/macos/key_mapping_macos.mm index 7f64ebb734..db3fa4e02d 100644 --- a/platform/macos/key_mapping_macos.mm +++ b/platform/macos/key_mapping_macos.mm @@ -30,12 +30,12 @@ #include "key_mapping_macos.h" -#import <Carbon/Carbon.h> -#import <Cocoa/Cocoa.h> - #include "core/templates/hash_map.h" #include "core/templates/hash_set.h" +#import <Carbon/Carbon.h> +#import <Cocoa/Cocoa.h> + struct HashMapHasherKeys { static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } diff --git a/platform/macos/os_macos.h b/platform/macos/os_macos.h index 07bae479be..ab61649d19 100644 --- a/platform/macos/os_macos.h +++ b/platform/macos/os_macos.h @@ -31,12 +31,13 @@ #ifndef OS_MACOS_H #define OS_MACOS_H -#include "core/input/input.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_macos.h" + +#include "core/input/input.h" +#import "drivers/coreaudio/audio_driver_coreaudio.h" +#import "drivers/coremidi/midi_driver_coremidi.h" +#include "drivers/unix/os_unix.h" #include "servers/audio_server.h" class OS_MacOS : public OS_Unix { @@ -120,6 +121,7 @@ public: virtual Error move_to_trash(const String &p_path) override; virtual String get_system_ca_certificates() override; + virtual OS::PreferredTextureFormat get_preferred_texture_format() const override; void run(); diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index 838ae742fd..fe6d8d9fb0 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -30,16 +30,16 @@ #include "os_macos.h" -#include "core/crypto/crypto_core.h" -#include "core/version_generated.gen.h" -#include "main/main.h" - #include "dir_access_macos.h" #include "display_server_macos.h" #include "godot_application.h" #include "godot_application_delegate.h" #include "macos_terminal_logger.h" +#include "core/crypto/crypto_core.h" +#include "core/version_generated.gen.h" +#include "main/main.h" + #include <dlfcn.h> #include <libproc.h> #include <mach-o/dyld.h> @@ -700,6 +700,12 @@ String OS_MacOS::get_system_ca_certificates() { return certs; } +OS::PreferredTextureFormat OS_MacOS::get_preferred_texture_format() const { + // macOS supports both formats on ARM. Prefer S3TC/BPTC + // for better compatibility with x86 platforms. + return PREFERRED_TEXTURE_FORMAT_S3TC_BPTC; +} + void OS_MacOS::run() { if (!main_loop) { return; diff --git a/platform/macos/vulkan_context_macos.h b/platform/macos/vulkan_context_macos.h index ab10912e70..ab019384e2 100644 --- a/platform/macos/vulkan_context_macos.h +++ b/platform/macos/vulkan_context_macos.h @@ -34,6 +34,7 @@ #ifdef VULKAN_ENABLED #include "drivers/vulkan/vulkan_context.h" + #import <AppKit/AppKit.h> class VulkanContextMacOS : public VulkanContext { diff --git a/platform/macos/vulkan_context_macos.mm b/platform/macos/vulkan_context_macos.mm index 454fb84859..46a2d9f86a 100644 --- a/platform/macos/vulkan_context_macos.mm +++ b/platform/macos/vulkan_context_macos.mm @@ -28,8 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef VULKAN_ENABLED #include "vulkan_context_macos.h" + +#ifdef VULKAN_ENABLED + #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/uwp/app_uwp.cpp b/platform/uwp/app_uwp.cpp index ddefa19708..789adb5e5b 100644 --- a/platform/uwp/app_uwp.cpp +++ b/platform/uwp/app_uwp.cpp @@ -28,17 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -// -// This file demonstrates how to initialize EGL in a Windows Store app, using ICoreWindow. -// - #include "app_uwp.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/os/keyboard.h" #include "main/main.h" - #include "platform/windows/key_mapping_windows.h" #include <collection.h> diff --git a/platform/uwp/app_uwp.h b/platform/uwp/app_uwp.h index 9fd4967c21..87c66bd679 100644 --- a/platform/uwp/app_uwp.h +++ b/platform/uwp/app_uwp.h @@ -31,12 +31,11 @@ #ifndef APP_UWP_H #define APP_UWP_H -#include <string> +#include "os_uwp.h" +#include <GLES2/gl2.h> #include <wrl.h> - -#include "GLES2/gl2.h" -#include "os_uwp.h" +#include <string> /** clang-format does not play nice with this C++/CX hybrid, needs investigation. */ /* clang-format off */ diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp index df5da99a1c..aa8cfb4d49 100644 --- a/platform/uwp/context_egl_uwp.cpp +++ b/platform/uwp/context_egl_uwp.cpp @@ -30,7 +30,7 @@ #include "context_egl_uwp.h" -#include "EGL/eglext.h" +#include <EGL/eglext.h> using Platform::Exception; diff --git a/platform/uwp/context_egl_uwp.h b/platform/uwp/context_egl_uwp.h index a778849334..810c3dcbc1 100644 --- a/platform/uwp/context_egl_uwp.h +++ b/platform/uwp/context_egl_uwp.h @@ -31,13 +31,12 @@ #ifndef CONTEXT_EGL_UWP_H #define CONTEXT_EGL_UWP_H -#include <wrl.h> - -#include <EGL/egl.h> - #include "core/error/error_list.h" #include "core/os/os.h" +#include <EGL/egl.h> +#include <wrl.h> + using namespace Windows::UI::Core; class ContextEGL_UWP { diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index c20e3316a5..3e229c7419 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -30,9 +30,10 @@ #include "export.h" +#include "export_plugin.h" + #include "editor/editor_settings.h" #include "editor/export/editor_export.h" -#include "export_plugin.h" void register_uwp_exporter_types() { // GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformUWP); diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index aac61184b1..69de383efc 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -30,9 +30,10 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" + #include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "platform/uwp/logo_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg and regex. #ifdef MODULE_SVG_ENABLED diff --git a/platform/uwp/export/export_plugin.h b/platform/uwp/export/export_plugin.h index b42a2ae6d9..999d54cb80 100644 --- a/platform/uwp/export/export_plugin.h +++ b/platform/uwp/export/export_plugin.h @@ -31,6 +31,8 @@ #ifndef UWP_EXPORT_PLUGIN_H #define UWP_EXPORT_PLUGIN_H +#include "app_packager.h" + #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" @@ -46,8 +48,6 @@ #include "thirdparty/minizip/unzip.h" #include "thirdparty/minizip/zip.h" -#include "app_packager.h" - #include <zlib.h> // Capabilities diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 153656add7..7f2195e4fd 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -32,12 +32,13 @@ #define OS_UWP_H #include "context_egl_uwp.h" +#include "joypad_uwp.h" + #include "core/input/input.h" #include "core/math/transform_2d.h" #include "core/os/os.h" #include "core/string/ustring.h" #include "drivers/xaudio2/audio_driver_xaudio2.h" -#include "joypad_uwp.h" #include "servers/audio_server.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering_server.h" diff --git a/platform/web/api/api.cpp b/platform/web/api/api.cpp index a630e3d866..ab7154b0fb 100644 --- a/platform/web/api/api.cpp +++ b/platform/web/api/api.cpp @@ -29,10 +29,12 @@ /**************************************************************************/ #include "api.h" -#include "core/config/engine.h" + #include "javascript_bridge_singleton.h" #include "web_tools_editor_plugin.h" +#include "core/config/engine.h" + static JavaScriptBridge *javascript_bridge_singleton; void register_web_api() { @@ -78,6 +80,7 @@ void JavaScriptBridge::_bind_methods() { } #if !defined(WEB_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED) + Variant JavaScriptBridge::eval(const String &p_code, bool p_use_global_exec_context) { return Variant(); } @@ -104,16 +107,23 @@ Variant JavaScriptBridge::_create_object_bind(const Variant **p_args, int p_argc } return Ref<JavaScriptObject>(); } + #endif + #if !defined(WEB_ENABLED) + bool JavaScriptBridge::pwa_needs_update() const { return false; } + Error JavaScriptBridge::pwa_update() { return ERR_UNAVAILABLE; } + void JavaScriptBridge::force_fs_sync() { } + void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { } + #endif diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp index 213204ff33..d39773bde2 100644 --- a/platform/web/api/web_tools_editor_plugin.cpp +++ b/platform/web/api/web_tools_editor_plugin.cpp @@ -28,9 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#if defined(TOOLS_ENABLED) && defined(WEB_ENABLED) #include "web_tools_editor_plugin.h" +#if defined(TOOLS_ENABLED) && defined(WEB_ENABLED) + #include "core/config/engine.h" #include "core/config/project_settings.h" #include "core/io/dir_access.h" @@ -154,4 +155,5 @@ void WebToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zip cur = dir->get_next(); } } -#endif + +#endif // TOOLS_ENABLED && WEB_ENABLED diff --git a/platform/web/api/web_tools_editor_plugin.h b/platform/web/api/web_tools_editor_plugin.h index fc74899a58..ac0d5e20ec 100644 --- a/platform/web/api/web_tools_editor_plugin.h +++ b/platform/web/api/web_tools_editor_plugin.h @@ -32,6 +32,7 @@ #define WEB_TOOLS_EDITOR_PLUGIN_H #if defined(TOOLS_ENABLED) && defined(WEB_ENABLED) + #include "core/io/zip_io.h" #include "editor/editor_plugin.h" @@ -48,11 +49,14 @@ public: WebToolsEditorPlugin(); }; + #else + class WebToolsEditorPlugin { public: static void initialize() {} }; -#endif + +#endif // TOOLS_ENABLED && WEB_ENABLED #endif // WEB_TOOLS_EDITOR_PLUGIN_H diff --git a/platform/web/audio_driver_web.h b/platform/web/audio_driver_web.h index be13935bd9..7bfed834e1 100644 --- a/platform/web/audio_driver_web.h +++ b/platform/web/audio_driver_web.h @@ -31,12 +31,12 @@ #ifndef AUDIO_DRIVER_WEB_H #define AUDIO_DRIVER_WEB_H +#include "godot_audio.h" + #include "core/os/mutex.h" #include "core/os/thread.h" #include "servers/audio_server.h" -#include "godot_audio.h" - class AudioDriverWeb : public AudioDriver { private: struct AudioContext { diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp index e870f0da29..6cb56b404f 100644 --- a/platform/web/display_server_web.cpp +++ b/platform/web/display_server_web.cpp @@ -30,19 +30,20 @@ #include "display_server_web.h" +#include "dom_keys.inc" +#include "godot_js.h" +#include "os_web.h" + #include "core/config/project_settings.h" +#include "servers/rendering/dummy/rasterizer_dummy.h" + #ifdef GLES3_ENABLED #include "drivers/gles3/rasterizer_gles3.h" #endif -#include "platform/web/os_web.h" -#include "servers/rendering/dummy/rasterizer_dummy.h" #include <emscripten.h> #include <png.h> -#include "dom_keys.inc" -#include "godot_js.h" - #define DOM_BUTTON_LEFT 0 #define DOM_BUTTON_MIDDLE 1 #define DOM_BUTTON_RIGHT 2 diff --git a/platform/web/export/export.cpp b/platform/web/export/export.cpp index 80c29024a8..168310c078 100644 --- a/platform/web/export/export.cpp +++ b/platform/web/export/export.cpp @@ -30,9 +30,10 @@ #include "export.h" +#include "export_plugin.h" + #include "editor/editor_settings.h" #include "editor/export/editor_export.h" -#include "export_plugin.h" void register_web_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformWeb); diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 2fff628c85..a398593f90 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -30,12 +30,13 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" + #include "core/config/project_settings.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/export/editor_export.h" -#include "platform/web/logo_svg.gen.h" -#include "platform/web/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index 334f12d64d..a1d3fed2f3 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -31,6 +31,8 @@ #ifndef WEB_EXPORT_PLUGIN_H #define WEB_EXPORT_PLUGIN_H +#include "editor_http_server.h" + #include "core/config/project_settings.h" #include "core/io/image_loader.h" #include "core/io/stream_peer_tls.h" @@ -38,7 +40,6 @@ #include "core/io/zip_io.h" #include "editor/editor_node.h" #include "editor/export/editor_export_platform.h" -#include "editor_http_server.h" #include "main/splash.gen.h" class EditorExportPlatformWeb : public EditorExportPlatform { diff --git a/platform/web/godot_audio.h b/platform/web/godot_audio.h index c6f92161fa..a32d5acd97 100644 --- a/platform/web/godot_audio.h +++ b/platform/web/godot_audio.h @@ -35,7 +35,8 @@ extern "C" { #endif -#include "stddef.h" +#include <stddef.h> +#include <stdint.h> extern int godot_audio_is_available(); extern int godot_audio_has_worklet(); diff --git a/platform/web/godot_js.h b/platform/web/godot_js.h index 660822e291..3341cf8a67 100644 --- a/platform/web/godot_js.h +++ b/platform/web/godot_js.h @@ -35,7 +35,7 @@ extern "C" { #endif -#include "stddef.h" +#include <stddef.h> // Config extern void godot_js_config_locale_get(char *p_ptr, int p_ptr_max); diff --git a/platform/web/godot_webgl2.h b/platform/web/godot_webgl2.h index fd551ff77d..d2f46e125e 100644 --- a/platform/web/godot_webgl2.h +++ b/platform/web/godot_webgl2.h @@ -31,8 +31,8 @@ #ifndef GODOT_WEBGL2_H #define GODOT_WEBGL2_H -#include "GLES3/gl3.h" -#include "webgl/webgl2.h" +#include <GLES3/gl3.h> +#include <webgl/webgl2.h> #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 diff --git a/platform/web/http_client_web.h b/platform/web/http_client_web.h index def7837a27..bb9672ab82 100644 --- a/platform/web/http_client_web.h +++ b/platform/web/http_client_web.h @@ -37,7 +37,7 @@ extern "C" { #endif -#include "stddef.h" +#include <stddef.h> typedef enum { GODOT_JS_FETCH_STATE_REQUESTING = 0, diff --git a/platform/web/javascript_bridge_singleton.cpp b/platform/web/javascript_bridge_singleton.cpp index dba630404f..45bce1b480 100644 --- a/platform/web/javascript_bridge_singleton.cpp +++ b/platform/web/javascript_bridge_singleton.cpp @@ -30,9 +30,10 @@ #include "api/javascript_bridge_singleton.h" -#include "emscripten.h" #include "os_web.h" +#include <emscripten.h> + extern "C" { extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, const char *p_name, const char *p_mime); } @@ -352,6 +353,7 @@ Variant JavaScriptBridge::eval(const String &p_code, bool p_use_global_exec_cont return Variant(); } } + #endif // JAVASCRIPT_EVAL_ENABLED void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp index 0f84e7e841..5115ff50da 100644 --- a/platform/web/os_web.cpp +++ b/platform/web/os_web.cpp @@ -30,12 +30,15 @@ #include "os_web.h" +#include "api/javascript_bridge_singleton.h" +#include "display_server_web.h" +#include "godot_js.h" + #include "core/config/project_settings.h" #include "core/debugger/engine_debugger.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" -#include "platform/web/display_server_web.h" #include "modules/modules_enabled.gen.h" // For websocket. @@ -43,9 +46,6 @@ #include <emscripten.h> #include <stdlib.h> -#include "api/javascript_bridge_singleton.h" -#include "godot_js.h" - void OS_Web::alert(const String &p_alert, const String &p_title) { godot_js_display_alert(p_alert.utf8().get_data()); } diff --git a/platform/web/os_web.h b/platform/web/os_web.h index 70d8af9db9..b9570f9ca1 100644 --- a/platform/web/os_web.h +++ b/platform/web/os_web.h @@ -32,6 +32,7 @@ #define OS_WEB_H #include "audio_driver_web.h" + #include "core/input/input.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" diff --git a/platform/web/web_main.cpp b/platform/web/web_main.cpp index df97b08b8a..f199f8ffd8 100644 --- a/platform/web/web_main.cpp +++ b/platform/web/web_main.cpp @@ -28,17 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#include "display_server_web.h" +#include "godot_js.h" +#include "os_web.h" + #include "core/config/engine.h" #include "core/io/resource_loader.h" #include "main/main.h" -#include "platform/web/display_server_web.h" -#include "platform/web/os_web.h" #include <emscripten/emscripten.h> #include <stdlib.h> -#include "godot_js.h" - static OS_Web *os = nullptr; static uint64_t target_ticks = 0; static bool main_started = false; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index f971846959..fc208eb4bb 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -30,12 +30,16 @@ #include "display_server_windows.h" +#include "os_windows.h" + #include "core/io/marshalls.h" -#include "core/math/geometry_2d.h" #include "main/main.h" -#include "os_windows.h" #include "scene/resources/texture.h" +#if defined(GLES3_ENABLED) +#include "drivers/gles3/rasterizer_gles3.h" +#endif + #include <avrt.h> #include <dwmapi.h> @@ -43,10 +47,6 @@ #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif -#if defined(GLES3_ENABLED) -#include "drivers/gles3/rasterizer_gles3.h" -#endif - #if defined(__GNUC__) // Workaround GCC warning from -Wcast-function-type. #define GetProcAddress (void *)GetProcAddress @@ -835,9 +835,12 @@ void DisplayServerWindows::show_window(WindowID p_id) { SetFocus(wd.hWnd); // Set keyboard focus. } else if (wd.minimized) { ShowWindow(wd.hWnd, SW_SHOWMINIMIZED); - } else if (wd.no_focus || wd.is_popup) { + } else if (wd.no_focus) { // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow ShowWindow(wd.hWnd, SW_SHOWNA); + } else if (wd.is_popup) { + ShowWindow(wd.hWnd, SW_SHOWNA); + SetFocus(wd.hWnd); // Set keyboard focus. } else { ShowWindow(wd.hWnd, SW_SHOW); SetForegroundWindow(wd.hWnd); // Slightly higher priority. @@ -1325,7 +1328,7 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre r_style = WS_OVERLAPPEDWINDOW; } } else { - r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; + r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; } } @@ -1381,6 +1384,8 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window) wd.multiwindow_fs = false; wd.maximized = wd.was_maximized; + _update_window_style(p_window, false); + if (wd.pre_fs_valid) { rect = wd.pre_fs_rect; } else { @@ -1391,8 +1396,6 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window) wd.pre_fs_valid = true; } - _update_window_style(p_window, false); - MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); if (restore_mouse_trails > 1) { diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 4a1619f331..ae2cd4e8b5 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -31,30 +31,31 @@ #ifndef DISPLAY_SERVER_WINDOWS_H #define DISPLAY_SERVER_WINDOWS_H -#include "servers/display_server.h" +#include "crash_handler_windows.h" +#include "joypad_windows.h" +#include "key_mapping_windows.h" +#include "tts_windows.h" #include "core/config/project_settings.h" #include "core/input/input.h" #include "core/os/os.h" -#include "crash_handler_windows.h" #include "drivers/unix/ip_unix.h" #include "drivers/wasapi/audio_driver_wasapi.h" #include "drivers/winmidi/midi_driver_winmidi.h" -#include "joypad_windows.h" -#include "key_mapping_windows.h" #include "servers/audio_server.h" +#include "servers/display_server.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #include "servers/rendering_server.h" -#include "tts_windows.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" #endif #if defined(VULKAN_ENABLED) +#include "vulkan_context_win.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/windows/vulkan_context_win.h" #endif #if defined(GLES3_ENABLED) diff --git a/platform/windows/doc_classes/EditorExportPlatformWindows.xml b/platform/windows/doc_classes/EditorExportPlatformWindows.xml index 4bdeed19ad..7506ac09f0 100644 --- a/platform/windows/doc_classes/EditorExportPlatformWindows.xml +++ b/platform/windows/doc_classes/EditorExportPlatformWindows.xml @@ -86,7 +86,7 @@ <member name="custom_template/release" type="String" setter="" getter=""> Path to the custom export template. If left empty, default template is used. </member> - <member name="debug/export_console_script" type="int" setter="" getter=""> + <member name="debug/export_console_wrapper" type="int" setter="" getter=""> If [code]true[/code], a console wrapper executable is exported alongside the main executable, which allows running the project with enabled console output. </member> <member name="ssh_remote_deploy/cleanup_script" type="String" setter="" getter=""> diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 08c620e1e9..7a65f74f0d 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -30,9 +30,10 @@ #include "export.h" -#include "editor/export/editor_export.h" #include "export_plugin.h" +#include "editor/export/editor_export.h" + void register_windows_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformWindows); } diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index 2ac41af3a2..7371e4daf7 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -30,14 +30,15 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" + #include "core/config/project_settings.h" #include "core/io/image_loader.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/export/editor_export.h" -#include "platform/windows/logo_svg.gen.h" -#include "platform/windows/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index dbe1e1aefa..ad7c637a37 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -30,13 +30,16 @@ #include "gl_manager_windows.h" -#ifdef WINDOWS_ENABLED -#ifdef GLES3_ENABLED +#if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED) -#include <stdio.h> -#include <stdlib.h> +#include "core/config/project_settings.h" +#include "core/version.h" + +#include "thirdparty/nvapi/nvapi_minimal.h" #include <dwmapi.h> +#include <stdio.h> +#include <stdlib.h> #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 @@ -66,6 +69,171 @@ static String format_error_message(DWORD id) { return msg; } +const int OGL_THREAD_CONTROL_ID = 0x20C1221E; +const int OGL_THREAD_CONTROL_DISABLE = 0x00000002; +const int OGL_THREAD_CONTROL_ENABLE = 0x00000001; + +typedef int(__cdecl *NvAPI_Initialize_t)(); +typedef int(__cdecl *NvAPI_Unload_t)(); +typedef int(__cdecl *NvAPI_GetErrorMessage_t)(unsigned int, NvAPI_ShortString); +typedef int(__cdecl *NvAPI_DRS_CreateSession_t)(NvDRSSessionHandle *); +typedef int(__cdecl *NvAPI_DRS_DestroySession_t)(NvDRSSessionHandle); +typedef int(__cdecl *NvAPI_DRS_LoadSettings_t)(NvDRSSessionHandle); +typedef int(__cdecl *NvAPI_DRS_CreateProfile_t)(NvDRSSessionHandle, NVDRS_PROFILE *, NvDRSProfileHandle *); +typedef int(__cdecl *NvAPI_DRS_CreateApplication_t)(NvDRSSessionHandle, NvDRSProfileHandle, NVDRS_APPLICATION *); +typedef int(__cdecl *NvAPI_DRS_SaveSettings_t)(NvDRSSessionHandle); +typedef int(__cdecl *NvAPI_DRS_SetSetting_t)(NvDRSSessionHandle, NvDRSProfileHandle, NVDRS_SETTING *); +typedef int(__cdecl *NvAPI_DRS_FindProfileByName_t)(NvDRSSessionHandle, NvAPI_UnicodeString, NvDRSProfileHandle *); +NvAPI_GetErrorMessage_t NvAPI_GetErrorMessage__; + +static bool nvapi_err_check(char *msg, int status) { + if (status != 0) { + if (OS::get_singleton()->is_stdout_verbose()) { + NvAPI_ShortString err_desc = { 0 }; + NvAPI_GetErrorMessage__(status, err_desc); + print_verbose(vformat("%s: %s(code %d)", msg, err_desc, status)); + } + return false; + } + return true; +} + +// On windows we have to disable threaded optimization when using NVIDIA graphics cards +// to avoid stuttering, see https://github.com/microsoft/vscode-cpptools/issues/6592 +// also see https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs +void GLManager_Windows::_nvapi_disable_threaded_optimization() { + HMODULE nvapi = 0; +#ifdef _WIN64 + nvapi = LoadLibraryA("nvapi64.dll"); +#else + nvapi = LoadLibraryA("nvapi.dll"); +#endif + + if (nvapi == NULL) { + return; + } + + void *(__cdecl * NvAPI_QueryInterface)(unsigned int interface_id) = 0; + + NvAPI_QueryInterface = (void *(__cdecl *)(unsigned int))GetProcAddress(nvapi, "nvapi_QueryInterface"); + + if (NvAPI_QueryInterface == NULL) { + print_verbose("Error getting NVAPI NvAPI_QueryInterface"); + return; + } + + // Setup NVAPI function pointers + NvAPI_Initialize_t NvAPI_Initialize = (NvAPI_Initialize_t)NvAPI_QueryInterface(0x0150E828); + NvAPI_GetErrorMessage__ = (NvAPI_GetErrorMessage_t)NvAPI_QueryInterface(0x6C2D048C); + NvAPI_DRS_CreateSession_t NvAPI_DRS_CreateSession = (NvAPI_DRS_CreateSession_t)NvAPI_QueryInterface(0x0694D52E); + NvAPI_DRS_DestroySession_t NvAPI_DRS_DestroySession = (NvAPI_DRS_DestroySession_t)NvAPI_QueryInterface(0xDAD9CFF8); + NvAPI_Unload_t NvAPI_Unload = (NvAPI_Unload_t)NvAPI_QueryInterface(0xD22BDD7E); + NvAPI_DRS_LoadSettings_t NvAPI_DRS_LoadSettings = (NvAPI_DRS_LoadSettings_t)NvAPI_QueryInterface(0x375DBD6B); + NvAPI_DRS_CreateProfile_t NvAPI_DRS_CreateProfile = (NvAPI_DRS_CreateProfile_t)NvAPI_QueryInterface(0xCC176068); + NvAPI_DRS_CreateApplication_t NvAPI_DRS_CreateApplication = (NvAPI_DRS_CreateApplication_t)NvAPI_QueryInterface(0x4347A9DE); + NvAPI_DRS_SaveSettings_t NvAPI_DRS_SaveSettings = (NvAPI_DRS_SaveSettings_t)NvAPI_QueryInterface(0xFCBC7E14); + NvAPI_DRS_SetSetting_t NvAPI_DRS_SetSetting = (NvAPI_DRS_SetSetting_t)NvAPI_QueryInterface(0x577DD202); + NvAPI_DRS_FindProfileByName_t NvAPI_DRS_FindProfileByName = (NvAPI_DRS_FindProfileByName_t)NvAPI_QueryInterface(0x7E4A9A0B); + + if (!nvapi_err_check("NVAPI: Init failed", NvAPI_Initialize())) { + return; + } + + print_verbose("NVAPI: Init OK!"); + + NvDRSSessionHandle session_handle; + + if (!nvapi_err_check("NVAPI: Error creating DRS session", NvAPI_DRS_CreateSession(&session_handle))) { + NvAPI_Unload(); + return; + } + + if (!nvapi_err_check("NVAPI: Error loading DRS settings", NvAPI_DRS_LoadSettings(session_handle))) { + NvAPI_DRS_DestroySession(session_handle); + NvAPI_Unload(); + return; + } + + String app_executable_name = OS::get_singleton()->get_executable_path().get_file(); + String app_friendly_name = GLOBAL_GET("application/config/name"); + // We need a name anyways, so let's use the engine name if an application name is not available + // (this is used mostly by the Project Manager) + if (app_friendly_name.is_empty()) { + app_friendly_name = VERSION_NAME; + } + String app_profile_name = app_friendly_name + " Nvidia Profile"; + Char16String app_profile_name_u16 = app_profile_name.utf16(); + Char16String app_executable_name_u16 = app_executable_name.utf16(); + Char16String app_friendly_name_u16 = app_friendly_name.utf16(); + + NvDRSProfileHandle profile_handle = 0; + + int status = NvAPI_DRS_FindProfileByName(session_handle, (NvU16 *)(app_profile_name_u16.ptrw()), &profile_handle); + + if (status != 0) { + print_verbose("NVAPI: Profile not found, creating...."); + + NVDRS_PROFILE profile_info; + profile_info.version = NVDRS_PROFILE_VER; + profile_info.isPredefined = 0; + memcpy(profile_info.profileName, app_profile_name_u16.get_data(), sizeof(char16_t) * app_profile_name_u16.size()); + + if (!nvapi_err_check("NVAPI: Error creating profile", NvAPI_DRS_CreateProfile(session_handle, &profile_info, &profile_handle))) { + NvAPI_DRS_DestroySession(session_handle); + NvAPI_Unload(); + return; + } + + NVDRS_APPLICATION_V4 app; + app.version = NVDRS_APPLICATION_VER_V4; + app.isPredefined = 0; + app.isMetro = 1; + app.isCommandLine = 1; + memcpy(app.appName, app_executable_name_u16.get_data(), sizeof(char16_t) * app_executable_name_u16.size()); + memcpy(app.userFriendlyName, app_friendly_name_u16.get_data(), sizeof(char16_t) * app_friendly_name_u16.size()); + memcpy(app.launcher, L"", 1); + memcpy(app.fileInFolder, L"", 1); + + if (!nvapi_err_check("NVAPI: Error creating application", NvAPI_DRS_CreateApplication(session_handle, profile_handle, &app))) { + NvAPI_DRS_DestroySession(session_handle); + NvAPI_Unload(); + return; + } + } + + NVDRS_SETTING setting; + setting.version = NVDRS_SETTING_VER; + setting.settingId = OGL_THREAD_CONTROL_ID; + setting.settingType = NVDRS_DWORD_TYPE; + setting.settingLocation = NVDRS_CURRENT_PROFILE_LOCATION; + setting.isCurrentPredefined = 0; + setting.isPredefinedValid = 0; + int thread_control_val = OGL_THREAD_CONTROL_DISABLE; + if (!GLOBAL_GET("rendering/gl_compatibility/nvidia_disable_threaded_optimization")) { + thread_control_val = OGL_THREAD_CONTROL_ENABLE; + } + setting.u32CurrentValue = thread_control_val; + setting.u32PredefinedValue = thread_control_val; + + if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &setting))) { + NvAPI_DRS_DestroySession(session_handle); + NvAPI_Unload(); + return; + } + + if (!nvapi_err_check("NVAPI: Error saving settings", NvAPI_DRS_SaveSettings(session_handle))) { + NvAPI_DRS_DestroySession(session_handle); + NvAPI_Unload(); + return; + } + if (thread_control_val == OGL_THREAD_CONTROL_DISABLE) { + print_verbose("NVAPI: Disabled OpenGL threaded optimization successfully"); + } else { + print_verbose("NVAPI: Enabled OpenGL threaded optimization successfully"); + } + NvAPI_DRS_DestroySession(session_handle); +} + int GLManager_Windows::_find_or_create_display(GLWindow &win) { // find display NYI, only 1 supported so far if (_displays.size()) { @@ -297,6 +465,7 @@ void GLManager_Windows::swap_buffers() { } Error GLManager_Windows::initialize() { + _nvapi_disable_threaded_optimization(); return OK; } @@ -345,5 +514,4 @@ GLManager_Windows::~GLManager_Windows() { release_current(); } -#endif // GLES3_ENABLED -#endif // WINDOWS +#endif // WINDOWS_ENABLED && GLES3_ENABLED diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h index 361c559a5a..482b00a1ba 100644 --- a/platform/windows/gl_manager_windows.h +++ b/platform/windows/gl_manager_windows.h @@ -89,6 +89,7 @@ private: ContextType context_type; private: + void _nvapi_disable_threaded_optimization(); int _find_or_create_display(GLWindow &win); Error _create_context(GLWindow &win, GLDisplay &gl_display); @@ -119,6 +120,6 @@ public: ~GLManager_Windows(); }; -#endif // defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED) +#endif // WINDOWS_ENABLED && GLES3_ENABLED #endif // GL_MANAGER_WINDOWS_H diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp index a26d3baa9f..8d63b1747e 100644 --- a/platform/windows/godot_windows.cpp +++ b/platform/windows/godot_windows.cpp @@ -28,9 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "main/main.h" #include "os_windows.h" +#include "main/main.h" + #include <locale.h> #include <stdio.h> diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 91efe09160..487cb56ba0 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -102,11 +102,25 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { static GUID IID_X360WiredGamepad = { MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; static GUID IID_X360WirelessGamepad = { MAKELONG(0x045E, 0x028E), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; static GUID IID_XSWirelessGamepad = { MAKELONG(0x045E, 0x0B13), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XEliteWirelessGamepad = { MAKELONG(0x045E, 0x0B05), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneWiredGamepad = { MAKELONG(0x045E, 0x02FF), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneWirelessGamepad = { MAKELONG(0x045E, 0x02DD), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneNewWirelessGamepad = { MAKELONG(0x045E, 0x02D1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneSWirelessGamepad = { MAKELONG(0x045E, 0x02EA), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneSBluetoothGamepad = { MAKELONG(0x045E, 0x02E0), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XOneEliteWirelessGamepad = { MAKELONG(0x045E, 0x02E3), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; if (memcmp(p_guid, &IID_ValveStreamingGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_X360WiredGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_X360WirelessGamepad, sizeof(*p_guid)) == 0 || - memcmp(p_guid, &IID_XSWirelessGamepad, sizeof(*p_guid)) == 0) + memcmp(p_guid, &IID_XSWirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XEliteWirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneWiredGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneWirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneNewWirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneSWirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneSBluetoothGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XOneEliteWirelessGamepad, sizeof(*p_guid)) == 0) return true; PRAWINPUTDEVICELIST dev_list = nullptr; diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index 0803ba53c2..cfddbcc8dc 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -35,7 +35,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include <dinput.h> -#include <xinput.h> // on unix the file is called "xinput.h", on windows I'm sure it won't mind +#include <xinput.h> #ifndef SAFE_RELEASE // when Windows Media Device M? is not present #define SAFE_RELEASE(x) \ diff --git a/platform/windows/lang_table.h b/platform/windows/lang_table.h index 198856ab1b..e1f4f72746 100644 --- a/platform/windows/lang_table.h +++ b/platform/windows/lang_table.h @@ -31,8 +31,6 @@ #ifndef LANG_TABLE_H #define LANG_TABLE_H -//#include <windows.h> - struct _WinLocale { const char *locale; int main_lang; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2653efed71..cb70f93a62 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -30,6 +30,11 @@ #include "os_windows.h" +#include "display_server_windows.h" +#include "joypad_windows.h" +#include "lang_table.h" +#include "windows_terminal_logger.h" + #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" #include "core/io/marshalls.h" @@ -37,14 +42,10 @@ #include "drivers/unix/net_socket_posix.h" #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" -#include "joypad_windows.h" -#include "lang_table.h" #include "main/main.h" -#include "platform/windows/display_server_windows.h" #include "servers/audio_server.h" #include "servers/rendering/rendering_server_default.h" #include "servers/text_server.h" -#include "windows_terminal_logger.h" #include <avrt.h> #include <bcrypt.h> @@ -449,7 +450,7 @@ String OS_Windows::get_version() const { } Vector<String> OS_Windows::get_video_adapter_driver_info() const { - if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) { + if (RenderingServer::get_singleton() == nullptr) { return Vector<String>(); } @@ -467,7 +468,7 @@ Vector<String> OS_Windows::get_video_adapter_driver_info() const { String driver_name; String driver_version; - const String device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); + const String device_name = RenderingServer::get_singleton()->get_video_adapter_name(); if (device_name.is_empty()) { return Vector<String>(); } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c5f95870b3..e873fb8a13 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -31,14 +31,15 @@ #ifndef OS_WINDOWS_H #define OS_WINDOWS_H +#include "crash_handler_windows.h" +#include "key_mapping_windows.h" + #include "core/config/project_settings.h" #include "core/input/input.h" #include "core/os/os.h" -#include "crash_handler_windows.h" #include "drivers/unix/ip_unix.h" #include "drivers/wasapi/audio_driver_wasapi.h" #include "drivers/winmidi/midi_driver_winmidi.h" -#include "key_mapping_windows.h" #include "servers/audio_server.h" #ifdef XAUDIO2_ENABLED @@ -46,8 +47,9 @@ #endif #if defined(VULKAN_ENABLED) +#include "vulkan_context_win.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/windows/vulkan_context_win.h" #endif #include <io.h> diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp index 4c1e6eebe4..a60055dbec 100644 --- a/platform/windows/vulkan_context_win.cpp +++ b/platform/windows/vulkan_context_win.cpp @@ -31,6 +31,7 @@ #if defined(WINDOWS_ENABLED) && defined(VULKAN_ENABLED) #include "vulkan_context_win.h" + #ifdef USE_VOLK #include <volk.h> #else @@ -64,4 +65,4 @@ VulkanContextWindows::VulkanContextWindows() { VulkanContextWindows::~VulkanContextWindows() { } -#endif +#endif // WINDOWS_ENABLED && VULKAN_ENABLED diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 47b569dd82..bb223628a8 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -33,6 +33,7 @@ #ifdef WINDOWS_ENABLED #include <stdio.h> + #define WIN32_LEAN_AND_MEAN #include <windows.h> @@ -163,4 +164,4 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file WindowsTerminalLogger::~WindowsTerminalLogger() {} -#endif +#endif // WINDOWS_ENABLED diff --git a/platform/windows/windows_terminal_logger.h b/platform/windows/windows_terminal_logger.h index c366d46461..60d82bb935 100644 --- a/platform/windows/windows_terminal_logger.h +++ b/platform/windows/windows_terminal_logger.h @@ -42,6 +42,6 @@ public: virtual ~WindowsTerminalLogger(); }; -#endif +#endif // WINDOWS_ENABLED #endif // WINDOWS_TERMINAL_LOGGER_H |
