diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/export/export.cpp | 18 | ||||
-rw-r--r-- | platform/android/export/export_plugin.cpp | 2 | ||||
-rw-r--r-- | platform/linuxbsd/wayland/wayland_thread.cpp | 6 | ||||
-rw-r--r-- | platform/macos/export/export_plugin.cpp | 4 | ||||
-rw-r--r-- | platform/web/api/web_tools_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 1 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 24 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 1 |
8 files changed, 43 insertions, 15 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 513d1be05b..73b427cc85 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -39,6 +39,8 @@ #include "editor/editor_settings.h" #include "editor/export/editor_export.h" +String get_default_android_sdk_path(); + void register_android_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid); } @@ -56,8 +58,10 @@ void register_android_exporter() { #else EDITOR_DEF_BASIC("export/android/java_sdk_path", OS::get_singleton()->get_environment("JAVA_HOME")); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/java_sdk_path", PROPERTY_HINT_GLOBAL_DIR)); - EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->get_environment("ANDROID_HOME")); + + EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->has_environment("ANDROID_HOME") ? OS::get_singleton()->get_environment("ANDROID_HOME") : get_default_android_sdk_path()); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/android_sdk_path", PROPERTY_HINT_GLOBAL_DIR)); + EDITOR_DEF("export/android/force_system_user", false); EDITOR_DEF("export/android/shutdown_adb_on_exit", true); @@ -71,3 +75,15 @@ void register_android_exporter() { Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid)); EditorExport::get_singleton()->add_export_platform(exporter); } + +inline String get_default_android_sdk_path() { +#ifdef WINDOWS_ENABLED + return OS::get_singleton()->get_environment("LOCALAPPDATA").path_join("Android/Sdk"); +#elif LINUXBSD_ENABLED + return OS::get_singleton()->get_environment("HOME").path_join("Android/Sdk"); +#elif MACOS_ENABLED + return OS::get_singleton()->get_environment("HOME").path_join("Library/Android/sdk"); +#else + return String(); +#endif +} diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 666c8d634a..3424df2969 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1566,7 +1566,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref<EditorExportPreset> & str = get_project_name(package_name); } else { - String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_"); + String lang = str.substr(str.rfind_char('-') + 1, str.length()).replace("-", "_"); if (appnames.has(lang)) { str = appnames[lang]; } else { diff --git a/platform/linuxbsd/wayland/wayland_thread.cpp b/platform/linuxbsd/wayland/wayland_thread.cpp index 90d07178d4..277324ac48 100644 --- a/platform/linuxbsd/wayland/wayland_thread.cpp +++ b/platform/linuxbsd/wayland/wayland_thread.cpp @@ -3990,10 +3990,10 @@ void WaylandThread::selection_set_text(const String &p_text) { wl_data_source_add_listener(ss->wl_data_source_selection, &wl_data_source_listener, ss); wl_data_source_offer(ss->wl_data_source_selection, "text/plain;charset=utf-8"); wl_data_source_offer(ss->wl_data_source_selection, "text/plain"); - } - // TODO: Implement a good way of getting the latest serial from the user. - wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial)); + // TODO: Implement a good way of getting the latest serial from the user. + wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial)); + } // Wait for the message to get to the server before continuing, otherwise the // clipboard update might come with a delay. diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 1fabe26263..9968f82792 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -972,7 +972,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres return Error::FAILED; } else { print_verbose("rcodesign (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); @@ -1056,7 +1056,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres return Error::FAILED; } else { print_verbose("notarytool (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp index 52da0c3347..3986d224c4 100644 --- a/platform/web/api/web_tools_editor_plugin.cpp +++ b/platform/web/api/web_tools_editor_plugin.cpp @@ -82,7 +82,7 @@ void WebToolsEditorPlugin::_download_zip() { const String output_path = String("/tmp").path_join(output_name); zipFile zip = zipOpen2(output_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); - const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/"; + const String base_path = resource_path.substr(0, resource_path.rfind_char('/')) + "/"; _zip_recursive(resource_path, base_path, zip); zipClose(zip, nullptr); { diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index b986091a16..020b0a7636 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -42,7 +42,6 @@ #include "core/input/input.h" #include "core/io/image.h" #include "core/os/os.h" -#include "drivers/unix/ip_unix.h" #include "drivers/wasapi/audio_driver_wasapi.h" #include "drivers/winmidi/midi_driver_winmidi.h" #include "servers/audio_server.h" diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d7a97a3b2d..7ff14cc1e1 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -45,6 +45,7 @@ #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/file_access_windows_pipe.h" +#include "drivers/windows/ip_windows.h" #include "drivers/windows/net_socket_winsock.h" #include "main/main.h" #include "servers/audio_server.h" @@ -71,6 +72,7 @@ extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 1; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +__declspec(dllexport) void NoHotPatch() {} // Disable Nahimic code injection. } // Workaround mingw-w64 < 4.0 bug @@ -276,7 +278,7 @@ void OS_Windows::initialize() { current_pi.pi.hProcess = GetCurrentProcess(); process_map->insert(GetCurrentProcessId(), current_pi); - IPUnix::make_default(); + IPWindows::make_default(); main_loop = nullptr; HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory)); @@ -817,10 +819,22 @@ double OS_Windows::get_unix_time() const { } void OS_Windows::delay_usec(uint32_t p_usec) const { - if (p_usec < 1000) { - Sleep(1); - } else { - Sleep(p_usec / 1000); + constexpr uint32_t tolerance = 1000 + 20; + + uint64_t t0 = get_ticks_usec(); + uint64_t target_time = t0 + p_usec; + + // Calculate sleep duration with a tolerance for fine-tuning. + if (p_usec > tolerance) { + uint32_t coarse_sleep_usec = p_usec - tolerance; + if (coarse_sleep_usec >= 1000) { + Sleep(coarse_sleep_usec / 1000); + } + } + + // Spin-wait until we reach the precise target time. + while (get_ticks_usec() < target_time) { + YieldProcessor(); } } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c51cb78d57..5681e7b804 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -39,7 +39,6 @@ #include "core/config/project_settings.h" #include "core/input/input.h" #include "core/os/os.h" -#include "drivers/unix/ip_unix.h" #include "drivers/wasapi/audio_driver_wasapi.h" #include "drivers/winmidi/midi_driver_winmidi.h" #include "servers/audio_server.h" |