summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/android_input_handler.cpp5
-rw-r--r--platform/android/api/api.cpp4
-rw-r--r--platform/android/api/java_class_wrapper.h4
-rw-r--r--platform/android/api/jni_singleton.h28
-rw-r--r--platform/android/audio_driver_opensl.cpp9
-rw-r--r--platform/android/dir_access_jandroid.cpp50
-rw-r--r--platform/android/display_server_android.cpp2
-rw-r--r--platform/android/export/export.cpp3
-rw-r--r--platform/android/export/export_plugin.cpp28
-rw-r--r--platform/android/export/export_plugin.h22
-rw-r--r--platform/android/export/gradle_export_util.cpp11
-rw-r--r--platform/android/file_access_android.cpp25
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java5
-rw-r--r--platform/android/java/nativeSrcsConfigs/CMakeLists.txt3
-rw-r--r--platform/android/java_class_wrapper.cpp96
-rw-r--r--platform/android/java_godot_io_wrapper.cpp5
-rw-r--r--platform/android/java_godot_lib_jni.cpp58
-rw-r--r--platform/android/java_godot_wrapper.cpp12
-rw-r--r--platform/android/jni_utils.cpp44
-rw-r--r--platform/android/net_socket_android.cpp21
-rw-r--r--platform/android/os_android.cpp30
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp7
-rw-r--r--platform/iphone/app_delegate.mm11
-rw-r--r--platform/iphone/display_layer.mm12
-rw-r--r--platform/iphone/display_server_iphone.mm23
-rw-r--r--platform/iphone/export/export_plugin.cpp228
-rw-r--r--platform/iphone/export/export_plugin.h1
-rw-r--r--platform/iphone/godot_iphone.mm12
-rw-r--r--platform/iphone/godot_view.mm8
-rw-r--r--platform/iphone/godot_view_gesture_recognizer.mm3
-rw-r--r--platform/iphone/godot_view_renderer.mm3
-rw-r--r--platform/iphone/ios.mm5
-rw-r--r--platform/iphone/joypad_iphone.mm27
-rw-r--r--platform/iphone/os_iphone.h1
-rw-r--r--platform/iphone/os_iphone.mm26
-rw-r--r--platform/iphone/view_controller.mm2
-rw-r--r--platform/javascript/api/api.cpp4
-rw-r--r--platform/javascript/api/javascript_tools_editor_plugin.cpp6
-rw-r--r--platform/javascript/api/javascript_tools_editor_plugin.h2
-rw-r--r--platform/javascript/display_server_javascript.cpp11
-rw-r--r--platform/javascript/export/export_plugin.cpp26
-rw-r--r--platform/javascript/export/export_plugin.h1
-rw-r--r--platform/javascript/export/export_server.h2
-rw-r--r--platform/javascript/javascript_main.cpp3
-rw-r--r--platform/javascript/javascript_singleton.cpp5
-rw-r--r--platform/javascript/os_javascript.cpp2
-rw-r--r--platform/linuxbsd/detect.py21
-rw-r--r--platform/linuxbsd/display_server_x11.cpp230
-rw-r--r--platform/linuxbsd/display_server_x11.h18
-rw-r--r--platform/linuxbsd/joypad_linux.cpp6
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp59
-rw-r--r--platform/linuxbsd/os_linuxbsd.h3
-rw-r--r--platform/linuxbsd/vulkan_context_x11.cpp1
-rw-r--r--platform/osx/crash_handler_osx.mm9
-rw-r--r--platform/osx/display_server_osx.h18
-rw-r--r--platform/osx/display_server_osx.mm203
-rw-r--r--platform/osx/export/codesign.cpp15
-rw-r--r--platform/osx/export/codesign.h1
-rw-r--r--platform/osx/export/export_plugin.cpp143
-rw-r--r--platform/osx/export/export_plugin.h1
-rw-r--r--platform/osx/godot_application_delegate.mm4
-rw-r--r--platform/osx/godot_content_view.mm6
-rw-r--r--platform/osx/godot_main_osx.mm4
-rw-r--r--platform/osx/godot_window.mm4
-rw-r--r--platform/osx/godot_window_delegate.mm16
-rw-r--r--platform/osx/joypad_osx.cpp14
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm16
-rw-r--r--platform/osx/osx_terminal_logger.mm5
-rw-r--r--platform/uwp/app_uwp.cpp15
-rw-r--r--platform/uwp/context_egl_uwp.cpp20
-rw-r--r--platform/uwp/export/app_packager.cpp3
-rw-r--r--platform/uwp/export/app_packager.h1
-rw-r--r--platform/uwp/export/export_plugin.cpp28
-rw-r--r--platform/uwp/export/export_plugin.h21
-rw-r--r--platform/uwp/joypad_uwp.cpp10
-rw-r--r--platform/uwp/os_uwp.cpp66
-rw-r--r--platform/windows/crash_handler_windows.cpp23
-rw-r--r--platform/windows/display_server_windows.cpp325
-rw-r--r--platform/windows/display_server_windows.h16
-rw-r--r--platform/windows/export/export_plugin.cpp3
-rw-r--r--platform/windows/export/export_plugin.h1
-rw-r--r--platform/windows/gl_manager_windows.cpp39
-rw-r--r--platform/windows/godot_windows.cpp5
-rw-r--r--platform/windows/joypad_windows.cpp46
-rw-r--r--platform/windows/joypad_windows.h3
-rw-r--r--platform/windows/os_windows.cpp81
-rw-r--r--platform/windows/os_windows.h5
-rw-r--r--platform/windows/windows_terminal_logger.cpp14
89 files changed, 1668 insertions, 751 deletions
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp
index 246ec6b198..10f23b320b 100644
--- a/platform/android/android_input_handler.cpp
+++ b/platform/android/android_input_handler.cpp
@@ -165,8 +165,9 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector
ERR_CONTINUE(idx == -1);
- if (touch[i].pos == p_points[idx].pos)
- continue; //no move unncesearily
+ if (touch[i].pos == p_points[idx].pos) {
+ continue; // Don't move unnecessarily.
+ }
Ref<InputEventScreenDrag> ev;
ev.instantiate();
diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp
index f544f29b10..f80f1e3051 100644
--- a/platform/android/api/api.cpp
+++ b/platform/android/api/api.cpp
@@ -64,14 +64,14 @@ void JavaClassWrapper::_bind_methods() {
#if !defined(ANDROID_ENABLED)
-Variant JavaClass::call(const StringName &, const Variant **, int, Callable::CallError &) {
+Variant JavaClass::callp(const StringName &, const Variant **, int, Callable::CallError &) {
return Variant();
}
JavaClass::JavaClass() {
}
-Variant JavaObject::call(const StringName &, const Variant **, int, Callable::CallError &) {
+Variant JavaObject::callp(const StringName &, const Variant **, int, Callable::CallError &) {
return Variant();
}
diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h
index d4d1208757..96b7b48e48 100644
--- a/platform/android/api/java_class_wrapper.h
+++ b/platform/android/api/java_class_wrapper.h
@@ -179,7 +179,7 @@ class JavaClass : public RefCounted {
#endif
public:
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
+ virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
JavaClass();
};
@@ -195,7 +195,7 @@ class JavaObject : public RefCounted {
#endif
public:
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
+ virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
#ifdef ANDROID_ENABLED
JavaObject(const Ref<JavaClass> &p_base, jobject *p_instance);
diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h
index d8503b6caf..74ca10e5e2 100644
--- a/platform/android/api/jni_singleton.h
+++ b/platform/android/api/jni_singleton.h
@@ -31,10 +31,10 @@
#ifndef JNI_SINGLETON_H
#define JNI_SINGLETON_H
-#include <core/config/engine.h>
-#include <core/variant/variant.h>
+#include "core/config/engine.h"
+#include "core/variant/variant.h"
#ifdef ANDROID_ENABLED
-#include <platform/android/jni_utils.h>
+#include "platform/android/jni_utils.h"
#endif
class JNISingleton : public Object {
@@ -52,7 +52,7 @@ class JNISingleton : public Object {
#endif
public:
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override {
+ virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override {
#ifdef ANDROID_ENABLED
Map<StringName, MethodData>::Element *E = method_map.find(p_method);
@@ -70,7 +70,7 @@ public:
if (call_error) {
// The method is not in this map, defaulting to the regular instance calls.
- return Object::call(p_method, p_args, p_argcount, r_error);
+ return Object::callp(p_method, p_args, p_argcount, r_error);
}
ERR_FAIL_COND_V(!instance, Variant());
@@ -93,8 +93,9 @@ public:
for (int i = 0; i < p_argcount; i++) {
jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
v[i] = vr.val;
- if (vr.obj)
+ if (vr.obj) {
to_erase.push_back(vr.obj);
+ }
}
Variant ret;
@@ -175,7 +176,7 @@ public:
#else // ANDROID_ENABLED
// Defaulting to the regular instance calls.
- return Object::call(p_method, p_args, p_argcount, r_error);
+ return Object::callp(p_method, p_args, p_argcount, r_error);
#endif
}
@@ -197,18 +198,19 @@ public:
}
void add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args) {
- if (p_args.size() == 0)
+ if (p_args.size() == 0) {
ADD_SIGNAL(MethodInfo(p_name));
- else if (p_args.size() == 1)
+ } else if (p_args.size() == 1) {
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1")));
- else if (p_args.size() == 2)
+ } else if (p_args.size() == 2) {
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2")));
- else if (p_args.size() == 3)
+ } else if (p_args.size() == 3) {
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3")));
- else if (p_args.size() == 4)
+ } else if (p_args.size() == 4) {
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4")));
- else if (p_args.size() == 5)
+ } else if (p_args.size() == 5) {
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"), PropertyInfo(p_args[4], "arg5")));
+ }
}
#endif
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index cd478bb90f..8495d2cc18 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -56,8 +56,9 @@ void AudioDriverOpenSL::_buffer_callback(
}
}
- if (mix)
+ if (mix) {
mutex.unlock();
+ }
const int32_t *src_buff = mixdown_buffer;
@@ -312,13 +313,15 @@ AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const {
}
void AudioDriverOpenSL::lock() {
- if (active)
+ if (active) {
mutex.lock();
+ }
}
void AudioDriverOpenSL::unlock() {
- if (active)
+ if (active) {
mutex.unlock();
+ }
}
void AudioDriverOpenSL::finish() {
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index 5461a3aefa..7fb4f54fca 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "dir_access_jandroid.h"
+
#include "core/string/print_string.h"
#include "file_access_android.h"
#include "string_android.h"
@@ -51,8 +52,9 @@ Error DirAccessJAndroid::list_dir_begin() {
jstring js = env->NewStringUTF(current_dir.utf8().get_data());
int res = env->CallIntMethod(io, _dir_open, js);
- if (res <= 0)
+ if (res <= 0) {
return ERR_CANT_OPEN;
+ }
id = res;
@@ -64,8 +66,9 @@ String DirAccessJAndroid::get_next() {
JNIEnv *env = get_jni_env();
jstring str = (jstring)env->CallObjectMethod(io, _dir_next, id);
- if (!str)
+ if (!str) {
return "";
+ }
String ret = jstring_to_string((jstring)str, env);
env->DeleteLocalRef((jobject)str);
@@ -83,8 +86,9 @@ bool DirAccessJAndroid::current_is_hidden() const {
}
void DirAccessJAndroid::list_dir_end() {
- if (id == 0)
+ if (id == 0) {
return;
+ }
JNIEnv *env = get_jni_env();
env->CallVoidMethod(io, _dir_close, id);
@@ -102,22 +106,25 @@ String DirAccessJAndroid::get_drive(int p_drive) {
Error DirAccessJAndroid::change_dir(String p_dir) {
JNIEnv *env = get_jni_env();
- if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty()))
+ if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) {
return OK;
+ }
String new_dir;
- if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/"))
+ if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) {
p_dir = p_dir.substr(0, p_dir.length() - 1);
+ }
- if (p_dir.begins_with("/"))
+ if (p_dir.begins_with("/")) {
new_dir = p_dir.substr(1, p_dir.length());
- else if (p_dir.begins_with("res://"))
+ } else if (p_dir.begins_with("res://")) {
new_dir = p_dir.substr(6, p_dir.length());
- else if (current_dir.is_empty())
+ } else if (current_dir.is_empty()) {
new_dir = p_dir;
- else
+ } else {
new_dir = current_dir.plus_file(p_dir);
+ }
//test if newdir exists
new_dir = new_dir.simplify_path();
@@ -125,8 +132,9 @@ Error DirAccessJAndroid::change_dir(String p_dir) {
jstring js = env->NewStringUTF(new_dir.utf8().get_data());
int res = env->CallIntMethod(io, _dir_open, js);
env->DeleteLocalRef(js);
- if (res <= 0)
+ if (res <= 0) {
return ERR_INVALID_PARAMETER;
+ }
env->CallVoidMethod(io, _dir_close, res);
@@ -141,10 +149,11 @@ String DirAccessJAndroid::get_current_dir(bool p_include_drive) {
bool DirAccessJAndroid::file_exists(String p_file) {
String sd;
- if (current_dir.is_empty())
+ if (current_dir.is_empty()) {
sd = p_file;
- else
+ } else {
sd = current_dir.plus_file(p_file);
+ }
FileAccessAndroid *f = memnew(FileAccessAndroid);
bool exists = f->file_exists(sd);
@@ -158,27 +167,30 @@ bool DirAccessJAndroid::dir_exists(String p_dir) {
String sd;
- if (current_dir.is_empty())
+ if (current_dir.is_empty()) {
sd = p_dir;
- else {
- if (p_dir.is_relative_path())
+ } else {
+ if (p_dir.is_relative_path()) {
sd = current_dir.plus_file(p_dir);
- else
+ } else {
sd = fix_path(p_dir);
+ }
}
String path = sd.simplify_path();
- if (path.begins_with("/"))
+ if (path.begins_with("/")) {
path = path.substr(1, path.length());
- else if (path.begins_with("res://"))
+ } else if (path.begins_with("res://")) {
path = path.substr(6, path.length());
+ }
jstring js = env->NewStringUTF(path.utf8().get_data());
int res = env->CallIntMethod(io, _dir_open, js);
env->DeleteLocalRef(js);
- if (res <= 0)
+ if (res <= 0) {
return false;
+ }
env->CallVoidMethod(io, _dir_close, res);
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index b0f16337ed..a7a8801bdc 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -164,7 +164,7 @@ int DisplayServerAndroid::screen_get_dpi(int p_screen) const {
float DisplayServerAndroid::screen_get_refresh_rate(int p_screen) const {
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
if (!godot_io_java) {
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return SCREEN_REFRESH_RATE_FALLBACK;
}
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 23b5c5e4e5..aa4b394965 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -32,6 +32,9 @@
#include "export_plugin.h"
+#include "core/os/os.h"
+#include "editor/editor_settings.h"
+
void register_android_exporter() {
String exe_ext;
if (OS::get_singleton()->get_name() == "Windows") {
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index df2d32e152..4220c57cae 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -30,6 +30,26 @@
#include "export_plugin.h"
+#include "gradle_export_util.h"
+
+#include "core/config/project_settings.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
+#include "core/io/image_loader.h"
+#include "core/io/json.h"
+#include "core/io/marshalls.h"
+#include "core/version.h"
+#include "drivers/png/png_driver_common.h"
+#include "editor/editor_log.h"
+#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
+#include "editor/editor_settings.h"
+#include "main/splash.gen.h"
+#include "platform/android/logo.gen.h"
+#include "platform/android/run_icon.gen.h"
+
+#include <string.h>
+
static const char *android_perms[] = {
"ACCESS_CHECKIN_PROPERTIES",
"ACCESS_COARSE_LOCATION",
@@ -523,7 +543,7 @@ bool EditorExportPlatformAndroid::_should_compress_asset(const String &p_path, c
".webp", // Same reasoning as .png
".cfb", // Don't let small config files slow-down startup
".scn", // Binary scenes are usually already compressed
- ".stex", // Streamable textures are usually already compressed
+ ".ctex", // Streamable textures are usually already compressed
// Trailer for easier processing
nullptr
};
@@ -1367,6 +1387,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref<EditorExportPreset> &
Vector<String> string_table;
String package_name = p_preset->get("package/name");
+ Dictionary appnames = ProjectSettings::get_singleton()->get("application/config/name_localized");
for (uint32_t i = 0; i < string_count; i++) {
uint32_t offset = decode_uint32(&r_manifest[string_table_begins + i * 4]);
@@ -1381,9 +1402,8 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref<EditorExportPreset> &
} else {
String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_");
- String prop = "application/config/name_" + lang;
- if (ProjectSettings::get_singleton()->has_setting(prop)) {
- str = ProjectSettings::get_singleton()->get(prop);
+ if (appnames.has(lang)) {
+ str = appnames[lang];
} else {
str = get_project_name(package_name);
}
diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h
index 9e952ecb8f..a4eb608b19 100644
--- a/platform/android/export/export_plugin.h
+++ b/platform/android/export/export_plugin.h
@@ -28,29 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/config/project_settings.h"
-#include "core/io/dir_access.h"
-#include "core/io/file_access.h"
-#include "core/io/image_loader.h"
-#include "core/io/json.h"
-#include "core/io/marshalls.h"
+#include "godot_plugin_config.h"
+
#include "core/io/zip_io.h"
#include "core/os/os.h"
-#include "core/templates/safe_refcount.h"
-#include "core/version.h"
-#include "drivers/png/png_driver_common.h"
#include "editor/editor_export.h"
-#include "editor/editor_log.h"
-#include "editor/editor_node.h"
-#include "editor/editor_settings.h"
-#include "main/splash.gen.h"
-#include "platform/android/logo.gen.h"
-#include "platform/android/run_icon.gen.h"
-
-#include "godot_plugin_config.h"
-#include "gradle_export_util.h"
-
-#include <string.h>
const String SPLASH_CONFIG_XML_CONTENT = R"SPLASH(<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index babd8173d0..ab915a5f85 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -30,6 +30,8 @@
#include "gradle_export_util.h"
+#include "core/config/project_settings.h"
+
int _get_android_orientation_value(DisplayServer::ScreenOrientation screen_orientation) {
switch (screen_orientation) {
case DisplayServer::SCREEN_PORTRAIT:
@@ -73,11 +75,10 @@ String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_or
// Utility method used to create a directory.
Error create_directory(const String &p_dir) {
if (!DirAccess::exists(p_dir)) {
- DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ DirAccessRef filesystem_da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
Error err = filesystem_da->make_dir_recursive(p_dir);
ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
- memdelete(filesystem_da);
}
return OK;
}
@@ -159,6 +160,7 @@ Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset
return ERR_CANT_OPEN;
}
da->list_dir_begin();
+ Dictionary appnames = ProjectSettings::get_singleton()->get("application/config/name_localized");
while (true) {
String file = da->get_next();
if (file.is_empty()) {
@@ -169,10 +171,9 @@ Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset
continue;
}
String locale = file.replace("values-", "").replace("-r", "_");
- String property_name = "application/config/name_" + locale;
String locale_directory = "res://android/build/res/" + file + "/godot_project_name_string.xml";
- if (ProjectSettings::get_singleton()->has_setting(property_name)) {
- String locale_project_name = ProjectSettings::get_singleton()->get(property_name);
+ if (appnames.has(locale)) {
+ String locale_project_name = appnames[locale];
String processed_xml_string = vformat(godot_project_name_xml_string, _android_xml_escape(locale_project_name));
print_verbose("Storing project name for locale " + locale + " under " + locale_directory);
store_string_at_path(locale_directory, processed_xml_string);
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index 26bdcb9520..c84a919b6b 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -29,30 +29,28 @@
/*************************************************************************/
#include "file_access_android.h"
+
#include "core/string/print_string.h"
AAssetManager *FileAccessAndroid::asset_manager = nullptr;
-/*void FileAccessAndroid::make_default() {
- create_func=create_android;
-}*/
-
FileAccess *FileAccessAndroid::create_android() {
return memnew(FileAccessAndroid);
}
Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
String path = fix_path(p_path).simplify_path();
- if (path.begins_with("/"))
+ if (path.begins_with("/")) {
path = path.substr(1, path.length());
- else if (path.begins_with("res://"))
+ } else if (path.begins_with("res://")) {
path = path.substr(6, path.length());
+ }
ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, ERR_UNAVAILABLE); //can't write on android..
a = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING);
- if (!a)
+ if (!a) {
return ERR_CANT_OPEN;
- //ERR_FAIL_COND_V(!a,ERR_FILE_NOT_FOUND);
+ }
len = AAsset_getLength(a);
pos = 0;
eof = false;
@@ -61,8 +59,9 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessAndroid::close() {
- if (!a)
+ if (!a) {
return;
+ }
AAsset_close(a);
a = nullptr;
}
@@ -146,15 +145,17 @@ void FileAccessAndroid::store_8(uint8_t p_dest) {
bool FileAccessAndroid::file_exists(const String &p_path) {
String path = fix_path(p_path).simplify_path();
- if (path.begins_with("/"))
+ if (path.begins_with("/")) {
path = path.substr(1, path.length());
- else if (path.begins_with("res://"))
+ } else if (path.begins_with("res://")) {
path = path.substr(6, path.length());
+ }
AAsset *at = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING);
- if (!at)
+ if (!at) {
return false;
+ }
AAsset_close(at);
return true;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
index 8fc16ab7ba..4525c5c212 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
@@ -147,8 +147,9 @@ public class GLUtils {
Log.i(TAG, String.format(" %s: %d\n", name, value[0]));
} else {
// Log.w(TAG, String.format(" %s: failed\n", name));
- while (egl.eglGetError() != EGL10.EGL_SUCCESS)
- ;
+ while (egl.eglGetError() != EGL10.EGL_SUCCESS) {
+ // Continue.
+ }
}
}
}
diff --git a/platform/android/java/nativeSrcsConfigs/CMakeLists.txt b/platform/android/java/nativeSrcsConfigs/CMakeLists.txt
index 34925684da..966c02f7d7 100644
--- a/platform/android/java/nativeSrcsConfigs/CMakeLists.txt
+++ b/platform/android/java/nativeSrcsConfigs/CMakeLists.txt
@@ -15,5 +15,4 @@ file(GLOB_RECURSE HEADERS ${GODOT_ROOT_DIR}/*.h**)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME}
SYSTEM PUBLIC
- ${GODOT_ROOT_DIR}
- ${GODOT_ROOT_DIR}/modules/gdnative/include)
+ ${GODOT_ROOT_DIR})
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index f823e2c27f..1805807f90 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -29,13 +29,15 @@
/*************************************************************************/
#include "api/java_class_wrapper.h"
+
#include "string_android.h"
#include "thread_jandroid.h"
bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret) {
Map<StringName, List<MethodInfo>>::Element *M = methods.find(p_method);
- if (!M)
+ if (!M) {
return false;
+ }
JNIEnv *env = get_jni_env();
ERR_FAIL_COND_V(env == nullptr, false);
@@ -68,8 +70,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
//bug?
} break;
case ARG_TYPE_BOOLEAN: {
- if (p_args[i]->get_type() != Variant::BOOL)
+ if (p_args[i]->get_type() != Variant::BOOL) {
arg_expected = Variant::BOOL;
+ }
} break;
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_BYTE:
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_CHAR:
@@ -81,27 +84,27 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
case ARG_TYPE_SHORT:
case ARG_TYPE_INT:
case ARG_TYPE_LONG: {
- if (!p_args[i]->is_num())
+ if (!p_args[i]->is_num()) {
arg_expected = Variant::INT;
-
+ }
} break;
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_FLOAT:
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_DOUBLE:
case ARG_TYPE_FLOAT:
case ARG_TYPE_DOUBLE: {
- if (!p_args[i]->is_num())
+ if (!p_args[i]->is_num()) {
arg_expected = Variant::FLOAT;
-
+ }
} break;
case ARG_TYPE_STRING: {
- if (p_args[i]->get_type() != Variant::STRING)
+ if (p_args[i]->get_type() != Variant::STRING) {
arg_expected = Variant::STRING;
-
+ }
} break;
case ARG_TYPE_CLASS: {
- if (p_args[i]->get_type() != Variant::OBJECT)
+ if (p_args[i]->get_type() != Variant::OBJECT) {
arg_expected = Variant::OBJECT;
- else {
+ } else {
Ref<RefCounted> ref = *p_args[i];
if (!ref.is_null()) {
if (Object::cast_to<JavaObject>(ref.ptr())) {
@@ -118,12 +121,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
}
}
}
-
} break;
default: {
- if (p_args[i]->get_type() != Variant::ARRAY)
+ if (p_args[i]->get_type() != Variant::ARRAY) {
arg_expected = Variant::ARRAY;
-
+ }
} break;
}
@@ -135,15 +137,17 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
break;
}
}
- if (!valid)
+ if (!valid) {
continue;
+ }
method = &E;
break;
}
- if (!method)
+ if (!method) {
return true; //no version convinces
+ }
r_error.error = Callable::CallError::CALL_OK;
@@ -481,14 +485,14 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
return success;
}
-Variant JavaClass::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
+Variant JavaClass::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
Variant ret;
bool found = _call_method(nullptr, p_method, p_args, p_argcount, r_error, ret);
if (found) {
return ret;
}
- return RefCounted::call(p_method, p_args, p_argcount, r_error);
+ return RefCounted::callp(p_method, p_args, p_argcount, r_error);
}
JavaClass::JavaClass() {
@@ -496,7 +500,7 @@ JavaClass::JavaClass() {
/////////////////////
-Variant JavaObject::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
+Variant JavaObject::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
return Variant();
}
@@ -780,9 +784,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
bool val = env->CallBooleanMethod(o, JavaClassWrapper::singleton->Boolean_booleanValue);
ret.push_back(val);
}
@@ -801,9 +805,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
int val = env->CallByteMethod(o, JavaClassWrapper::singleton->Byte_byteValue);
ret.push_back(val);
}
@@ -821,9 +825,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
int val = env->CallCharMethod(o, JavaClassWrapper::singleton->Character_characterValue);
ret.push_back(val);
}
@@ -841,9 +845,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
int val = env->CallShortMethod(o, JavaClassWrapper::singleton->Short_shortValue);
ret.push_back(val);
}
@@ -861,9 +865,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
int val = env->CallIntMethod(o, JavaClassWrapper::singleton->Integer_integerValue);
ret.push_back(val);
}
@@ -881,9 +885,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
int64_t val = env->CallLongMethod(o, JavaClassWrapper::singleton->Long_longValue);
ret.push_back(val);
}
@@ -901,9 +905,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
float val = env->CallFloatMethod(o, JavaClassWrapper::singleton->Float_floatValue);
ret.push_back(val);
}
@@ -921,9 +925,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
double val = env->CallDoubleMethod(o, JavaClassWrapper::singleton->Double_doubleValue);
ret.push_back(val);
}
@@ -942,9 +946,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
for (int i = 0; i < count; i++) {
jobject o = env->GetObjectArrayElement(arr, i);
- if (!o)
+ if (!o) {
ret.push_back(Variant());
- else {
+ } else {
String val = jstring_to_string((jstring)o, env);
ret.push_back(val);
}
@@ -962,8 +966,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
}
Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
- if (class_cache.has(p_class))
+ if (class_cache.has(p_class)) {
return class_cache[p_class];
+ }
JNIEnv *env = get_jni_env();
ERR_FAIL_COND_V(env == nullptr, Ref<JavaClass>());
@@ -971,10 +976,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
jclass bclass = env->FindClass(p_class.utf8().get_data());
ERR_FAIL_COND_V(!bclass, Ref<JavaClass>());
- //jmethodID getDeclaredMethods = env->GetMethodID(bclass,"getDeclaredMethods", "()[Ljava/lang/reflect/Method;");
-
- //ERR_FAIL_COND_V(!getDeclaredMethods,Ref<JavaClass>());
-
jobjectArray methods = (jobjectArray)env->CallObjectMethod(bclass, getDeclaredMethods);
ERR_FAIL_COND_V(!methods, Ref<JavaClass>());
@@ -1057,8 +1058,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
float new_likeliness = 0;
float existing_likeliness = 0;
- if (E->get().param_types.size() != mi.param_types.size())
+ if (E->get().param_types.size() != mi.param_types.size()) {
continue;
+ }
bool valid = true;
for (int j = 0; j < E->get().param_types.size(); j++) {
Variant::Type _new;
@@ -1075,8 +1077,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
existing_likeliness = existing_l;
}
- if (!valid)
+ if (!valid) {
continue;
+ }
if (new_likeliness > existing_likeliness) {
java_class->methods[str_method].erase(E);
@@ -1087,10 +1090,11 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
}
if (!discard) {
- if (mi._static)
+ if (mi._static) {
mi.method = env->GetStaticMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data());
- else
+ } else {
mi.method = env->GetMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data());
+ }
ERR_CONTINUE(!mi.method);
@@ -1100,7 +1104,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
env->DeleteLocalRef(obj);
env->DeleteLocalRef(param_types);
env->DeleteLocalRef(return_type);
- };
+ }
env->DeleteLocalRef(methods);
diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp
index 8a2788e848..d6e3ad90b1 100644
--- a/platform/android/java_godot_io_wrapper.cpp
+++ b/platform/android/java_godot_io_wrapper.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "java_godot_io_wrapper.h"
+
#include "core/error/error_list.h"
// JNIEnv is only valid within the thread it belongs to, in a multi threading environment
@@ -141,12 +142,12 @@ float GodotIOJavaWrapper::get_screen_refresh_rate(float fallback) {
if (_get_screen_refresh_rate) {
JNIEnv *env = get_jni_env();
if (env == nullptr) {
- ERR_PRINT("An error occured while trying to get screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get screen refresh rate.");
return fallback;
}
return (float)env->CallDoubleMethod(godot_io_instance, _get_screen_refresh_rate, (double)fallback);
}
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return fallback;
}
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index e7ab0ef7ed..249717921f 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -200,8 +200,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) {
- if (step.get() == 0)
+ if (step.get() == 0) {
return;
+ }
if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST);
@@ -209,8 +210,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jcl
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) {
- if (step.get() == -1)
+ if (step.get() == -1) {
return;
+ }
if (step.get() == 0) {
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
@@ -243,8 +245,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
}
void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
Vector<AndroidInputHandler::TouchPos> points;
for (int i = 0; i < pointer_count; i++) {
@@ -279,32 +282,36 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FIFF(JNI
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jclass clazz, jint p_type, jfloat p_x, jfloat p_y) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
input_handler->process_hover(p_type, Point2(p_x, p_y));
}
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubleTap(JNIEnv *env, jclass clazz, jint p_button_mask, jint p_x, jint p_y) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
input_handler->process_double_tap(p_button_mask, Point2(p_x, p_y));
}
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jclass clazz, jint p_x, jint p_y) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
input_handler->process_scroll(Point2(p_x, p_y));
}
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
AndroidInputHandler::JoypadEvent jevent;
jevent.device = p_device;
@@ -369,8 +376,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_scancode, jint p_unicode_char, jboolean p_pressed) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
input_handler->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed);
}
@@ -392,15 +400,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
os_android->main_loop_focusin();
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
os_android->main_loop_focusout();
}
@@ -426,16 +436,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
for (int i = 0; i < count; i++) {
jobject obj = env->GetObjectArrayElement(params, i);
Variant v;
- if (obj)
+ if (obj) {
v = _jobject_to_variant(env, obj);
+ }
memnew_placement(&vlist[i], Variant);
vlist[i] = v;
vptr[i] = &vlist[i];
env->DeleteLocalRef(obj);
- };
+ }
Callable::CallError err;
- obj->call(str_method, (const Variant **)vptr, count, err);
+ obj->callp(str_method, (const Variant **)vptr, count, err);
// something
env->PopLocalFrame(nullptr);
@@ -451,17 +462,20 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
String str_method = jstring_to_string(method, env);
int count = env->GetArrayLength(params);
- Variant args[VARIANT_ARG_MAX];
- for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) {
+ Variant *args = (Variant *)alloca(sizeof(Variant) * count);
+ const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * count);
+
+ for (int i = 0; i < count; i++) {
jobject obj = env->GetObjectArrayElement(params, i);
- if (obj)
+ if (obj) {
args[i] = _jobject_to_variant(env, obj);
+ }
env->DeleteLocalRef(obj);
- };
+ argptrs[i] = &args[i];
+ }
- static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8");
- obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+ MessageQueue::get_singleton()->push_callp(obj, str_method, (const Variant **)argptrs, count);
// something
env->PopLocalFrame(nullptr);
}
@@ -478,8 +492,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResu
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
if (os_android->get_main_loop()) {
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED);
@@ -487,8 +502,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNI
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
if (os_android->get_main_loop()) {
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED);
diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp
index 5beec6b611..754267c834 100644
--- a/platform/android/java_godot_wrapper.cpp
+++ b/platform/android/java_godot_wrapper.cpp
@@ -92,8 +92,9 @@ jobject GodotJavaWrapper::get_activity() {
jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) {
if (godot_class) {
- if (p_env == nullptr)
+ if (p_env == nullptr) {
p_env = get_jni_env();
+ }
ERR_FAIL_COND_V(p_env == nullptr, nullptr);
@@ -129,8 +130,9 @@ GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() {
void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
if (_on_video_init) {
- if (p_env == nullptr)
+ if (p_env == nullptr) {
p_env = get_jni_env();
+ }
ERR_FAIL_COND(p_env == nullptr);
p_env->CallVoidMethod(godot_instance, _on_video_init);
@@ -158,8 +160,9 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
void GodotJavaWrapper::restart(JNIEnv *p_env) {
if (_restart) {
- if (p_env == nullptr)
+ if (p_env == nullptr) {
p_env = get_jni_env();
+ }
ERR_FAIL_COND(p_env == nullptr);
p_env->CallVoidMethod(godot_instance, _restart);
@@ -168,8 +171,9 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) {
void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
if (_finish) {
- if (p_env == nullptr)
+ if (p_env == nullptr) {
p_env = get_jni_env();
+ }
ERR_FAIL_COND(p_env == nullptr);
p_env->CallVoidMethod(godot_instance, _finish);
diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp
index 7e81565d9d..e2573d10f8 100644
--- a/platform/android/jni_utils.cpp
+++ b/platform/android/jni_utils.cpp
@@ -46,7 +46,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
env->DeleteLocalRef(bclass);
} else {
v.val.z = *p_arg;
- };
+ }
} break;
case Variant::INT: {
if (force_jobject) {
@@ -61,7 +61,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} else {
v.val.i = *p_arg;
- };
+ }
} break;
case Variant::FLOAT: {
if (force_jobject) {
@@ -76,7 +76,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} else {
v.val.f = *p_arg;
- };
+ }
} break;
case Variant::STRING: {
String s = *p_arg;
@@ -111,7 +111,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
jstring str = env->NewStringUTF(String(keys[j]).utf8().get_data());
env->SetObjectArrayElement(jkeys, j, str);
env->DeleteLocalRef(str);
- };
+ }
jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V");
jvalue val;
@@ -128,7 +128,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
if (v.obj) {
env->DeleteLocalRef(v.obj);
}
- };
+ }
jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V");
val.l = jvalues;
@@ -205,7 +205,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
if (name == "java.lang.String") {
return jstring_to_string((jstring)obj, env);
- };
+ }
if (name == "[Ljava.lang.String;") {
jobjectArray arr = (jobjectArray)obj;
@@ -219,20 +219,20 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
}
return sarr;
- };
+ }
if (name == "java.lang.Boolean") {
jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
bool ret = env->CallBooleanMethod(obj, boolValue);
return ret;
- };
+ }
if (name == "java.lang.Integer" || name == "java.lang.Long") {
jclass nclass = env->FindClass("java/lang/Number");
jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J");
jlong ret = env->CallLongMethod(obj, longValue);
return ret;
- };
+ }
if (name == "[I") {
jintArray arr = (jintArray)obj;
@@ -243,7 +243,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
int *w = sarr.ptrw();
env->GetIntArrayRegion(arr, 0, fCount, w);
return sarr;
- };
+ }
if (name == "[B") {
jbyteArray arr = (jbyteArray)obj;
@@ -254,14 +254,14 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
uint8_t *w = sarr.ptrw();
env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w));
return sarr;
- };
+ }
if (name == "java.lang.Float" || name == "java.lang.Double") {
jclass nclass = env->FindClass("java/lang/Number");
jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
double ret = env->CallDoubleMethod(obj, doubleValue);
return ret;
- };
+ }
if (name == "[D") {
jdoubleArray arr = (jdoubleArray)obj;
@@ -275,9 +275,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
double n;
env->GetDoubleArrayRegion(arr, i, 1, &n);
w[i] = n;
- };
+ }
return sarr;
- };
+ }
if (name == "[F") {
jfloatArray arr = (jfloatArray)obj;
@@ -291,9 +291,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
float n;
env->GetFloatArrayRegion(arr, i, 1, &n);
w[i] = n;
- };
+ }
return sarr;
- };
+ }
if (name == "[Ljava.lang.Object;") {
jobjectArray arr = (jobjectArray)obj;
@@ -308,7 +308,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
}
return varr;
- };
+ }
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
Dictionary ret;
@@ -327,10 +327,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
for (int i = 0; i < keys.size(); i++) {
ret[keys[i]] = vals[i];
- };
+ }
return ret;
- };
+ }
env->DeleteLocalRef(c);
@@ -359,8 +359,9 @@ Variant::Type get_jni_type(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
- if (p_type == _type_to_vtype[idx].name)
+ if (p_type == _type_to_vtype[idx].name) {
return _type_to_vtype[idx].type;
+ }
idx++;
}
@@ -390,8 +391,9 @@ const char *get_jni_sig(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
- if (p_type == _type_to_vtype[idx].name)
+ if (p_type == _type_to_vtype[idx].name) {
return _type_to_vtype[idx].sig;
+ }
idx++;
}
diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp
index 620df539e4..a65e7c6724 100644
--- a/platform/android/net_socket_android.cpp
+++ b/platform/android/net_socket_android.cpp
@@ -77,18 +77,21 @@ NetSocketAndroid::~NetSocketAndroid() {
void NetSocketAndroid::close() {
NetSocketPosix::close();
- if (wants_broadcast)
+ if (wants_broadcast) {
multicast_lock_release();
- if (multicast_groups)
+ }
+ if (multicast_groups) {
multicast_lock_release();
+ }
wants_broadcast = false;
multicast_groups = 0;
}
Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (p_enabled != wants_broadcast) {
if (p_enabled) {
@@ -105,11 +108,13 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
- if (!multicast_groups)
+ if (!multicast_groups) {
multicast_lock_acquire();
+ }
multicast_groups++;
return OK;
@@ -117,14 +122,16 @@ Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, S
Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
ERR_FAIL_COND_V(multicast_groups == 0, ERR_BUG);
multicast_groups--;
- if (!multicast_groups)
+ if (!multicast_groups) {
multicast_lock_release();
+ }
return OK;
}
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index d1672d6ea3..b17b0f3139 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -81,17 +81,18 @@ void OS_Android::alert(const String &p_alert, const String &p_title) {
void OS_Android::initialize_core() {
OS_Unix::initialize_core();
- if (use_apk_expansion)
+ if (use_apk_expansion) {
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
- else {
+ } else {
FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
}
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
- if (use_apk_expansion)
+ if (use_apk_expansion) {
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
- else
+ } else {
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
+ }
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
@@ -162,20 +163,23 @@ MainLoop *OS_Android::get_main_loop() const {
}
void OS_Android::main_loop_begin() {
- if (main_loop)
+ if (main_loop) {
main_loop->initialize();
+ }
}
bool OS_Android::main_loop_iterate() {
- if (!main_loop)
+ if (!main_loop) {
return false;
+ }
DisplayServerAndroid::get_singleton()->process_events();
return Main::iteration();
}
void OS_Android::main_loop_end() {
- if (main_loop)
+ if (main_loop) {
main_loop->finalize();
+ }
}
void OS_Android::main_loop_focusout() {
@@ -207,8 +211,9 @@ String OS_Android::get_locale() const {
String OS_Android::get_model_name() const {
String model = godot_io_java->get_model();
- if (!model.is_empty())
+ if (!model.is_empty()) {
return model;
+ }
return OS_Unix::get_model_name();
}
@@ -218,8 +223,9 @@ String OS_Android::get_data_path() const {
}
String OS_Android::get_user_data_dir() const {
- if (!data_dir_cache.is_empty())
+ if (!data_dir_cache.is_empty()) {
return data_dir_cache;
+ }
String data_dir = godot_io_java->get_user_data_dir();
if (!data_dir.is_empty()) {
@@ -230,8 +236,9 @@ String OS_Android::get_user_data_dir() const {
}
String OS_Android::get_cache_path() const {
- if (!cache_dir_cache.is_empty())
+ if (!cache_dir_cache.is_empty()) {
return cache_dir_cache;
+ }
String cache_dir = godot_io_java->get_cache_dir();
if (!cache_dir.is_empty()) {
@@ -243,8 +250,9 @@ String OS_Android::get_cache_path() const {
String OS_Android::get_unique_id() const {
String unique_id = godot_io_java->get_unique_id();
- if (!unique_id.is_empty())
+ if (!unique_id.is_empty()) {
return unique_id;
+ }
return OS::get_unique_id();
}
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index 48aeb3d070..158512803a 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -114,10 +114,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS
String signal_name = jstring_to_string(j_signal_name, env);
int count = env->GetArrayLength(j_signal_params);
- ERR_FAIL_COND_MSG(count > VARIANT_ARG_MAX, "Maximum argument count exceeded!");
- Variant variant_params[VARIANT_ARG_MAX];
- const Variant *args[VARIANT_ARG_MAX];
+ Variant *variant_params = (Variant *)alloca(sizeof(Variant) * count);
+ const Variant **args = (const Variant **)alloca(sizeof(Variant *) * count);
for (int i = 0; i < count; i++) {
jobject j_param = env->GetObjectArrayElement(j_signal_params, i);
@@ -126,7 +125,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS
env->DeleteLocalRef(j_param);
};
- singleton->emit_signal(StringName(signal_name), args, count);
+ singleton->emit_signalp(StringName(signal_name), args, count);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterGDNativeLibraries(JNIEnv *env, jclass clazz, jobjectArray gdnlib_paths) {
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 5130a26f15..c5c9b5a5f9 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "app_delegate.h"
+
#include "core/config/project_settings.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#import "godot_view.h"
@@ -76,7 +77,7 @@ static ViewController *mainViewController = nil;
// bail, things did not go very well for us, should probably output a message on screen with our error code...
exit(0);
return NO;
- };
+ }
ViewController *viewController = [[ViewController alloc] init];
viewController.godotView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
@@ -99,7 +100,7 @@ static ViewController *mainViewController = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
return YES;
-};
+}
- (void)onAudioInterruption:(NSNotification *)notification {
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
@@ -111,17 +112,17 @@ static ViewController *mainViewController = nil;
OSIPhone::get_singleton()->on_focus_in();
}
}
-};
+}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
}
-};
+}
- (void)applicationWillTerminate:(UIApplication *)application {
iphone_finish();
-};
+}
// When application goes to background (e.g. user switches to another app or presses Home),
// then applicationWillResignActive -> applicationDidEnterBackground are called.
diff --git a/platform/iphone/display_layer.mm b/platform/iphone/display_layer.mm
index 7448dfed4a..92e81448ac 100644
--- a/platform/iphone/display_layer.mm
+++ b/platform/iphone/display_layer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "display_layer.h"
+
#include "core/config/project_settings.h"
#include "core/os/keyboard.h"
#include "display_server_iphone.h"
@@ -153,17 +154,6 @@
return NO;
}
- // if (OS::get_singleton()) {
- // OS::VideoMode vm;
- // vm.fullscreen = true;
- // vm.width = backingWidth;
- // vm.height = backingHeight;
- // vm.resizable = false;
- // OS::get_singleton()->set_video_mode(vm);
- // OSIPhone::get_singleton()->set_base_framebuffer(viewFramebuffer);
- // };
- // gl_view_base_fb = viewFramebuffer;
-
return YES;
}
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index 9491c9cf90..a0f8daf5a0 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "display_server_iphone.h"
+
#import "app_delegate.h"
#include "core/config/project_settings.h"
#include "core/io/file_access_pack.h"
@@ -231,7 +232,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse
ev->set_position(Vector2(p_x, p_y));
perform_event(ev);
}
-};
+}
void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
@@ -241,16 +242,16 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int
ev->set_position(Vector2(p_x, p_y));
ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
perform_event(ev);
- };
-};
+ }
+}
void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) {
Input::get_singleton()->parse_input_event(p_event);
-};
+}
void DisplayServerIPhone::touches_cancelled(int p_idx) {
touch_press(p_idx, -1, -1, false, false);
-};
+}
// MARK: Keyboard
@@ -263,13 +264,13 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) {
ev->set_physical_keycode(p_key);
ev->set_unicode((char32_t)p_key);
perform_event(ev);
-};
+}
// MARK: Motion
void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z));
-};
+}
void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
// Found out the Z should not be negated! Pass as is!
@@ -279,15 +280,15 @@ void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z)
p_z / kDisplayServerIPhoneAcceleration);
Input::get_singleton()->set_accelerometer(v_accelerometer);
-};
+}
void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z));
-};
+}
void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z));
-};
+}
// MARK: -
@@ -520,7 +521,7 @@ void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) {
float DisplayServerIPhone::screen_get_max_scale() const {
return screen_get_scale(SCREEN_OF_MAIN_WINDOW);
-};
+}
void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
screen_orientation = p_orientation;
diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp
index 122e64d6a1..26c5acb13e 100644
--- a/platform/iphone/export/export_plugin.cpp
+++ b/platform/iphone/export/export_plugin.cpp
@@ -30,6 +30,8 @@
#include "export_plugin.h"
+#include "editor/editor_node.h"
+
void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
// Vulkan and OpenGL ES 3.0 both mandate ETC2 support.
@@ -90,13 +92,10 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/targeted_device_family", PROPERTY_HINT_ENUM, "iPhone,iPad,iPhone & iPad"), 2));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
Vector<PluginConfigIOS> found_plugins = get_plugins();
for (int i = 0; i < found_plugins.size(); i++) {
@@ -137,8 +136,11 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_itunes_sharing"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/camera_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/microphone_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/photolibrary_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "icons/iphone_120x120", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone/iPod Touch with Retina display
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "icons/iphone_180x180", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone with Retina HD display
@@ -198,8 +200,6 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
strnew += lines[i].replace("$modules_buildgrp", p_config.modules_buildgrp) + "\n";
} else if (lines[i].find("$name") != -1) {
strnew += lines[i].replace("$name", p_config.pkg_name) + "\n";
- } else if (lines[i].find("$info") != -1) {
- strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n";
} else if (lines[i].find("$bundle_identifier") != -1) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
} else if (lines[i].find("$short_version") != -1) {
@@ -208,8 +208,6 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
strnew += lines[i].replace("$version", p_preset->get("application/version")) + "\n";
} else if (lines[i].find("$signature") != -1) {
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
- } else if (lines[i].find("$copyright") != -1) {
- strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
} else if (lines[i].find("$team_id") != -1) {
strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n";
} else if (lines[i].find("$default_build_config") != -1) {
@@ -387,6 +385,36 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
String value = value_format.format(value_dictionary, "$_");
strnew += lines[i].replace("$launch_screen_background_color", value) + "\n";
+ } else if (lines[i].find("$pbx_locale_file_reference") != -1) {
+ String locale_files;
+ Vector<String> translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations");
+ if (translations.size() > 0) {
+ int index = 0;
+ for (const String &E : translations) {
+ Ref<Translation> tr = ResourceLoader::load(E);
+ if (tr.is_valid()) {
+ String lang = tr->get_locale();
+ locale_files += "D0BCFE4518AEBDA2004A" + itos(index).pad_zeros(4) + " /* " + lang + " */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = " + lang + "; path = " + lang + ".lproj/InfoPlist.strings; sourceTree = \"<group>\"; };";
+ }
+ index++;
+ }
+ }
+ strnew += lines[i].replace("$pbx_locale_file_reference", locale_files);
+ } else if (lines[i].find("$pbx_locale_build_reference") != -1) {
+ String locale_files;
+ Vector<String> translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations");
+ if (translations.size() > 0) {
+ int index = 0;
+ for (const String &E : translations) {
+ Ref<Translation> tr = ResourceLoader::load(E);
+ if (tr.is_valid()) {
+ String lang = tr->get_locale();
+ locale_files += "D0BCFE4518AEBDA2004A" + itos(index).pad_zeros(4) + " /* " + lang + " */,";
+ }
+ index++;
+ }
+ }
+ strnew += lines[i].replace("$pbx_locale_build_reference", locale_files);
} else {
strnew += lines[i] + "\n";
}
@@ -502,7 +530,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
String json_description = "{\"images\":[";
String sizes;
- DirAccess *da = DirAccess::open(p_iconset_dir);
+ DirAccessRef da = DirAccess::open(p_iconset_dir);
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_iconset_dir + "'.");
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
@@ -542,7 +570,6 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
}
if (err) {
- memdelete(da);
String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'.");
ERR_PRINT(err_str.utf8().get_data());
return err;
@@ -560,7 +587,6 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
json_description += String("}");
}
json_description += "]}";
- memdelete(da);
FileAccess *json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE);
ERR_FAIL_COND_V(!json_file, ERR_CANT_CREATE);
@@ -646,7 +672,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
}
Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
- DirAccess *da = DirAccess::open(p_dest_dir);
+ DirAccessRef da = DirAccess::open(p_dest_dir);
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_dest_dir + "'.");
for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
@@ -684,7 +710,6 @@ Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExp
err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
}
if (err) {
- memdelete(da);
String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'.";
ERR_PRINT(err_str.utf8().get_data());
return err;
@@ -732,7 +757,6 @@ Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExp
}
}
}
- memdelete(da);
return OK;
}
@@ -938,21 +962,15 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese
}
Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
- DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
-
String binary_name = p_out_dir.get_file().get_basename();
- DirAccess *da = DirAccess::create_for_path(p_asset);
+ DirAccessRef da = DirAccess::create_for_path(p_asset);
if (!da) {
- memdelete(filesystem_da);
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + p_asset + ".");
}
bool file_exists = da->file_exists(p_asset);
bool dir_exists = da->dir_exists(p_asset);
if (!file_exists && !dir_exists) {
- memdelete(da);
- memdelete(filesystem_da);
return ERR_FILE_NOT_FOUND;
}
@@ -1012,19 +1030,18 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String
destination = p_out_dir.plus_file(asset_path);
}
+ DirAccessRef filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
+
if (!filesystem_da->dir_exists(destination_dir)) {
Error make_dir_err = filesystem_da->make_dir_recursive(destination_dir);
if (make_dir_err) {
- memdelete(da);
- memdelete(filesystem_da);
return make_dir_err;
}
}
Error err = dir_exists ? da->copy_dir(p_asset, destination) : da->copy(p_asset, destination);
- memdelete(da);
if (err) {
- memdelete(filesystem_da);
return err;
}
IOSExportAsset exported_asset = { binary_name.plus_file(asset_path), p_is_framework, p_should_embed };
@@ -1089,8 +1106,6 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String
}
}
- memdelete(filesystem_da);
-
return OK;
}
@@ -1395,29 +1410,29 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
return ERR_FILE_BAD_PATH;
}
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (da) {
- String current_dir = da->get_current_dir();
-
- // remove leftovers from last export so they don't interfere
- // in case some files are no longer needed
- if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) {
- da->erase_contents_recursive();
- }
- if (da->change_dir(dest_dir + binary_name) == OK) {
- da->erase_contents_recursive();
- }
+ {
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ if (da) {
+ String current_dir = da->get_current_dir();
+
+ // remove leftovers from last export so they don't interfere
+ // in case some files are no longer needed
+ if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) {
+ da->erase_contents_recursive();
+ }
+ if (da->change_dir(dest_dir + binary_name) == OK) {
+ da->erase_contents_recursive();
+ }
- da->change_dir(current_dir);
+ da->change_dir(current_dir);
- if (!da->dir_exists(dest_dir + binary_name)) {
- Error err = da->make_dir(dest_dir + binary_name);
- if (err) {
- memdelete(da);
- return err;
+ if (!da->dir_exists(dest_dir + binary_name)) {
+ Error err = da->make_dir(dest_dir + binary_name);
+ if (err) {
+ return err;
+ }
}
}
- memdelete(da);
}
if (ep.step("Making .pck", 0)) {
@@ -1438,9 +1453,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
print_line("Static framework: " + library_to_use);
String pkg_name;
- if (p_preset->get("application/name") != "") {
- pkg_name = p_preset->get("application/name"); // app_name
- } else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
+ if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
} else {
pkg_name = "Unnamed";
@@ -1475,7 +1488,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
Vector<IOSExportAsset> assets;
- DirAccess *tmp_app_path = DirAccess::create_for_path(dest_dir);
+ DirAccessRef tmp_app_path = DirAccess::create_for_path(dest_dir);
ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE);
print_line("Unzipping...");
@@ -1554,7 +1567,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
if (dir_err) {
ERR_PRINT("Can't create '" + dir_name + "'.");
unzClose(src_pkg_zip);
- memdelete(tmp_app_path);
return ERR_CANT_CREATE;
}
}
@@ -1564,7 +1576,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
if (!f) {
ERR_PRINT("Can't write '" + file + "'.");
unzClose(src_pkg_zip);
- memdelete(tmp_app_path);
return ERR_CANT_CREATE;
};
f->store_buffer(data.ptr(), data.size());
@@ -1587,10 +1598,53 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
if (!found_library) {
ERR_PRINT("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
- memdelete(tmp_app_path);
return ERR_FILE_NOT_FOUND;
}
+ Dictionary appnames = ProjectSettings::get_singleton()->get("application/config/name_localized");
+ Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized");
+ Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized");
+ Dictionary photolibrary_usage_descriptions = p_preset->get("privacy/photolibrary_usage_description_localized");
+
+ Vector<String> translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations");
+ if (translations.size() > 0) {
+ {
+ String fname = dest_dir + binary_name + "/en.lproj";
+ tmp_app_path->make_dir_recursive(fname);
+ FileAccessRef f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
+ f->store_line("/* Localized versions of Info.plist keys */");
+ f->store_line("");
+ f->store_line("CFBundleDisplayName = \"" + ProjectSettings::get_singleton()->get("application/config/name").operator String() + "\";");
+ f->store_line("NSCameraUsageDescription = \"" + p_preset->get("privacy/camera_usage_description").operator String() + "\";");
+ f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";");
+ f->store_line("NSPhotoLibraryUsageDescription = \"" + p_preset->get("privacy/photolibrary_usage_description").operator String() + "\";");
+ }
+
+ for (const String &E : translations) {
+ Ref<Translation> tr = ResourceLoader::load(E);
+ if (tr.is_valid()) {
+ String lang = tr->get_locale();
+ String fname = dest_dir + binary_name + "/" + lang + ".lproj";
+ tmp_app_path->make_dir_recursive(fname);
+ FileAccessRef f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
+ f->store_line("/* Localized versions of Info.plist keys */");
+ f->store_line("");
+ if (appnames.has(lang)) {
+ f->store_line("CFBundleDisplayName = \"" + appnames[lang].operator String() + "\";");
+ }
+ if (camera_usage_descriptions.has(lang)) {
+ f->store_line("NSCameraUsageDescription = \"" + camera_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (microphone_usage_descriptions.has(lang)) {
+ f->store_line("NSMicrophoneUsageDescription = \"" + microphone_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (photolibrary_usage_descriptions.has(lang)) {
+ f->store_line("NSPhotoLibraryUsageDescription = \"" + photolibrary_usage_descriptions[lang].operator String() + "\";");
+ }
+ }
+ }
+ }
+
// Copy project static libs to the project
Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
for (int i = 0; i < export_plugins.size(); i++) {
@@ -1601,7 +1655,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path);
if (lib_copy_err != OK) {
ERR_PRINT("Can't copy '" + static_lib_path + "'.");
- memdelete(tmp_app_path);
return lib_copy_err;
}
}
@@ -1612,7 +1665,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
if (!tmp_app_path->dir_exists(iconset_dir)) {
err = tmp_app_path->make_dir_recursive(iconset_dir);
}
- memdelete(tmp_app_path);
if (err) {
return err;
}
@@ -1622,43 +1674,43 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
return err;
}
- bool use_storyboard = p_preset->get("storyboard/use_launch_screen_storyboard");
+ {
+ bool use_storyboard = p_preset->get("storyboard/use_launch_screen_storyboard");
- String launch_image_path = dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/";
- String splash_image_path = dest_dir + binary_name + "/Images.xcassets/SplashImage.imageset/";
+ String launch_image_path = dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/";
+ String splash_image_path = dest_dir + binary_name + "/Images.xcassets/SplashImage.imageset/";
- DirAccess *launch_screen_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef launch_screen_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (!launch_screen_da) {
- return ERR_CANT_CREATE;
- }
+ if (!launch_screen_da) {
+ return ERR_CANT_CREATE;
+ }
- if (use_storyboard) {
- print_line("Using Launch Storyboard");
+ if (use_storyboard) {
+ print_line("Using Launch Storyboard");
- if (launch_screen_da->change_dir(launch_image_path) == OK) {
- launch_screen_da->erase_contents_recursive();
- launch_screen_da->remove(launch_image_path);
- }
+ if (launch_screen_da->change_dir(launch_image_path) == OK) {
+ launch_screen_da->erase_contents_recursive();
+ launch_screen_da->remove(launch_image_path);
+ }
- err = _export_loading_screen_file(p_preset, splash_image_path);
- } else {
- print_line("Using Launch Images");
+ err = _export_loading_screen_file(p_preset, splash_image_path);
+ } else {
+ print_line("Using Launch Images");
- const String launch_screen_path = dest_dir + binary_name + "/Launch Screen.storyboard";
+ const String launch_screen_path = dest_dir + binary_name + "/Launch Screen.storyboard";
- launch_screen_da->remove(launch_screen_path);
+ launch_screen_da->remove(launch_screen_path);
- if (launch_screen_da->change_dir(splash_image_path) == OK) {
- launch_screen_da->erase_contents_recursive();
- launch_screen_da->remove(splash_image_path);
- }
+ if (launch_screen_da->change_dir(splash_image_path) == OK) {
+ launch_screen_da->erase_contents_recursive();
+ launch_screen_da->remove(splash_image_path);
+ }
- err = _export_loading_screen_images(p_preset, launch_image_path);
+ err = _export_loading_screen_images(p_preset, launch_image_path);
+ }
}
- memdelete(launch_screen_da);
-
if (err) {
return err;
}
@@ -1677,15 +1729,17 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
memdelete(f);
#ifdef OSX_ENABLED
- if (ep.step("Code-signing dylibs", 2)) {
- return ERR_SKIP;
+ {
+ if (ep.step("Code-signing dylibs", 2)) {
+ return ERR_SKIP;
+ }
+ DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs");
+ ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN);
+ CodesignData codesign_data(p_preset, p_debug);
+ err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data);
+ memdelete(dylibs_dir);
+ ERR_FAIL_COND_V(err, err);
}
- DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs");
- ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN);
- CodesignData codesign_data(p_preset, p_debug);
- err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data);
- memdelete(dylibs_dir);
- ERR_FAIL_COND_V(err, err);
if (ep.step("Making .xcarchive", 3)) {
return ERR_SKIP;
diff --git a/platform/iphone/export/export_plugin.h b/platform/iphone/export/export_plugin.h
index 93b23f7ee2..c01983e39f 100644
--- a/platform/iphone/export/export_plugin.h
+++ b/platform/iphone/export/export_plugin.h
@@ -41,7 +41,6 @@
#include "core/templates/safe_refcount.h"
#include "core/version.h"
#include "editor/editor_export.h"
-#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "main/splash.gen.h"
#include "platform/iphone/logo.gen.h"
diff --git a/platform/iphone/godot_iphone.mm b/platform/iphone/godot_iphone.mm
index a76276e815..49474ef554 100644
--- a/platform/iphone/godot_iphone.mm
+++ b/platform/iphone/godot_iphone.mm
@@ -53,7 +53,7 @@ int add_path(int p_argc, char **p_args) {
p_args[p_argc] = nullptr;
return p_argc;
-};
+}
int add_cmdline(int p_argc, char **p_args) {
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
@@ -67,12 +67,12 @@ int add_cmdline(int p_argc, char **p_args) {
continue;
}
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
- };
+ }
p_args[p_argc] = nullptr;
return p_argc;
-};
+}
int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
size_t len = strlen(argv[0]);
@@ -103,7 +103,7 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
char *fargv[64];
for (int i = 0; i < argc; i++) {
fargv[i] = argv[i];
- };
+ }
fargv[argc] = nullptr;
argc = add_path(argc, fargv);
argc = add_cmdline(argc, fargv);
@@ -119,10 +119,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
os->initialize_modules();
return 0;
-};
+}
void iphone_finish() {
printf("iphone_finish\n");
Main::cleanup();
delete os;
-};
+}
diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm
index ae92f32851..e48dd2e507 100644
--- a/platform/iphone/godot_view.mm
+++ b/platform/iphone/godot_view.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view.h"
+
#include "core/os/keyboard.h"
#include "core/string/ustring.h"
#import "display_layer.h"
@@ -153,6 +154,8 @@ static const float earth_gravity = 9.80665;
[self initTouches];
+ self.multipleTouchEnabled = YES;
+
// Configure and start accelerometer
if (!self.motionManager) {
self.motionManager = [[CMMotionManager alloc] init];
@@ -226,8 +229,9 @@ static const float earth_gravity = 9.80665;
[self.displayLink setPaused:YES];
// Process all input events
- while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource)
- ;
+ while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) {
+ // Continue.
+ }
// We are good to go, resume the CADisplayLink
[self.displayLink setPaused:NO];
diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/iphone/godot_view_gesture_recognizer.mm
index a46c42765a..c8137f35ff 100644
--- a/platform/iphone/godot_view_gesture_recognizer.mm
+++ b/platform/iphone/godot_view_gesture_recognizer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view_gesture_recognizer.h"
+
#import "godot_view.h"
#include "core/config/project_settings.h"
@@ -148,7 +149,7 @@ const CGFloat kGLGestureMovementDistance = 0.5;
return;
}
- [self.godotView touchesMoved:cleared withEvent:event];
+ [self.godotView godotTouchesMoved:cleared withEvent:event];
[super touchesMoved:touches withEvent:event];
}
diff --git a/platform/iphone/godot_view_renderer.mm b/platform/iphone/godot_view_renderer.mm
index e49edf5b74..32477ae41c 100644
--- a/platform/iphone/godot_view_renderer.mm
+++ b/platform/iphone/godot_view_renderer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view_renderer.h"
+
#include "core/config/project_settings.h"
#include "core/os/keyboard.h"
#import "display_server_iphone.h"
@@ -101,7 +102,7 @@
double dval = [n doubleValue];
ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval);
- };
+ }
// do stuff
}
}
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index da21ad0ace..ad1ea70c10 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "ios.h"
+
#import "app_delegate.h"
#import "view_controller.h"
#import <UIKit/UIKit.h>
@@ -36,7 +37,7 @@
void iOS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
-};
+}
void iOS::alert(const char *p_alert, const char *p_title) {
NSString *title = [NSString stringWithUTF8String:p_title];
@@ -75,6 +76,6 @@ String iOS::get_rate_url(int p_app_id) const {
printf("returning rate url %s\n", ret.utf8().get_data());
return ret;
-};
+}
iOS::iOS() {}
diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm
index f45f4da5a8..9c2feeaaca 100644
--- a/platform/iphone/joypad_iphone.mm
+++ b/platform/iphone/joypad_iphone.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "joypad_iphone.h"
+
#include "core/config/project_settings.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "main/main.h"
@@ -139,10 +140,10 @@ void JoypadIPhone::start_processing() {
for (NSNumber *key in keys) {
int joy_id = [key intValue];
return joy_id;
- };
+ }
return -1;
-};
+}
- (void)addiOSJoypad:(GCController *)controller {
// get a new id for our controller
@@ -156,7 +157,7 @@ void JoypadIPhone::start_processing() {
// assign our player index
if (controller.playerIndex == GCControllerPlayerIndexUnset) {
controller.playerIndex = [self getFreePlayerIndex];
- };
+ }
// tell Godot about our new controller
Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String]));
@@ -202,8 +203,8 @@ void JoypadIPhone::start_processing() {
// and remove it from our dictionary
[self.connectedJoypads removeObjectForKey:key];
- };
-};
+ }
+}
- (GCControllerPlayerIndex)getFreePlayerIndex {
bool have_player_1 = false;
@@ -223,9 +224,9 @@ void JoypadIPhone::start_processing() {
have_player_3 = true;
} else if (controller.playerIndex == GCControllerPlayerIndex4) {
have_player_4 = true;
- };
- };
- };
+ }
+ }
+ }
if (!have_player_1) {
return GCControllerPlayerIndex1;
@@ -237,7 +238,7 @@ void JoypadIPhone::start_processing() {
return GCControllerPlayerIndex4;
} else {
return GCControllerPlayerIndexUnset;
- };
+ }
}
- (void)setControllerInputHandler:(GCController *)controller {
@@ -285,7 +286,7 @@ void JoypadIPhone::start_processing() {
gamepad.dpad.left.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT,
gamepad.dpad.right.isPressed);
- };
+ }
if (element == gamepad.leftThumbstick) {
float value = gamepad.leftThumbstick.xAxis.value;
@@ -303,7 +304,7 @@ void JoypadIPhone::start_processing() {
} else if (element == gamepad.rightTrigger) {
float value = gamepad.rightTrigger.value;
Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, value);
- };
+ }
};
} else if (controller.microGamepad != nil) {
// micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad
@@ -329,7 +330,7 @@ void JoypadIPhone::start_processing() {
gamepad.dpad.down.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed);
- };
+ }
};
}
@@ -338,6 +339,6 @@ void JoypadIPhone::start_processing() {
///@TODO need to add support for controllerPausedHandler which should be a
/// toggle
-};
+}
@end
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index aca6f5fe2b..3281ff0cdb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -109,6 +109,7 @@ public:
virtual String get_locale() const override;
virtual String get_unique_id() const override;
+ virtual String get_processor_name() const override;
virtual void vibrate_handheld(int p_duration_ms = 500) override;
diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm
index 8350365d88..1d990b5625 100644
--- a/platform/iphone/os_iphone.mm
+++ b/platform/iphone/os_iphone.mm
@@ -31,6 +31,7 @@
#ifdef IPHONE_ENABLED
#include "os_iphone.h"
+
#import "app_delegate.h"
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
@@ -45,6 +46,7 @@
#import <AudioToolbox/AudioServices.h>
#import <UIKit/UIKit.h>
#import <dlfcn.h>
+#include <sys/sysctl.h>
#if defined(VULKAN_ENABLED)
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
@@ -168,7 +170,7 @@ void OSIPhone::delete_main_loop() {
if (main_loop) {
main_loop->finalize();
memdelete(main_loop);
- };
+ }
main_loop = nullptr;
}
@@ -197,7 +199,7 @@ void OSIPhone::finalize() {
deinitialize_modules();
// Already gets called
- // delete_main_loop();
+ //delete_main_loop();
}
// MARK: Dynamic Libraries
@@ -230,12 +232,13 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const
String OSIPhone::get_name() const {
return "iOS";
-};
+}
String OSIPhone::get_model_name() const {
String model = ios->get_model();
- if (model != "")
+ if (model != "") {
return model;
+ }
return OS_Unix::get_model_name();
}
@@ -253,14 +256,12 @@ Error OSIPhone::shell_open(String p_uri) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
return OK;
-};
+}
void OSIPhone::set_user_data_dir(String p_dir) {
- DirAccess *da = DirAccess::open(p_dir);
-
+ DirAccessRef da = DirAccess::open(p_dir);
user_data_dir = da->get_current_dir();
printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), p_dir.utf8().get_data());
- memdelete(da);
}
String OSIPhone::get_user_data_dir() const {
@@ -287,6 +288,15 @@ String OSIPhone::get_unique_id() const {
return String::utf8([uuid UTF8String]);
}
+String OSIPhone::get_processor_name() const {
+ char buffer[256];
+ size_t buffer_len = 256;
+ if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) {
+ return String::utf8(buffer, buffer_len);
+ }
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+}
+
void OSIPhone::vibrate_handheld(int p_duration_ms) {
// iOS does not support duration for vibration
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index e1fc645c13..4f4ef4f046 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -203,7 +203,7 @@
case DisplayServer::SCREEN_LANDSCAPE:
return UIInterfaceOrientationMaskLandscapeLeft;
}
-};
+}
- (BOOL)prefersStatusBarHidden {
return YES;
diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp
index 4190b24b8e..46a0a816bf 100644
--- a/platform/javascript/api/api.cpp
+++ b/platform/javascript/api/api.cpp
@@ -37,8 +37,8 @@ static JavaScript *javascript_eval;
void register_javascript_api() {
JavaScriptToolsEditorPlugin::initialize();
- GDREGISTER_VIRTUAL_CLASS(JavaScriptObject);
- GDREGISTER_VIRTUAL_CLASS(JavaScript);
+ GDREGISTER_ABSTRACT_CLASS(JavaScriptObject);
+ GDREGISTER_ABSTRACT_CLASS(JavaScript);
javascript_eval = memnew(JavaScript);
Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval));
}
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp
index c68ac655a8..0442a1eaeb 100644
--- a/platform/javascript/api/javascript_tools_editor_plugin.cpp
+++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp
@@ -46,14 +46,14 @@ extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, co
}
static void _javascript_editor_init_callback() {
- EditorNode::get_singleton()->add_editor_plugin(memnew(JavaScriptToolsEditorPlugin(EditorNode::get_singleton())));
+ EditorNode::get_singleton()->add_editor_plugin(memnew(JavaScriptToolsEditorPlugin));
}
void JavaScriptToolsEditorPlugin::initialize() {
EditorNode::add_init_callback(_javascript_editor_init_callback);
}
-JavaScriptToolsEditorPlugin::JavaScriptToolsEditorPlugin(EditorNode *p_editor) {
+JavaScriptToolsEditorPlugin::JavaScriptToolsEditorPlugin() {
add_tool_menu_item("Download Project Source", callable_mp(this, &JavaScriptToolsEditorPlugin::_download_zip));
}
@@ -124,7 +124,7 @@ void JavaScriptToolsEditorPlugin::_zip_file(String p_path, String p_base_path, z
}
void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zipFile p_zip) {
- DirAccess *dir = DirAccess::open(p_path);
+ DirAccessRef dir = DirAccess::open(p_path);
if (!dir) {
WARN_PRINT("Unable to open directory for zipping: " + p_path);
return;
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.h b/platform/javascript/api/javascript_tools_editor_plugin.h
index 08f10b01dc..cbf5f49497 100644
--- a/platform/javascript/api/javascript_tools_editor_plugin.h
+++ b/platform/javascript/api/javascript_tools_editor_plugin.h
@@ -46,7 +46,7 @@ private:
public:
static void initialize();
- JavaScriptToolsEditorPlugin(EditorNode *p_editor);
+ JavaScriptToolsEditorPlugin();
};
#else
class JavaScriptToolsEditorPlugin {
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index a0e1246c55..2caf369354 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "platform/javascript/display_server_javascript.h"
+#include "display_server_javascript.h"
#ifdef GLES3_ENABLED
#include "drivers/gles3/rasterizer_gles3.h"
@@ -325,12 +325,13 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso
image = image->duplicate();
- if (atlas_texture.is_valid())
+ if (atlas_texture.is_valid()) {
image->crop_from_point(
atlas_rect.position.x,
atlas_rect.position.y,
texture_size.width,
texture_size.height);
+ }
if (image->get_format() != Image::FORMAT_RGBA8) {
image->convert(Image::FORMAT_RGBA8);
@@ -618,8 +619,9 @@ void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) {
ERR_FAIL_COND(icon->decompress() != OK);
}
if (icon->get_format() != Image::FORMAT_RGBA8) {
- if (icon == p_icon)
+ if (icon == p_icon) {
icon = icon->duplicate();
+ }
icon->convert(Image::FORMAT_RGBA8);
}
@@ -891,8 +893,9 @@ Size2i DisplayServerJavaScript::window_get_real_size(WindowID p_window) const {
}
void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_window) {
- if (window_mode == p_mode)
+ if (window_mode == p_mode) {
return;
+ }
switch (p_mode) {
case WINDOW_MODE_WINDOWED: {
diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp
index d4c198d631..e7855acf60 100644
--- a/platform/javascript/export/export_plugin.cpp
+++ b/platform/javascript/export/export_plugin.cpp
@@ -30,6 +30,8 @@
#include "export_plugin.h"
+#include "core/config/project_settings.h"
+
Error EditorExportPlatformJavaScript::_extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa) {
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
@@ -250,7 +252,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
// Custom offline page
const String offline_page = p_preset->get("progressive_web_app/offline_page");
if (!offline_page.is_empty()) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
const String offline_dest = dir.plus_file(name + ".offline.html");
err = da->copy(ProjectSettings::get_singleton()->globalize_path(offline_page), offline_dest);
if (err != OK) {
@@ -443,18 +445,18 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + pck_path);
return error;
}
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- for (int i = 0; i < shared_objects.size(); i++) {
- String dst = base_dir.plus_file(shared_objects[i].path.get_file());
- error = da->copy(shared_objects[i].path, dst);
- if (error != OK) {
- EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file());
- memdelete(da);
- return error;
+
+ {
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < shared_objects.size(); i++) {
+ String dst = base_dir.plus_file(shared_objects[i].path.get_file());
+ error = da->copy(shared_objects[i].path, dst);
+ if (error != OK) {
+ EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file());
+ return error;
+ }
}
}
- memdelete(da);
- da = nullptr;
// Extract templates.
error = _extract_template(template_path, base_dir, base_name, pwa);
@@ -642,7 +644,7 @@ Ref<Texture2D> EditorExportPlatformJavaScript::get_run_icon() const {
void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
EditorExportPlatformJavaScript *ej = (EditorExportPlatformJavaScript *)data;
while (!ej->server_quit) {
- OS::get_singleton()->delay_usec(1000);
+ OS::get_singleton()->delay_usec(6900);
{
MutexLock lock(ej->server_lock);
ej->server->poll();
diff --git a/platform/javascript/export/export_plugin.h b/platform/javascript/export/export_plugin.h
index 278e317430..d17fd2f674 100644
--- a/platform/javascript/export/export_plugin.h
+++ b/platform/javascript/export/export_plugin.h
@@ -31,6 +31,7 @@
#ifndef JAVASCRIPT_EXPORT_PLUGIN_H
#define JAVASCRIPT_EXPORT_PLUGIN_H
+#include "core/config/project_settings.h"
#include "core/io/image_loader.h"
#include "core/io/stream_peer_ssl.h"
#include "core/io/tcp_server.h"
diff --git a/platform/javascript/export/export_server.h b/platform/javascript/export/export_server.h
index 1380f34ad7..1b908ad9b0 100644
--- a/platform/javascript/export/export_server.h
+++ b/platform/javascript/export/export_server.h
@@ -36,7 +36,7 @@
#include "core/io/tcp_server.h"
#include "core/io/zip_io.h"
#include "editor/editor_export.h"
-#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
class EditorHTTPServer : public RefCounted {
private:
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 5c00476a72..307a80feea 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "core/config/engine.h"
#include "core/io/resource_loader.h"
#include "main/main.h"
#include "platform/javascript/display_server_javascript.h"
@@ -94,7 +95,7 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) {
Main::start();
os->get_main_loop()->initialize();
#ifdef TOOLS_ENABLED
- if (Main::is_project_manager() && FileAccess::exists("/tmp/preload.zip")) {
+ if (Engine::get_singleton()->is_project_manager_hint() && FileAccess::exists("/tmp/preload.zip")) {
PackedStringArray ps;
ps.push_back("/tmp/preload.zip");
os->get_main_loop()->emit_signal(SNAME("files_dropped"), ps, -1);
diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp
index 77858bff01..c9c4d6e1b9 100644
--- a/platform/javascript/javascript_singleton.cpp
+++ b/platform/javascript/javascript_singleton.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "api/javascript_singleton.h"
+
#include "emscripten.h"
#include "os_javascript.h"
@@ -80,7 +81,7 @@ protected:
public:
Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const override;
void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = nullptr) override;
- Variant call(const StringName &p_method, const Variant **p_args, int p_argc, Callable::CallError &r_error) override;
+ Variant callp(const StringName &p_method, const Variant **p_args, int p_argc, Callable::CallError &r_error) override;
JavaScriptObjectImpl() {}
JavaScriptObjectImpl(int p_id) { _js_id = p_id; }
~JavaScriptObjectImpl() {
@@ -230,7 +231,7 @@ int JavaScriptObjectImpl::_variant2js(const void **p_args, int p_pos, godot_js_w
return type;
}
-Variant JavaScriptObjectImpl::call(const StringName &p_method, const Variant **p_args, int p_argc, Callable::CallError &r_error) {
+Variant JavaScriptObjectImpl::callp(const StringName &p_method, const Variant **p_args, int p_argc, Callable::CallError &r_error) {
godot_js_wrapper_ex exchange;
const String method = p_method;
void *lock = nullptr;
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index de5ca44f9d..da88ea18b0 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -175,7 +175,7 @@ String OS_JavaScript::get_name() const {
String OS_JavaScript::get_user_data_dir() const {
return "/userfs";
-};
+}
String OS_JavaScript::get_cache_path() const {
return "/home/web_user/.cache";
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index ab643b254a..03c85d09ad 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -261,27 +261,6 @@ def configure(env):
if not env["builtin_libpng"]:
env.ParseConfig("pkg-config libpng16 --cflags --libs")
- if not env["builtin_bullet"]:
- # We need at least version 2.90
- min_bullet_version = "2.90"
-
- import subprocess
-
- bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip()
- if str(bullet_version) < min_bullet_version:
- # Abort as system bullet was requested but too old
- print(
- "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(
- bullet_version, min_bullet_version
- )
- )
- sys.exit(255)
- env.ParseConfig("pkg-config bullet --cflags --libs")
-
- if False: # not env['builtin_assimp']:
- # FIXME: Add min version check
- env.ParseConfig("pkg-config assimp --cflags --libs")
-
if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs")
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index bf9c9b1766..07cb6a23e8 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -109,6 +109,15 @@ struct Hints {
unsigned long status = 0;
};
+static String get_atom_name(Display *p_disp, Atom p_atom) {
+ char *name = XGetAtomName(p_disp, p_atom);
+ ERR_FAIL_NULL_V_MSG(name, String(), "Atom is invalid.");
+ String ret;
+ ret.parse_utf8(name);
+ XFree(name);
+ return ret;
+}
+
bool DisplayServerX11::has_feature(Feature p_feature) const {
switch (p_feature) {
case FEATURE_SUBWINDOWS:
@@ -435,7 +444,7 @@ String DisplayServerX11::_clipboard_get_impl(Atom p_source, Window x11_window, A
Window selection_owner = XGetSelectionOwner(x11_display, p_source);
if (selection_owner == x11_window) {
static const char *target_type = "PRIMARY";
- if (p_source != None && String(XGetAtomName(x11_display, p_source)) == target_type) {
+ if (p_source != None && get_atom_name(x11_display, p_source) == target_type) {
return internal_clipboard_primary;
} else {
return internal_clipboard;
@@ -1077,7 +1086,7 @@ float DisplayServerX11::screen_get_refresh_rate(int p_screen) const {
monitors = xrr_get_monitors(x11_display, windows[MAIN_WINDOW_ID].x11_window, true, &count);
ERR_FAIL_INDEX_V(p_screen, count, SCREEN_REFRESH_RATE_FALLBACK);
} else {
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return SCREEN_REFRESH_RATE_FALLBACK;
}
@@ -1105,14 +1114,14 @@ float DisplayServerX11::screen_get_refresh_rate(int p_screen) const {
}
}
- ERR_PRINT("An error occured while trying to get the screen refresh rate."); // We should have returned the refresh rate by now. An error must have occured.
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate."); // We should have returned the refresh rate by now. An error must have occurred.
return SCREEN_REFRESH_RATE_FALLBACK;
} else {
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return SCREEN_REFRESH_RATE_FALLBACK;
}
}
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return SCREEN_REFRESH_RATE_FALLBACK;
}
@@ -1173,6 +1182,7 @@ void DisplayServerX11::show_window(WindowID p_id) {
_THREAD_SAFE_METHOD_
const WindowData &wd = windows[p_id];
+ popup_open(p_id);
DEBUG_LOG_X11("show_window: %lu (%u) \n", wd.x11_window, p_id);
@@ -1183,7 +1193,9 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_id));
- ERR_FAIL_COND_MSG(p_id == MAIN_WINDOW_ID, "Main window can't be deleted"); //ma
+ ERR_FAIL_COND_MSG(p_id == MAIN_WINDOW_ID, "Main window can't be deleted");
+
+ popup_close(p_id);
WindowData &wd = windows[p_id];
@@ -1458,8 +1470,8 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent
// Set focus to parent sub window to avoid losing all focus when closing a nested sub-menu.
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
- if (wd_window.menu_type && !wd_window.no_focus && wd_window.focused) {
- if (!wd_parent.no_focus) {
+ if (!wd_window.no_focus && !wd_window.is_popup && wd_window.focused) {
+ if (!wd_parent.no_focus && !wd_window.is_popup) {
XSetInputFocus(x11_display, wd_parent.x11_window, RevertToPointerRoot, CurrentTime);
}
}
@@ -2073,6 +2085,18 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
case WINDOW_FLAG_TRANSPARENT: {
//todo reimplement
} break;
+ case WINDOW_FLAG_NO_FOCUS: {
+ wd.no_focus = p_enabled;
+ } break;
+ case WINDOW_FLAG_POPUP: {
+ XWindowAttributes xwa;
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
+
+ ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
+ ERR_FAIL_COND_MSG((xwa.map_state == IsViewable) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
+ wd.is_popup = p_enabled;
+ } break;
default: {
}
}
@@ -2114,6 +2138,12 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co
case WINDOW_FLAG_TRANSPARENT: {
//todo reimplement
} break;
+ case WINDOW_FLAG_NO_FOCUS: {
+ return wd.no_focus;
+ } break;
+ case WINDOW_FLAG_POPUP: {
+ return wd.is_popup;
+ } break;
default: {
}
}
@@ -2427,8 +2457,7 @@ String DisplayServerX11::keyboard_get_layout_language(int p_index) const {
Atom names = kbd->names->symbols;
if (names != None) {
- char *name = XGetAtomName(x11_display, names);
- Vector<String> info = String(name).split("+");
+ Vector<String> info = get_atom_name(x11_display, names).split("+");
if (p_index >= 0 && p_index < _group_count) {
if (p_index + 1 < info.size()) {
ret = info[p_index + 1]; // Skip "pc" at the start and "inet"/"group" at the end of symbols.
@@ -2438,7 +2467,6 @@ String DisplayServerX11::keyboard_get_layout_language(int p_index) const {
} else {
ERR_PRINT("Index " + itos(p_index) + "is out of bounds (" + itos(_group_count) + ").");
}
- XFree(name);
}
XkbFreeKeyboard(kbd, 0, true);
}
@@ -2465,9 +2493,7 @@ String DisplayServerX11::keyboard_get_layout_name(int p_index) const {
}
if (p_index >= 0 && p_index < _group_count) {
- char *full_name = XGetAtomName(x11_display, groups[p_index]);
- ret.parse_utf8(full_name);
- XFree(full_name);
+ ret = get_atom_name(x11_display, groups[p_index]);
} else {
ERR_PRINT("Index " + itos(p_index) + "is out of bounds (" + itos(_group_count) + ").");
}
@@ -2530,7 +2556,7 @@ static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count)
for (int i = 0; i < p_count; i++) {
Atom atom = p_list[i];
- if (atom != None && String(XGetAtomName(p_display, atom)) == target_type) {
+ if (atom != None && get_atom_name(p_display, atom) == target_type) {
return atom;
}
}
@@ -2539,15 +2565,15 @@ static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count)
static Atom pick_target_from_atoms(Display *p_disp, Atom p_t1, Atom p_t2, Atom p_t3) {
static const char *target_type = "text/uri-list";
- if (p_t1 != None && String(XGetAtomName(p_disp, p_t1)) == target_type) {
+ if (p_t1 != None && get_atom_name(p_disp, p_t1) == target_type) {
return p_t1;
}
- if (p_t2 != None && String(XGetAtomName(p_disp, p_t2)) == target_type) {
+ if (p_t2 != None && get_atom_name(p_disp, p_t2) == target_type) {
return p_t2;
}
- if (p_t3 != None && String(XGetAtomName(p_disp, p_t3)) == target_type) {
+ if (p_t3 != None && get_atom_name(p_disp, p_t3) == target_type) {
return p_t3;
}
@@ -2869,7 +2895,7 @@ Atom DisplayServerX11::_process_selection_request_target(Atom p_target, Window p
// is the owner during a selection request.
CharString clip;
static const char *target_type = "PRIMARY";
- if (p_selection != None && String(XGetAtomName(x11_display, p_selection)) == target_type) {
+ if (p_selection != None && get_atom_name(x11_display, p_selection) == target_type) {
clip = internal_clipboard_primary.utf8();
} else {
clip = internal_clipboard.utf8();
@@ -3028,23 +3054,36 @@ void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
Variant ret;
Callable::CallError ce;
+ {
+ List<WindowID>::Element *E = popup_list.front();
+ if (E && Object::cast_to<InputEventKey>(*p_event)) {
+ // Redirect keyboard input to active popup.
+ if (windows.has(E->get())) {
+ Callable callable = windows[E->get()].input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ }
+ return;
+ }
+ }
+
Ref<InputEventFromWindow> event_from_window = p_event;
if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
- //send to a window
- ERR_FAIL_COND(!windows.has(event_from_window->get_window_id()));
- Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
- if (callable.is_null()) {
- return;
+ // Send to a single window.
+ if (windows.has(event_from_window->get_window_id())) {
+ Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
}
- callable.call((const Variant **)&evp, 1, ret, ce);
} else {
- //send to all windows
+ // Send to all windows.
for (KeyValue<WindowID, WindowData> &E : windows) {
Callable callable = E.value.input_event_callback;
- if (callable.is_null()) {
- continue;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
}
- callable.call((const Variant **)&evp, 1, ret, ce);
}
}
}
@@ -3136,6 +3175,108 @@ void DisplayServerX11::_check_pending_events(LocalVector<XEvent> &r_events) {
}
}
+DisplayServer::WindowID DisplayServerX11::window_get_active_popup() const {
+ const List<WindowID>::Element *E = popup_list.back();
+ if (E) {
+ return E->get();
+ } else {
+ return INVALID_WINDOW_ID;
+ }
+}
+
+void DisplayServerX11::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.parent_safe_rect = p_rect;
+}
+
+Rect2i DisplayServerX11::window_get_popup_safe_rect(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Rect2i());
+ const WindowData &wd = windows[p_window];
+ return wd.parent_safe_rect;
+}
+
+void DisplayServerX11::popup_open(WindowID p_window) {
+ WindowData &wd = windows[p_window];
+ if (wd.is_popup) {
+ // Close all popups, up to current popup parent, or every popup if new window is not transient.
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ if (wd.transient_parent != E->get() || wd.transient_parent == INVALID_WINDOW_ID) {
+ _send_window_event(windows[E->get()], DisplayServerX11::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ } else {
+ break;
+ }
+ }
+
+ time_since_popup = OS::get_singleton()->get_ticks_msec();
+ popup_list.push_back(p_window);
+ }
+}
+
+void DisplayServerX11::popup_close(WindowID p_window) {
+ List<WindowID>::Element *E = popup_list.find(p_window);
+ while (E) {
+ _send_window_event(windows[E->get()], DisplayServerX11::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->next();
+ popup_list.erase(E);
+ E = F;
+ }
+}
+
+void DisplayServerX11::mouse_process_popups() {
+ if (popup_list.is_empty()) {
+ return;
+ }
+
+ uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_popup;
+ if (delta < 250) {
+ return;
+ }
+
+ int number_of_screens = XScreenCount(x11_display);
+ for (int i = 0; i < number_of_screens; i++) {
+ Window root, child;
+ int root_x, root_y, win_x, win_y;
+ unsigned int mask;
+ if (XQueryPointer(x11_display, XRootWindow(x11_display, i), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask)) {
+ XWindowAttributes root_attrs;
+ XGetWindowAttributes(x11_display, root, &root_attrs);
+ Vector2i pos = Vector2i(root_attrs.x + root_x, root_attrs.y + root_y);
+ if ((pos != last_mouse_monitor_pos) || (mask != last_mouse_monitor_mask)) {
+ if (((mask & Button1Mask) || (mask & Button2Mask) || (mask & Button3Mask) || (mask & Button4Mask) || (mask & Button5Mask))) {
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ // Popup window area.
+ Rect2i win_rect = Rect2i(window_get_position(E->get()), window_get_size(E->get()));
+ // Area of the parent window, which responsible for opening sub-menu.
+ Rect2i safe_rect = window_get_popup_safe_rect(E->get());
+ if (win_rect.has_point(pos)) {
+ break;
+ } else if (safe_rect != Rect2i() && safe_rect.has_point(pos)) {
+ break;
+ } else {
+ _send_window_event(windows[E->get()], DisplayServerX11::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ }
+ }
+ }
+ }
+ last_mouse_monitor_mask = mask;
+ last_mouse_monitor_pos = pos;
+ }
+ }
+}
+
void DisplayServerX11::process_events() {
_THREAD_SAFE_METHOD_
@@ -3144,6 +3285,8 @@ void DisplayServerX11::process_events() {
++frame;
#endif
+ mouse_process_popups();
+
if (app_focused) {
//verify that one of the windows has focus, else send focus out notification
bool focus_found = false;
@@ -3374,7 +3517,7 @@ void DisplayServerX11::process_events() {
// Set focus when menu window is started.
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
- if (wd.menu_type && !wd.no_focus) {
+ if (!wd.no_focus && !wd.is_popup) {
XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
}
} break;
@@ -3517,10 +3660,14 @@ void DisplayServerX11::process_events() {
const WindowData &wd = windows[window_id];
+ XWindowAttributes xwa;
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
+
// Set focus when menu window is re-used.
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
- if (wd.menu_type && !wd.no_focus) {
+ if ((xwa.map_state == IsViewable) && !wd.no_focus && !wd.is_popup) {
XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
}
@@ -3561,7 +3708,7 @@ void DisplayServerX11::process_events() {
// Ensure window focus on click.
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
- if (!wd.no_focus) {
+ if (!wd.no_focus && !wd.is_popup) {
XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
}
@@ -3776,6 +3923,7 @@ void DisplayServerX11::process_events() {
Property p = _read_property(x11_display, windows[window_id].x11_window, XInternAtom(x11_display, "PRIMARY", 0));
Vector<String> files = String((char *)p.data).split("\n", false);
+ XFree(p.data);
for (int i = 0; i < files.size(); i++) {
files.write[i] = files[i].replace("file://", "").uri_decode().strip_edges();
}
@@ -3818,6 +3966,7 @@ void DisplayServerX11::process_events() {
if (more_than_3) {
Property p = _read_property(x11_display, source, XInternAtom(x11_display, "XdndTypeList", False));
requested = pick_target_from_list(x11_display, (Atom *)p.data, p.nitems);
+ XFree(p.data);
} else {
requested = pick_target_from_atoms(x11_display, event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
}
@@ -4121,21 +4270,20 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
WindowID id = window_id_counter++;
WindowData &wd = windows[id];
- if ((id != MAIN_WINDOW_ID) && (p_flags & WINDOW_FLAG_BORDERLESS_BIT)) {
- wd.menu_type = true;
- }
-
if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) {
- wd.menu_type = true;
wd.no_focus = true;
}
+ if (p_flags & WINDOW_FLAG_POPUP_BIT) {
+ wd.is_popup = true;
+ }
+
// Setup for menu subwindows:
// - override_redirect forces the WM not to interfere with the window, to avoid delays due to
// handling decorations and placement.
// On the other hand, focus changes need to be handled manually when this is set.
// - save_under is a hint for the WM to keep the content of windows behind to avoid repaint.
- if (wd.menu_type) {
+ if (wd.is_popup || wd.no_focus) {
windowAttributes.override_redirect = True;
windowAttributes.save_under = True;
valuemask |= CWOverrideRedirect | CWSaveUnder;
@@ -4146,7 +4294,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
// Enable receiving notification when the window is initialized (MapNotify)
// so the focus can be set at the right time.
- if (wd.menu_type && !wd.no_focus) {
+ if (!wd.no_focus && !wd.is_popup) {
XSelectInput(x11_display, wd.x11_window, StructureNotifyMask);
}
@@ -4243,7 +4391,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
}
}
- if (wd.menu_type) {
+ if (wd.is_popup || wd.no_focus) {
// Set Utility type to disable fade animations.
Atom type_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
Atom wt_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE", False);
@@ -4794,7 +4942,7 @@ DisplayServerX11::~DisplayServerX11() {
if (img[i] != nullptr) {
XcursorImageDestroy(img[i]);
}
- };
+ }
if (xim) {
XCloseIM(xim);
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 2d07361deb..63d32d939d 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -133,7 +133,6 @@ class DisplayServerX11 : public DisplayServer {
ObjectID instance_id;
- bool menu_type = false;
bool no_focus = false;
//better to guess on the fly, given WM can change it
@@ -145,12 +144,21 @@ class DisplayServerX11 : public DisplayServer {
Vector2i last_position_before_fs;
bool focused = true;
bool minimized = false;
+ bool is_popup = false;
+
+ Rect2i parent_safe_rect;
unsigned int focus_order = 0;
};
Map<WindowID, WindowData> windows;
+ unsigned int last_mouse_monitor_mask = 0;
+ Vector2i last_mouse_monitor_pos;
+ uint64_t time_since_popup = 0;
+
+ List<WindowID> popup_list;
+
WindowID last_focused_window = INVALID_WINDOW_ID;
WindowID window_id_counter = MAIN_WINDOW_ID;
@@ -283,6 +291,10 @@ protected:
void _window_changed(XEvent *event);
public:
+ void mouse_process_popups();
+ void popup_open(WindowID p_window);
+ void popup_close(WindowID p_window);
+
virtual bool has_feature(Feature p_feature) const override;
virtual String get_name() const override;
@@ -317,6 +329,10 @@ public:
virtual void show_window(WindowID p_id) override;
virtual void delete_sub_window(WindowID p_id) override;
+ virtual WindowID window_get_active_popup() const override;
+ virtual void window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) override;
+ virtual Rect2i window_get_popup_safe_rect(WindowID p_window) const override;
+
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index 8e963238e3..65d53b266f 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -238,7 +238,7 @@ void JoypadLinux::close_joypad(int p_id) {
if (p_id == -1) {
for (int i = 0; i < JOYPADS_MAX; i++) {
close_joypad(i);
- };
+ }
return;
} else if (p_id < 0) {
return;
@@ -251,7 +251,7 @@ void JoypadLinux::close_joypad(int p_id) {
joy.fd = -1;
attached_devices.remove_at(attached_devices.find(joy.devpath));
input->joy_connection_changed(p_id, false, "");
- };
+ }
}
static String _hex_str(uint8_t p_byte) {
@@ -516,7 +516,7 @@ void JoypadLinux::process_joypads() {
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
close_joypad(i);
- };
+ }
if (joy->force_feedback) {
uint64_t timestamp = input->get_joy_vibration_timestamp(i);
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index e95a865636..86874687ad 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -32,6 +32,7 @@
#include "core/io/dir_access.h"
#include "main/main.h"
+#include "servers/display_server.h"
#ifdef X11_ENABLED
#include "display_server_x11.h"
@@ -141,6 +142,20 @@ String OS_LinuxBSD::get_unique_id() const {
return machine_id;
}
+String OS_LinuxBSD::get_processor_name() const {
+ FileAccessRef f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(!f, "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));
+
+ while (!f->eof_reached()) {
+ const String line = f->get_line();
+ if (line.find("model name") != -1) {
+ return line.split(":")[1].strip_edges();
+ }
+ }
+
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
+}
+
void OS_LinuxBSD::finalize() {
if (main_loop) {
memdelete(main_loop);
@@ -342,7 +357,7 @@ void OS_LinuxBSD::run() {
if (Main::iteration()) {
break;
}
- };
+ }
main_loop->finalize();
}
@@ -384,9 +399,11 @@ static String get_mountpoint(const String &p_path) {
}
Error OS_LinuxBSD::move_to_trash(const String &p_path) {
+ String path = p_path.rstrip("/"); // Strip trailing slash when path points to a directory
+
int err_code;
List<String> args;
- args.push_back(p_path);
+ args.push_back(path);
args.push_front("trash"); // The command is `gio trash <file_name>` so we need to add it to args.
Error result = execute("gio", args, nullptr, &err_code); // For GNOME based machines.
if (result == OK && !err_code) {
@@ -416,14 +433,14 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
// If the commands `kioclient5`, `gio` or `gvfs-trash` don't exist on the system we do it manually.
String trash_path = "";
- String mnt = get_mountpoint(p_path);
+ String mnt = get_mountpoint(path);
// If there is a directory "[Mountpoint]/.Trash-[UID], use it as the trash can.
if (!mnt.is_empty()) {
- String path(mnt + "/.Trash-" + itos(getuid()));
+ String mountpoint_trash_path(mnt + "/.Trash-" + itos(getuid()));
struct stat s;
- if (!stat(path.utf8().get_data(), &s)) {
- trash_path = path;
+ if (!stat(mountpoint_trash_path.utf8().get_data(), &s)) {
+ trash_path = mountpoint_trash_path;
}
}
@@ -454,18 +471,15 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
// Issue an error if trash can is not created properly.
ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"");
err = dir_access->make_dir_recursive(trash_path + "/files");
- ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/files");
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "/files\"");
err = dir_access->make_dir_recursive(trash_path + "/info");
- ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/info");
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "/info\"");
}
// The trash can is successfully created, now we check that we don't exceed our file name length limit.
// If the file name is too long trim it so we can add the identifying number and ".trashinfo".
// Assumes that the file name length limit is 255 characters.
- String file_name = p_path.get_file();
- if (file_name.length() == 0) {
- file_name = p_path.get_base_dir().get_file();
- }
+ String file_name = path.get_file();
if (file_name.length() > 240) {
file_name = file_name.substr(0, file_name.length() - 15);
}
@@ -488,29 +502,31 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
}
file_name = fn;
+ String renamed_path = path.get_base_dir() + "/" + file_name;
+
// Generates the .trashinfo file
OS::Date date = OS::get_singleton()->get_date(false);
OS::Time time = OS::get_singleton()->get_time(false);
String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", date.year, (int)date.month, date.day, time.hour, time.minute);
timestamp = vformat("%s%02d", timestamp, time.second); // vformat only supports up to 6 arguments.
- String trash_info = "[Trash Info]\nPath=" + p_path.uri_encode() + "\nDeletionDate=" + timestamp + "\n";
+ String trash_info = "[Trash Info]\nPath=" + path.uri_encode() + "\nDeletionDate=" + timestamp + "\n";
{
Error err;
FileAccessRef file = FileAccess::open(trash_path + "/info/" + file_name + ".trashinfo", FileAccess::WRITE, &err);
- ERR_FAIL_COND_V_MSG(err != OK, err, "Can't create trashinfo file:" + trash_path + "/info/" + file_name + ".trashinfo");
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Can't create trashinfo file: \"" + trash_path + "/info/" + file_name + ".trashinfo\"");
file->store_string(trash_info);
file->close();
// Rename our resource before moving it to the trash can.
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- err = dir_access->rename(p_path, p_path.get_base_dir() + "/" + file_name);
- ERR_FAIL_COND_V_MSG(err != OK, err, "Can't rename file \"" + p_path + "\"");
+ err = dir_access->rename(path, renamed_path);
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Can't rename file \"" + path + "\" to \"" + renamed_path + "\"");
}
// Move the given resource to the trash can.
// Do not use DirAccess:rename() because it can't move files across multiple mountpoints.
List<String> mv_args;
- mv_args.push_back(p_path.get_base_dir() + "/" + file_name);
+ mv_args.push_back(renamed_path);
mv_args.push_back(trash_path + "/files");
{
int retval;
@@ -518,11 +534,10 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
// Issue an error if "mv" failed to move the given resource to the trash can.
if (err != OK || retval != 0) {
- ERR_PRINT("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_path + "/files\"");
- DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- err = dir_access->rename(p_path.get_base_dir() + "/" + file_name, p_path);
- memdelete(dir_access);
- ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename " + p_path.get_base_dir() + "/" + file_name + " back to its original name:" + p_path);
+ ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\"");
+ DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ err = dir_access->rename(renamed_path, path);
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\"");
return FAILED;
}
}
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
index ad6e4cd168..d3857e85f8 100644
--- a/platform/linuxbsd/os_linuxbsd.h
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -39,8 +39,6 @@
#include "drivers/unix/os_unix.h"
#include "joypad_linux.h"
#include "servers/audio_server.h"
-#include "servers/rendering/renderer_compositor.h"
-#include "servers/rendering_server.h"
class OS_LinuxBSD : public OS_Unix {
virtual void delete_main_loop() override;
@@ -89,6 +87,7 @@ public:
virtual Error shell_open(String p_uri) override;
virtual String get_unique_id() const override;
+ virtual String get_processor_name() const override;
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp
index e2fd8c76d2..b4f585726f 100644
--- a/platform/linuxbsd/vulkan_context_x11.cpp
+++ b/platform/linuxbsd/vulkan_context_x11.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "vulkan_context_x11.h"
+
#ifdef USE_VOLK
#include <volk.h>
#else
diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm
index 3e640b3bf3..06ed91907c 100644
--- a/platform/osx/crash_handler_osx.mm
+++ b/platform/osx/crash_handler_osx.mm
@@ -89,8 +89,9 @@ static void handle_crash(int sig) {
fprintf(stderr, "\n================================================================\n");
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
- if (OS::get_singleton()->get_main_loop())
+ if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
+ }
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
if (String(VERSION_HASH).is_empty()) {
@@ -119,8 +120,9 @@ static void handle_crash(int sig) {
snprintf(fname, 1024, "%s", demangled);
}
- if (demangled)
+ if (demangled) {
free(demangled);
+ }
}
}
@@ -177,8 +179,9 @@ CrashHandler::~CrashHandler() {
}
void CrashHandler::disable() {
- if (disabled)
+ if (disabled) {
return;
+ }
#ifdef CRASH_HANDLER_ENABLED
signal(SIGSEGV, nullptr);
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index eaf03d298e..cc9ac162ea 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -95,6 +95,7 @@ public:
ObjectID instance_id;
WindowID transient_parent = INVALID_WINDOW_ID;
+ bool exclusive = false;
Set<WindowID> transient_children;
bool layered_window = false;
@@ -103,8 +104,14 @@ public:
bool borderless = false;
bool resize_disabled = false;
bool no_focus = false;
+ bool is_popup = false;
+
+ Rect2i parent_safe_rect;
};
+ List<WindowID> popup_list;
+ uint64_t time_since_popup = 0;
+
private:
#if defined(GLES3_ENABLED)
GLManager_OSX *gl_manager = nullptr;
@@ -153,6 +160,7 @@ private:
float display_max_scale = 1.f;
Point2i origin;
bool displays_arrangement_dirty = true;
+ bool is_resizing = false;
CursorShape cursor_shape = CURSOR_ARROW;
NSCursor *cursors[CURSOR_MAX];
@@ -196,6 +204,11 @@ public:
void push_to_key_event_buffer(const KeyEvent &p_event);
void update_im_text(const Point2i &p_selection, const String &p_text);
void set_last_focused_window(WindowID p_window);
+ void mouse_process_popups(bool p_close = false);
+ void popup_open(WindowID p_window);
+ void popup_close(WindowID p_window);
+ void set_is_resizing(bool p_is_resizing);
+ bool get_is_resizing() const;
void window_update(WindowID p_window);
void window_destroy(WindowID p_window);
@@ -258,6 +271,10 @@ public:
virtual void show_window(WindowID p_id) override;
virtual void delete_sub_window(WindowID p_id) override;
+ virtual WindowID window_get_active_popup() const override;
+ virtual void window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) override;
+ virtual Rect2i window_get_popup_safe_rect(WindowID p_window) const override;
+
virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
@@ -274,6 +291,7 @@ public:
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
+ virtual void window_set_exclusive(WindowID p_window, bool p_exclusive) override;
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 2691664b96..89ca6e50ec 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -324,27 +324,39 @@ void DisplayServerOSX::_dispatch_input_event(const Ref<InputEvent> &p_event) {
Variant ret;
Callable::CallError ce;
+ {
+ List<WindowID>::Element *E = popup_list.front();
+ if (E && Object::cast_to<InputEventKey>(*p_event)) {
+ // Redirect keyboard input to active popup.
+ if (windows.has(E->get())) {
+ Callable callable = windows[E->get()].input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ }
+ in_dispatch_input_event = false;
+ return;
+ }
+ }
+
Ref<InputEventFromWindow> event_from_window = p_event;
if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
// Send to a window.
if (windows.has(event_from_window->get_window_id())) {
Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
- if (callable.is_null()) {
- return;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
}
- callable.call((const Variant **)&evp, 1, ret, ce);
}
} else {
// Send to all windows.
- for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
- Callable callable = E->get().input_event_callback;
- if (callable.is_null()) {
- continue;
+ for (KeyValue<WindowID, WindowData> &E : windows) {
+ Callable callable = E.value.input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
}
- callable.call((const Variant **)&evp, 1, ret, ce);
}
}
-
in_dispatch_input_event = false;
}
}
@@ -513,6 +525,9 @@ DisplayServerOSX::WindowData &DisplayServerOSX::get_window(WindowID p_window) {
}
void DisplayServerOSX::send_event(NSEvent *p_event) {
+ if ([p_event type] == NSEventTypeLeftMouseDown || [p_event type] == NSEventTypeRightMouseDown || [p_event type] == NSEventTypeOtherMouseDown) {
+ mouse_process_popups();
+ }
// Special case handling of command-period, which is traditionally a special
// shortcut in macOS and doesn't arrive at our regular keyDown handler.
if ([p_event type] == NSEventTypeKeyDown) {
@@ -584,6 +599,14 @@ void DisplayServerOSX::set_last_focused_window(WindowID p_window) {
last_focused_window = p_window;
}
+void DisplayServerOSX::set_is_resizing(bool p_is_resizing) {
+ is_resizing = p_is_resizing;
+}
+
+bool DisplayServerOSX::get_is_resizing() const {
+ return is_resizing;
+}
+
void DisplayServerOSX::window_update(WindowID p_window) {
#if defined(GLES3_ENABLED)
if (gl_manager) {
@@ -790,8 +813,9 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root,
const NSMenu *sub_menu = [menu_item submenu];
if (sub_menu) {
for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
- if (E->get() == sub_menu)
+ if (E->get() == sub_menu) {
return E->key();
+ }
}
}
}
@@ -1335,7 +1359,7 @@ float DisplayServerOSX::screen_get_refresh_rate(int p_screen) const {
const double displayRefreshRate = CGDisplayModeGetRefreshRate(displayMode);
return (float)displayRefreshRate;
}
- ERR_PRINT("An error occured while trying to get the screen refresh rate.");
+ ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
return SCREEN_REFRESH_RATE_FALLBACK;
}
@@ -1365,7 +1389,8 @@ DisplayServer::WindowID DisplayServerOSX::create_sub_window(WindowMode p_mode, V
void DisplayServerOSX::show_window(WindowID p_id) {
WindowData &wd = windows[p_id];
- if (wd.no_focus) {
+ popup_open(p_id);
+ if (wd.no_focus || wd.is_popup) {
[wd.window_object orderFront:nil];
} else {
[wd.window_object makeKeyAndOrderFront:nil];
@@ -1471,6 +1496,24 @@ void DisplayServerOSX::window_set_current_screen(int p_screen, WindowID p_window
}
}
+void DisplayServerOSX::window_set_exclusive(WindowID p_window, bool p_exclusive) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ if (wd.exclusive != p_exclusive) {
+ wd.exclusive = p_exclusive;
+ if (wd.transient_parent != INVALID_WINDOW_ID) {
+ WindowData &wd_parent = windows[wd.transient_parent];
+ if (wd.exclusive) {
+ ERR_FAIL_COND_MSG([[wd_parent.window_object childWindows] count] > 0, "Transient parent has another exclusive child.");
+ [wd_parent.window_object addChildWindow:wd.window_object ordered:NSWindowAbove];
+ } else {
+ [wd_parent.window_object removeChildWindow:wd.window_object];
+ }
+ }
+ }
+}
+
Point2i DisplayServerOSX::window_get_position(WindowID p_window) const {
_THREAD_SAFE_METHOD_
@@ -1541,8 +1584,11 @@ void DisplayServerOSX::window_set_transient(WindowID p_window, WindowID p_parent
wd_window.transient_parent = INVALID_WINDOW_ID;
wd_parent.transient_children.erase(p_window);
-
[wd_window.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+
+ if (wd_window.exclusive) {
+ [wd_parent.window_object removeChildWindow:wd_window.window_object];
+ }
} else {
ERR_FAIL_COND(!windows.has(p_parent));
ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
@@ -1550,8 +1596,11 @@ void DisplayServerOSX::window_set_transient(WindowID p_window, WindowID p_parent
wd_window.transient_parent = p_parent;
wd_parent.transient_children.insert(p_window);
-
[wd_window.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+
+ if (wd_window.exclusive) {
+ [wd_parent.window_object addChildWindow:wd_window.window_object ordered:NSWindowAbove];
+ }
}
}
@@ -1784,7 +1833,7 @@ void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
}
_update_window_style(wd);
if ([wd.window_object isVisible]) {
- if (wd.no_focus) {
+ if (wd.no_focus || wd.is_popup) {
[wd.window_object orderFront:nil];
} else {
[wd.window_object makeKeyAndOrderFront:nil];
@@ -1813,6 +1862,11 @@ void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
case WINDOW_FLAG_NO_FOCUS: {
wd.no_focus = p_enabled;
} break;
+ case WINDOW_FLAG_POPUP: {
+ ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
+ ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
+ wd.is_popup = p_enabled;
+ } break;
default: {
}
}
@@ -1844,6 +1898,9 @@ bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) co
case WINDOW_FLAG_NO_FOCUS: {
return wd.no_focus;
} break;
+ case WINDOW_FLAG_POPUP: {
+ return wd.is_popup;
+ } break;
default: {
}
}
@@ -1863,7 +1920,7 @@ void DisplayServerOSX::window_move_to_foreground(WindowID p_window) {
const WindowData &wd = windows[p_window];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
- if (wd.no_focus) {
+ if (wd.no_focus || wd.is_popup) {
[wd.window_object orderFront:nil];
} else {
[wd.window_object makeKeyAndOrderFront:nil];
@@ -2421,6 +2478,120 @@ void DisplayServerOSX::register_osx_driver() {
register_create_function("osx", create_func, get_rendering_drivers_func);
}
+DisplayServer::WindowID DisplayServerOSX::window_get_active_popup() const {
+ const List<WindowID>::Element *E = popup_list.back();
+ if (E) {
+ return E->get();
+ } else {
+ return INVALID_WINDOW_ID;
+ }
+}
+
+void DisplayServerOSX::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.parent_safe_rect = p_rect;
+}
+
+Rect2i DisplayServerOSX::window_get_popup_safe_rect(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Rect2i());
+ const WindowData &wd = windows[p_window];
+ return wd.parent_safe_rect;
+}
+
+void DisplayServerOSX::popup_open(WindowID p_window) {
+ WindowData &wd = windows[p_window];
+ if (wd.is_popup) {
+ bool was_empty = popup_list.is_empty();
+ // Close all popups, up to current popup parent, or every popup if new window is not transient.
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ if (wd.transient_parent != E->get() || wd.transient_parent == INVALID_WINDOW_ID) {
+ send_window_event(windows[E->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ } else {
+ break;
+ }
+ }
+
+ if (was_empty && popup_list.is_empty()) {
+ // Inform OS that popup was opened, to close other native popups.
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.beginMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
+ }
+ time_since_popup = OS::get_singleton()->get_ticks_msec();
+ popup_list.push_back(p_window);
+ }
+}
+
+void DisplayServerOSX::popup_close(WindowID p_window) {
+ bool was_empty = popup_list.is_empty();
+ List<WindowID>::Element *E = popup_list.find(p_window);
+ while (E) {
+ send_window_event(windows[E->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->next();
+ popup_list.erase(E);
+ E = F;
+ }
+ if (!was_empty && popup_list.is_empty()) {
+ // Inform OS that all popups are closed.
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
+ }
+}
+
+void DisplayServerOSX::mouse_process_popups(bool p_close) {
+ _THREAD_SAFE_METHOD_
+
+ bool was_empty = popup_list.is_empty();
+ if (p_close) {
+ // Close all popups.
+ List<WindowID>::Element *E = popup_list.front();
+ while (E) {
+ send_window_event(windows[E->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->next();
+ popup_list.erase(E);
+ E = F;
+ }
+ if (!was_empty) {
+ // Inform OS that all popups are closed.
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
+ }
+ } else {
+ uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_popup;
+ if (delta < 250) {
+ return;
+ }
+
+ Point2i pos = mouse_get_position();
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ // Popup window area.
+ Rect2i win_rect = Rect2i(window_get_position(E->get()), window_get_size(E->get()));
+ // Area of the parent window, which responsible for opening sub-menu.
+ Rect2i safe_rect = window_get_popup_safe_rect(E->get());
+ if (win_rect.has_point(pos)) {
+ break;
+ } else if (safe_rect != Rect2i() && safe_rect.has_point(pos)) {
+ break;
+ } else {
+ send_window_event(windows[E->get()], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ }
+ }
+ if (!was_empty && popup_list.is_empty()) {
+ // Inform OS that all popups are closed.
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
+ }
+ }
+}
+
DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
diff --git a/platform/osx/export/codesign.cpp b/platform/osx/export/codesign.cpp
index 8ea6ff519d..b609a21c44 100644
--- a/platform/osx/export/codesign.cpp
+++ b/platform/osx/export/codesign.cpp
@@ -35,7 +35,9 @@
#include "plist.h"
#include "core/os/os.h"
+#include "editor/editor_paths.h"
#include "editor/editor_settings.h"
+
#include "modules/modules_enabled.gen.h" // For regex.
#include <ctime>
@@ -1206,7 +1208,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
String id;
String main_exe = p_exe_path;
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (!da) {
r_error_msg = TTR("Can't get filesystem access.");
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
@@ -1359,9 +1361,12 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
// Generate common signature structures.
if (id.is_empty()) {
- Ref<Crypto> crypto = Ref<Crypto>(Crypto::create());
- PackedByteArray uuid = crypto->generate_random_bytes(16);
- id = (String("a-55554944") /*a-UUID*/ + String::hex_encode_buffer(uuid.ptr(), 16));
+ CryptoCore::RandomGenerator rng;
+ ERR_FAIL_COND_V_MSG(rng.init(), FAILED, "Failed to initialize random number generator.");
+ uint8_t uuid[16];
+ Error err = rng.get_random_bytes(uuid, 16);
+ ERR_FAIL_COND_V_MSG(err, err, "Failed to generate UUID.");
+ id = (String("a-55554944") /*a-UUID*/ + String::hex_encode_buffer(uuid, 16));
}
CharString uuid_str = id.utf8();
print_verbose(vformat("CodeSign: Used bundle ID: %s", id));
@@ -1517,7 +1522,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
}
Error CodeSign::codesign(bool p_use_hardened_runtime, bool p_force, const String &p_path, const String &p_ent_path, String &r_error_msg) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (!da) {
r_error_msg = TTR("Can't get filesystem access.");
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
diff --git a/platform/osx/export/codesign.h b/platform/osx/export/codesign.h
index 927df79281..e5e9be5c28 100644
--- a/platform/osx/export/codesign.h
+++ b/platform/osx/export/codesign.h
@@ -41,7 +41,6 @@
#ifndef CODESIGN_H
#define CODESIGN_H
-#include "core/crypto/crypto.h"
#include "core/crypto/crypto_core.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index f0b58efb63..0f4477d312 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -28,10 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "modules/modules_enabled.gen.h" // For regex.
+#include "export_plugin.h"
#include "codesign.h"
-#include "export_plugin.h"
+
+#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
+
+#include "modules/modules_enabled.gen.h" // For regex.
void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
if (p_preset->get("texture_format/s3tc")) {
@@ -68,8 +72,6 @@ void EditorExportPlatformOSX::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::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png,*.icns"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), ""));
@@ -77,18 +79,30 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "application/copyright_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "display/high_res"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/microphone_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/camera_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/location_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the location information"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/location_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/address_book_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the address book"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/address_book_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/calendar_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the calendar"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/calendar_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photos_library_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the photo library"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/photos_library_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/desktop_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Desktop folder"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/desktop_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/documents_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Documents folder"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/documents_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/downloads_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Downloads folder"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/downloads_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/network_volumes_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use network volumes"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/network_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/removable_volumes_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use removable volumes"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/removable_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/enable"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "Type: Name (ID)"), ""));
@@ -312,9 +326,7 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset
if (lines[i].find("$binary") != -1) {
strnew += lines[i].replace("$binary", p_binary) + "\n";
} else if (lines[i].find("$name") != -1) {
- strnew += lines[i].replace("$name", p_binary) + "\n";
- } else if (lines[i].find("$info") != -1) {
- strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n";
+ strnew += lines[i].replace("$name", ProjectSettings::get_singleton()->get("application/config/name")) + "\n";
} else if (lines[i].find("$bundle_identifier") != -1) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
} else if (lines[i].find("$short_version") != -1) {
@@ -437,7 +449,7 @@ Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset
print_line(TTR("Note: The notarization process generally takes less than an hour. When the process is completed, you'll receive an email."));
print_line(" " + TTR("You can check progress manually by opening a Terminal and running the following command:"));
print_line(" \"xcrun altool --notarization-history 0 -u <your email> -p <app-specific pwd>\"");
- print_line(" " + TTR("Run the following command to staple notarization ticket to the exported application (optional):"));
+ print_line(" " + TTR("Run the following command to staple the notarization ticket to the exported application (optional):"));
print_line(" \"xcrun stapler staple <app path>\"");
}
@@ -709,9 +721,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".64";
String pkg_name;
- if (p_preset->get("application/name") != "") {
- pkg_name = p_preset->get("application/name"); // app_name
- } else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
+ if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
} else {
pkg_name = "Unnamed";
@@ -777,20 +787,113 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
}
+ Dictionary appnames = ProjectSettings::get_singleton()->get("application/config/name_localized");
+ Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized");
+ Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized");
+ Dictionary location_usage_descriptions = p_preset->get("privacy/location_usage_description_localized");
+ Dictionary address_book_usage_descriptions = p_preset->get("privacy/address_book_usage_description_localized");
+ Dictionary calendar_usage_descriptions = p_preset->get("privacy/calendar_usage_description_localized");
+ Dictionary photos_library_usage_descriptions = p_preset->get("privacy/photos_library_usage_description_localized");
+ Dictionary desktop_folder_usage_descriptions = p_preset->get("privacy/desktop_folder_usage_description_localized");
+ Dictionary documents_folder_usage_descriptions = p_preset->get("privacy/documents_folder_usage_description_localized");
+ Dictionary downloads_folder_usage_descriptions = p_preset->get("privacy/downloads_folder_usage_description_localized");
+ Dictionary network_volumes_usage_descriptions = p_preset->get("privacy/network_volumes_usage_description_localized");
+ Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized");
+ Dictionary copyrights = p_preset->get("application/copyright_localized");
+
Vector<String> translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations");
if (translations.size() > 0) {
{
String fname = tmp_app_path_name + "/Contents/Resources/en.lproj";
tmp_app_dir->make_dir_recursive(fname);
FileAccessRef f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
+ f->store_line("/* Localized versions of Info.plist keys */");
+ f->store_line("");
+ f->store_line("CFBundleDisplayName = \"" + ProjectSettings::get_singleton()->get("application/config/name").operator String() + "\";");
+ if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
+ f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
+ f->store_line("NSCameraUsageDescription = \"" + p_preset->get("privacy/camera_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
+ f->store_line("NSLocationUsageDescription = \"" + p_preset->get("privacy/location_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
+ f->store_line("NSContactsUsageDescription = \"" + p_preset->get("privacy/address_book_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
+ f->store_line("NSCalendarsUsageDescription = \"" + p_preset->get("privacy/calendar_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
+ f->store_line("NSPhotoLibraryUsageDescription = \"" + p_preset->get("privacy/photos_library_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/desktop_folder_usage_description")).is_empty()) {
+ f->store_line("NSDesktopFolderUsageDescription = \"" + p_preset->get("privacy/desktop_folder_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/documents_folder_usage_description")).is_empty()) {
+ f->store_line("NSDocumentsFolderUsageDescription = \"" + p_preset->get("privacy/documents_folder_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/downloads_folder_usage_description")).is_empty()) {
+ f->store_line("NSDownloadsFolderUsageDescription = \"" + p_preset->get("privacy/downloads_folder_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/network_volumes_usage_description")).is_empty()) {
+ f->store_line("NSNetworkVolumesUsageDescription = \"" + p_preset->get("privacy/network_volumes_usage_description").operator String() + "\";");
+ }
+ if (!((String)p_preset->get("privacy/removable_volumes_usage_description")).is_empty()) {
+ f->store_line("NSRemovableVolumesUsageDescription = \"" + p_preset->get("privacy/removable_volumes_usage_description").operator String() + "\";");
+ }
+ f->store_line("NSHumanReadableCopyright = \"" + p_preset->get("application/copyright").operator String() + "\";");
}
for (const String &E : translations) {
Ref<Translation> tr = ResourceLoader::load(E);
if (tr.is_valid()) {
- String fname = tmp_app_path_name + "/Contents/Resources/" + tr->get_locale() + ".lproj";
+ String lang = tr->get_locale();
+ String fname = tmp_app_path_name + "/Contents/Resources/" + lang + ".lproj";
tmp_app_dir->make_dir_recursive(fname);
FileAccessRef f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
+ f->store_line("/* Localized versions of Info.plist keys */");
+ f->store_line("");
+ if (appnames.has(lang)) {
+ f->store_line("CFBundleDisplayName = \"" + appnames[lang].operator String() + "\";");
+ }
+ if (microphone_usage_descriptions.has(lang)) {
+ f->store_line("NSMicrophoneUsageDescription = \"" + microphone_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (camera_usage_descriptions.has(lang)) {
+ f->store_line("NSCameraUsageDescription = \"" + camera_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (location_usage_descriptions.has(lang)) {
+ f->store_line("NSLocationUsageDescription = \"" + location_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (address_book_usage_descriptions.has(lang)) {
+ f->store_line("NSContactsUsageDescription = \"" + address_book_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (calendar_usage_descriptions.has(lang)) {
+ f->store_line("NSCalendarsUsageDescription = \"" + calendar_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (photos_library_usage_descriptions.has(lang)) {
+ f->store_line("NSPhotoLibraryUsageDescription = \"" + photos_library_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (desktop_folder_usage_descriptions.has(lang)) {
+ f->store_line("NSDesktopFolderUsageDescription = \"" + desktop_folder_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (documents_folder_usage_descriptions.has(lang)) {
+ f->store_line("NSDocumentsFolderUsageDescription = \"" + documents_folder_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (downloads_folder_usage_descriptions.has(lang)) {
+ f->store_line("NSDownloadsFolderUsageDescription = \"" + downloads_folder_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (network_volumes_usage_descriptions.has(lang)) {
+ f->store_line("NSNetworkVolumesUsageDescription = \"" + network_volumes_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (removable_volumes_usage_descriptions.has(lang)) {
+ f->store_line("NSRemovableVolumesUsageDescription = \"" + removable_volumes_usage_descriptions[lang].operator String() + "\";");
+ }
+ if (copyrights.has(lang)) {
+ f->store_line("NSHumanReadableCopyright = \"" + copyrights[lang].operator String() + "\";");
+ }
}
}
}
@@ -822,7 +925,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (((info.external_fa >> 16L) & 0120000) == 0120000) {
#ifndef UNIX_ENABLED
- WARN_PRINT(vformat("Relative symlinks are not supported on this OS, exported project might be broken!"));
+ WARN_PRINT(vformat("Relative symlinks are not supported on this OS, the exported project might be broken!"));
#endif
// Handle symlinks in the archive.
file = tmp_app_path_name.plus_file(file);
@@ -1126,7 +1229,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
ad_hoc = (sign_identity == "" || sign_identity == "-");
bool lib_validation = p_preset->get("codesign/entitlements/disable_library_validation");
if ((!dylibs_found.is_empty() || !shared_objects.is_empty()) && sign_enabled && ad_hoc && !lib_validation) {
- ERR_PRINT("Application with an ad-hoc signature require 'Disable Library Validation' entitlement to load dynamic libraries.");
+ ERR_PRINT("Ad-hoc signed applications require the 'Disable Library Validation' entitlement to load dynamic libraries.");
err = ERR_CANT_CREATE;
}
}
@@ -1205,7 +1308,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
bool noto_enabled = p_preset->get("notarization/enable");
if (err == OK && noto_enabled) {
if (export_format == "app") {
- WARN_PRINT("Notarization require app to be archived first, select DMG or ZIP export format instead.");
+ WARN_PRINT("Notarization requires the app to be archived first, select the DMG or ZIP export format instead.");
} else {
if (ep.step(TTR("Sending archive for notarization"), 4)) {
return ERR_SKIP;
@@ -1402,7 +1505,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
if (noto_enabled) {
if (ad_hoc) {
- err += TTR("Notarization: Notarization with the ad-hoc signature is not supported.") + "\n";
+ err += TTR("Notarization: Notarization with an ad-hoc signature is not supported.") + "\n";
valid = false;
}
if (!sign_enabled) {
@@ -1426,9 +1529,9 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
valid = false;
}
} else {
- err += TTR("Warning: Notarization is disabled. Exported project will be blocked by Gatekeeper, if it's downloaded from an unknown source.") + "\n";
+ err += TTR("Warning: Notarization is disabled. The exported project will be blocked by Gatekeeper if it's downloaded from an unknown source.") + "\n";
if (!sign_enabled) {
- err += TTR("Code signing is disabled. Exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
+ err += TTR("Code signing is disabled. The exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
} else {
if ((bool)p_preset->get("codesign/hardened_runtime") && ad_hoc) {
err += TTR("Hardened Runtime is not compatible with ad-hoc signature, and will be disabled!") + "\n";
@@ -1439,9 +1542,9 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
}
}
#else
- err += TTR("Warning: Notarization is not supported on this OS. Exported project will be blocked by Gatekeeper, if it's downloaded from an unknown source.") + "\n";
+ err += TTR("Warning: Notarization is not supported from this OS. The exported project will be blocked by Gatekeeper if it's downloaded from an unknown source.") + "\n";
if (!sign_enabled) {
- err += TTR("Code signing is disabled. Exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
+ err += TTR("Code signing is disabled. The exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
}
#endif
diff --git a/platform/osx/export/export_plugin.h b/platform/osx/export/export_plugin.h
index 931ce7e41a..b85e9d662c 100644
--- a/platform/osx/export/export_plugin.h
+++ b/platform/osx/export/export_plugin.h
@@ -40,7 +40,6 @@
#include "core/os/os.h"
#include "core/version.h"
#include "editor/editor_export.h"
-#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "platform/osx/logo.gen.h"
diff --git a/platform/osx/godot_application_delegate.mm b/platform/osx/godot_application_delegate.mm
index be284ba543..dc82075c44 100644
--- a/platform/osx/godot_application_delegate.mm
+++ b/platform/osx/godot_application_delegate.mm
@@ -68,6 +68,10 @@
}
- (void)applicationDidResignActive:(NSNotification *)notification {
+ DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
+ if (ds) {
+ ds->mouse_process_popups(true);
+ }
if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
}
diff --git a/platform/osx/godot_content_view.mm b/platform/osx/godot_content_view.mm
index 4e831e1ccc..e96f0a8098 100644
--- a/platform/osx/godot_content_view.mm
+++ b/platform/osx/godot_content_view.mm
@@ -117,6 +117,10 @@
}
}
+- (void)doCommandBySelector:(SEL)aSelector {
+ [self tryToPerform:aSelector with:self];
+}
+
- (void)unmarkText {
ime_input_event_in_progress = false;
[[marked_text mutableString] setString:@""];
@@ -277,7 +281,7 @@
}
DisplayServerOSX::WindowData &wd = ds->get_window(window_id);
- return !wd.no_focus;
+ return !wd.no_focus && !wd.is_popup;
}
- (BOOL)acceptsFirstResponder {
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 7fabfaa1b7..f3db363151 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -49,7 +49,7 @@ int main(int argc, char **argv) {
first_arg = i + 2;
}
printf("%i: %s\n", i, argv[i]);
- };
+ }
#ifdef DEBUG_ENABLED
// Lets report the path we made current after all that.
@@ -84,4 +84,4 @@ int main(int argc, char **argv) {
Main::cleanup();
return os.get_exit_code();
-};
+}
diff --git a/platform/osx/godot_window.mm b/platform/osx/godot_window.mm
index 772a2ddb9f..d43853a94b 100644
--- a/platform/osx/godot_window.mm
+++ b/platform/osx/godot_window.mm
@@ -52,7 +52,7 @@
}
DisplayServerOSX::WindowData &wd = ds->get_window(window_id);
- return !wd.no_focus;
+ return !wd.no_focus && !wd.is_popup;
}
- (BOOL)canBecomeMainWindow {
@@ -63,7 +63,7 @@
}
DisplayServerOSX::WindowData &wd = ds->get_window(window_id);
- return !wd.no_focus;
+ return !wd.no_focus && !wd.is_popup;
}
@end
diff --git a/platform/osx/godot_window_delegate.mm b/platform/osx/godot_window_delegate.mm
index 1742be987d..9f49a6a4e9 100644
--- a/platform/osx/godot_window_delegate.mm
+++ b/platform/osx/godot_window_delegate.mm
@@ -54,6 +54,8 @@
return;
}
+ ds->popup_close(window_id);
+
DisplayServerOSX::WindowData &wd = ds->get_window(window_id);
while (wd.transient_children.size()) {
ds->window_set_transient(wd.transient_children.front()->get(), DisplayServerOSX::INVALID_WINDOW_ID);
@@ -147,6 +149,20 @@
}
}
+- (void)windowWillStartLiveResize:(NSNotification *)notification {
+ DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
+ if (ds) {
+ ds->set_is_resizing(true);
+ }
+}
+
+- (void)windowDidEndLiveResize:(NSNotification *)notification {
+ DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
+ if (ds) {
+ ds->set_is_resizing(false);
+ }
+}
+
- (void)windowDidResize:(NSNotification *)notification {
DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
if (!ds || !ds->has_window(window_id)) {
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index d518206f04..7d31ede61d 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -322,10 +322,11 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
// Bluetooth device.
String guid = "05000000";
for (int i = 0; i < 12; i++) {
- if (i < name.size())
+ if (i < name.size()) {
guid += _hex_str(name[i]);
- else
+ } else {
guid += "00";
+ }
}
input->joy_connection_changed(id, true, name, guid);
}
@@ -381,8 +382,9 @@ bool joypad::check_ff_features() {
if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) {
uint32_t val;
ret = FFDeviceGetForceFeedbackProperty(ff_device, FFPROP_FFGAIN, &val, sizeof(val));
- if (ret != FF_OK)
+ if (ret != FF_OK) {
return false;
+ }
int num_axes = features.numFfAxes;
ff_axes = (DWORD *)memalloc(sizeof(DWORD) * num_axes);
ff_directions = (LONG *)memalloc(sizeof(LONG) * num_axes);
@@ -509,16 +511,18 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
int JoypadOSX::get_joy_index(int p_id) const {
for (int i = 0; i < device_list.size(); i++) {
- if (device_list[i].id == p_id)
+ if (device_list[i].id == p_id) {
return i;
+ }
}
return -1;
}
int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const {
for (int i = 0; i < device_list.size(); i++) {
- if (device_list[i].device_ref == p_device)
+ if (device_list[i].device_ref == p_device) {
return i;
+ }
}
return -1;
}
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 5bb5b3320e..53c5c8bd90 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -102,6 +102,7 @@ public:
virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override;
virtual String get_unique_id() const override;
+ virtual String get_processor_name() const override;
virtual bool _check_internal_feature_support(const String &p_feature) override;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 9288e658cf..7e0cf9f9cc 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -42,6 +42,8 @@
#include <dlfcn.h>
#include <libproc.h>
#include <mach-o/dyld.h>
+#include <os/log.h>
+#include <sys/sysctl.h>
_FORCE_INLINE_ String OS_OSX::get_framework_executable(const String &p_path) {
// Append framework executable name, or return as is if p_path is not a framework.
@@ -56,7 +58,8 @@ _FORCE_INLINE_ String OS_OSX::get_framework_executable(const String &p_path) {
void OS_OSX::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context) {
// Prevent main loop from sleeping and redraw window during resize / modal popups.
- if (get_singleton()->get_main_loop()) {
+ DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
+ if (get_singleton()->get_main_loop() && ds && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD || !ds->get_is_resizing())) {
Main::force_redraw();
if (!Main::is_iterating()) { // Avoid cyclic loop.
Main::iteration();
@@ -72,6 +75,15 @@ void OS_OSX::initialize() {
initialize_core();
}
+String OS_OSX::get_processor_name() const {
+ char buffer[256];
+ size_t buffer_len = 256;
+ if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) {
+ return String::utf8(buffer, buffer_len);
+ }
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+}
+
void OS_OSX::initialize_core() {
OS_Unix::initialize_core();
@@ -430,7 +442,7 @@ void OS_OSX::run() {
} @catch (NSException *exception) {
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
}
- };
+ }
main_loop->finalize();
}
diff --git a/platform/osx/osx_terminal_logger.mm b/platform/osx/osx_terminal_logger.mm
index c1dca111a7..48e26f42bf 100644
--- a/platform/osx/osx_terminal_logger.mm
+++ b/platform/osx/osx_terminal_logger.mm
@@ -40,10 +40,11 @@ void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, in
}
const char *err_details;
- if (p_rationale && p_rationale[0])
+ if (p_rationale && p_rationale[0]) {
err_details = p_rationale;
- else
+ } else {
err_details = p_code;
+ }
switch (p_type) {
case ERR_WARNING:
diff --git a/platform/uwp/app_uwp.cpp b/platform/uwp/app_uwp.cpp
index 6832d71a6f..6460c43447 100644
--- a/platform/uwp/app_uwp.cpp
+++ b/platform/uwp/app_uwp.cpp
@@ -177,7 +177,7 @@ static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) {
#endif
return MOUSE_BUTTON_NONE;
-};
+}
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
@@ -231,11 +231,11 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windo
outputPosition.Y *= vm.height;
return outputPosition;
-};
+}
static int _get_finger(uint32_t p_touch_id) {
return p_touch_id % 31; // for now
-};
+}
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
@@ -281,15 +281,15 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
os->input_event(mouse_button);
}
}
-};
+}
void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
pointer_event(sender, args, true);
-};
+}
void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
pointer_event(sender, args, false);
-};
+}
void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
pointer_event(sender, args, true, true);
@@ -416,8 +416,9 @@ void App::Load(Platform::String ^ entryPoint) {
// This method is called after the window becomes active.
void App::Run() {
- if (Main::start())
+ if (Main::start()) {
os->run();
+ }
}
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView
diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp
index a08693c72f..8ec7bdfcee 100644
--- a/platform/uwp/context_egl_uwp.cpp
+++ b/platform/uwp/context_egl_uwp.cpp
@@ -36,26 +36,26 @@ using Platform::Exception;
void ContextEGL_UWP::release_current() {
eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext);
-};
+}
void ContextEGL_UWP::make_current() {
eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext);
-};
+}
int ContextEGL_UWP::get_window_width() {
return width;
-};
+}
int ContextEGL_UWP::get_window_height() {
return height;
-};
+}
void ContextEGL_UWP::reset() {
cleanup();
window = CoreWindow::GetForCurrentThread();
initialize();
-};
+}
void ContextEGL_UWP::swap_buffers() {
if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) {
@@ -66,7 +66,7 @@ void ContextEGL_UWP::swap_buffers() {
// tell rasterizer to reload textures and stuff?
}
-};
+}
Error ContextEGL_UWP::initialize() {
EGLint configAttribList[] = {
@@ -170,7 +170,7 @@ Error ContextEGL_UWP::initialize() {
}
} catch (...) {
return FAILED;
- };
+ }
mEglDisplay = display;
mEglSurface = surface;
@@ -180,7 +180,7 @@ Error ContextEGL_UWP::initialize() {
eglQuerySurface(display, surface, EGL_HEIGHT, &height);
return OK;
-};
+}
void ContextEGL_UWP::cleanup() {
if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) {
@@ -197,7 +197,7 @@ void ContextEGL_UWP::cleanup() {
eglTerminate(mEglDisplay);
mEglDisplay = EGL_NO_DISPLAY;
}
-};
+}
ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
mEglDisplay(EGL_NO_DISPLAY),
@@ -209,4 +209,4 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
ContextEGL_UWP::~ContextEGL_UWP() {
cleanup();
-};
+}
diff --git a/platform/uwp/export/app_packager.cpp b/platform/uwp/export/app_packager.cpp
index 9b586a640e..e7978ff74d 100644
--- a/platform/uwp/export/app_packager.cpp
+++ b/platform/uwp/export/app_packager.cpp
@@ -30,6 +30,9 @@
#include "app_packager.h"
+#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
+
String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) {
unsigned char hash[32];
char base64[45];
diff --git a/platform/uwp/export/app_packager.h b/platform/uwp/export/app_packager.h
index a5f5896592..da118449c7 100644
--- a/platform/uwp/export/app_packager.h
+++ b/platform/uwp/export/app_packager.h
@@ -41,7 +41,6 @@
#include "core/object/class_db.h"
#include "core/version.h"
#include "editor/editor_export.h"
-#include "editor/editor_node.h"
#include "thirdparty/minizip/unzip.h"
#include "thirdparty/minizip/zip.h"
diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp
index 594495375a..a76ff042b2 100644
--- a/platform/uwp/export/export_plugin.cpp
+++ b/platform/uwp/export/export_plugin.cpp
@@ -98,13 +98,13 @@ void EditorExportPlatformUWP::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait_flipped"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "images/background_color"), "transparent"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/store_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square44x44_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square71x71_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square150x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square310x310_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/wide310x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
- r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/splash_screen", PROPERTY_HINT_RESOURCE_TYPE, "StreamTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/store_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square44x44_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square71x71_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square150x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/square310x310_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/wide310x150_logo", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::OBJECT, "images/splash_screen", PROPERTY_HINT_RESOURCE_TYPE, "CompressedTexture2D"), Variant()));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square150x150"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_wide310x150"), false));
@@ -201,37 +201,37 @@ bool EditorExportPlatformUWP::can_export(const Ref<EditorExportPreset> &p_preset
err += TTR("Invalid background color.") + "\n";
}
- if (!p_preset->get("images/store_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/store_logo"))), 50, 50)) {
+ if (!p_preset->get("images/store_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/store_logo"))), 50, 50)) {
valid = false;
err += TTR("Invalid Store Logo image dimensions (should be 50x50).") + "\n";
}
- if (!p_preset->get("images/square44x44_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/square44x44_logo"))), 44, 44)) {
+ if (!p_preset->get("images/square44x44_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/square44x44_logo"))), 44, 44)) {
valid = false;
err += TTR("Invalid square 44x44 logo image dimensions (should be 44x44).") + "\n";
}
- if (!p_preset->get("images/square71x71_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/square71x71_logo"))), 71, 71)) {
+ if (!p_preset->get("images/square71x71_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/square71x71_logo"))), 71, 71)) {
valid = false;
err += TTR("Invalid square 71x71 logo image dimensions (should be 71x71).") + "\n";
}
- if (!p_preset->get("images/square150x150_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/square150x150_logo"))), 150, 150)) {
+ if (!p_preset->get("images/square150x150_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/square150x150_logo"))), 150, 150)) {
valid = false;
err += TTR("Invalid square 150x150 logo image dimensions (should be 150x150).") + "\n";
}
- if (!p_preset->get("images/square310x310_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/square310x310_logo"))), 310, 310)) {
+ if (!p_preset->get("images/square310x310_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/square310x310_logo"))), 310, 310)) {
valid = false;
err += TTR("Invalid square 310x310 logo image dimensions (should be 310x310).") + "\n";
}
- if (!p_preset->get("images/wide310x150_logo").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/wide310x150_logo"))), 310, 150)) {
+ if (!p_preset->get("images/wide310x150_logo").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/wide310x150_logo"))), 310, 150)) {
valid = false;
err += TTR("Invalid wide 310x150 logo image dimensions (should be 310x150).") + "\n";
}
- if (!p_preset->get("images/splash_screen").is_zero() && !_valid_image((Object::cast_to<StreamTexture2D>((Object *)p_preset->get("images/splash_screen"))), 620, 300)) {
+ if (!p_preset->get("images/splash_screen").is_zero() && !_valid_image((Object::cast_to<CompressedTexture2D>((Object *)p_preset->get("images/splash_screen"))), 620, 300)) {
valid = false;
err += TTR("Invalid splash screen image dimensions (should be 620x300).") + "\n";
}
diff --git a/platform/uwp/export/export_plugin.h b/platform/uwp/export/export_plugin.h
index eab958534a..bf89b10ffa 100644
--- a/platform/uwp/export/export_plugin.h
+++ b/platform/uwp/export/export_plugin.h
@@ -41,6 +41,7 @@
#include "core/version.h"
#include "editor/editor_export.h"
#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
#include "thirdparty/minizip/unzip.h"
#include "thirdparty/minizip/zip.h"
@@ -190,7 +191,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
return false;
}
- bool _valid_image(const StreamTexture2D *p_image, int p_width, int p_height) const {
+ bool _valid_image(const CompressedTexture2D *p_image, int p_width, int p_height) const {
if (!p_image) {
return false;
}
@@ -310,22 +311,22 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
Vector<uint8_t> data;
- StreamTexture2D *texture = nullptr;
+ CompressedTexture2D *texture = nullptr;
if (p_path.find("StoreLogo") != -1) {
- texture = p_preset->get("images/store_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/store_logo")));
+ texture = p_preset->get("images/store_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/store_logo")));
} else if (p_path.find("Square44x44Logo") != -1) {
- texture = p_preset->get("images/square44x44_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/square44x44_logo")));
+ texture = p_preset->get("images/square44x44_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/square44x44_logo")));
} else if (p_path.find("Square71x71Logo") != -1) {
- texture = p_preset->get("images/square71x71_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/square71x71_logo")));
+ texture = p_preset->get("images/square71x71_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/square71x71_logo")));
} else if (p_path.find("Square150x150Logo") != -1) {
- texture = p_preset->get("images/square150x150_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/square150x150_logo")));
+ texture = p_preset->get("images/square150x150_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/square150x150_logo")));
} else if (p_path.find("Square310x310Logo") != -1) {
- texture = p_preset->get("images/square310x310_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/square310x310_logo")));
+ texture = p_preset->get("images/square310x310_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/square310x310_logo")));
} else if (p_path.find("Wide310x150Logo") != -1) {
- texture = p_preset->get("images/wide310x150_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/wide310x150_logo")));
+ texture = p_preset->get("images/wide310x150_logo").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/wide310x150_logo")));
} else if (p_path.find("SplashScreen") != -1) {
- texture = p_preset->get("images/splash_screen").is_zero() ? nullptr : Object::cast_to<StreamTexture2D>(((Object *)p_preset->get("images/splash_screen")));
+ texture = p_preset->get("images/splash_screen").is_zero() ? nullptr : Object::cast_to<CompressedTexture2D>(((Object *)p_preset->get("images/splash_screen")));
} else {
ERR_PRINT("Unable to load logo");
}
@@ -392,7 +393,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
".webp", // Same reasoning as .png
".cfb", // Don't let small config files slow-down startup
".scn", // Binary scenes are usually already compressed
- ".stex", // Streamable textures are usually already compressed
+ ".ctex", // Streamable textures are usually already compressed
// Trailer for easier processing
nullptr
};
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index e48016919b..85c8959cf1 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "joypad_uwp.h"
+
#include "core/os/os.h"
using namespace Windows::Gaming::Input;
@@ -45,8 +46,9 @@ void JoypadUWP::process_controllers() {
for (int i = 0; i < MAX_CONTROLLERS; i++) {
ControllerDevice &joy = controllers[i];
- if (!joy.connected)
+ if (!joy.connected) {
break;
+ }
switch (joy.type) {
case ControllerType::GAMEPAD_CONTROLLER: {
@@ -76,8 +78,9 @@ void JoypadUWP::process_controllers() {
}
} else if (joy.vibrating && joy.ff_end_timestamp != 0) {
uint64_t current_time = OS::get_singleton()->get_ticks_usec();
- if (current_time >= joy.ff_end_timestamp)
+ if (current_time >= joy.ff_end_timestamp) {
joypad_vibration_stop(i, current_time);
+ }
}
break;
@@ -87,8 +90,9 @@ void JoypadUWP::process_controllers() {
}
JoypadUWP::JoypadUWP() {
- for (int i = 0; i < MAX_CONTROLLERS; i++)
+ for (int i = 0; i < MAX_CONTROLLERS; i++) {
controllers[i].id = i;
+ }
}
JoypadUWP::JoypadUWP(InputDefault *p_input) {
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index b6dde9c63f..22a54911f9 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -95,12 +95,12 @@ void OS_UWP::set_window_fullscreen(bool p_enabled) {
video_mode.fullscreen = view->IsFullScreenMode;
- if (video_mode.fullscreen == p_enabled)
+ if (video_mode.fullscreen == p_enabled) {
return;
+ }
if (p_enabled) {
video_mode.fullscreen = view->TryEnterFullScreenMode();
-
} else {
view->ExitFullScreenMode();
video_mode.fullscreen = false;
@@ -112,13 +112,15 @@ bool OS_UWP::is_window_fullscreen() const {
}
void OS_UWP::set_keep_screen_on(bool p_enabled) {
- if (is_keep_screen_on() == p_enabled)
+ if (is_keep_screen_on() == p_enabled) {
return;
+ }
- if (p_enabled)
+ if (p_enabled) {
display_request->RequestActive();
- else
+ } else {
display_request->RequestRelease();
+ }
OS::set_keep_screen_on(p_enabled);
}
@@ -150,7 +152,7 @@ void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) {
void OS_UWP::screen_size_changed() {
gl_context->reset();
-};
+}
Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
main_loop = nullptr;
@@ -269,8 +271,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
_ensure_user_data_dir();
- if (is_keep_screen_on())
+ if (is_keep_screen_on()) {
display_request->RequestActive();
+ }
set_keep_screen_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true));
@@ -283,22 +286,24 @@ void OS_UWP::set_clipboard(const String &p_text) {
clip->SetText(ref new Platform::String((LPCWSTR)(p_text.utf16().get_data())));
Clipboard::SetContent(clip);
-};
+}
String OS_UWP::get_clipboard() const {
- if (managed_object->clipboard != nullptr)
+ if (managed_object->clipboard != nullptr) {
return managed_object->clipboard->Data();
- else
+ } else {
return "";
-};
+ }
+}
void OS_UWP::input_event(const Ref<InputEvent> &p_event) {
input->parse_input_event(p_event);
-};
+}
void OS_UWP::delete_main_loop() {
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
}
@@ -308,16 +313,18 @@ void OS_UWP::set_main_loop(MainLoop *p_main_loop) {
}
void OS_UWP::finalize() {
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
rendering_server->finish();
memdelete(rendering_server);
#ifdef GLES3_ENABLED
- if (gl_context)
+ if (gl_context) {
memdelete(gl_context);
+ }
#endif
memdelete(input);
@@ -472,8 +479,9 @@ OS::Time OS_UWP::get_time(bool p_utc) const {
OS::TimeZoneInfo OS_UWP::get_time_zone_info() const {
TIME_ZONE_INFORMATION info;
bool daylight = false;
- if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT)
+ if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) {
daylight = true;
+ }
TimeZoneInfo ret;
if (daylight) {
@@ -507,7 +515,7 @@ uint64_t OS_UWP::get_unix_time() const {
SystemTimeToFileTime(&ep, &fep);
return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
-};
+}
void OS_UWP::delay_usec(uint32_t p_usec) const {
int msec = p_usec < 1000 ? 1 : p_usec / 1000;
@@ -590,8 +598,9 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) {
void OS_UWP::set_cursor_shape(CursorShape p_shape) {
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
- if (cursor_shape == p_shape)
+ if (cursor_shape == p_shape) {
return;
+ }
static const CoreCursorType uwp_cursors[CURSOR_MAX] = {
CoreCursorType::Arrow,
@@ -628,15 +637,15 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) {
return FAILED;
-};
+}
Error OS_UWP::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) {
return FAILED;
-};
+}
Error OS_UWP::kill(const ProcessID &p_pid) {
return FAILED;
-};
+}
Error OS_UWP::set_cwd(const String &p_cwd) {
return FAILED;
@@ -651,11 +660,11 @@ void OS_UWP::set_icon(const Ref<Image> &p_icon) {
bool OS_UWP::has_environment(const String &p_var) const {
return false;
-};
+}
String OS_UWP::get_environment(const String &p_var) const {
return "";
-};
+}
bool OS_UWP::set_environment(const String &p_var, const String &p_value) const {
return false;
@@ -751,8 +760,9 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St
}
void OS_UWP::run() {
- if (!main_loop)
+ if (!main_loop) {
return;
+ }
main_loop->init();
@@ -763,12 +773,14 @@ void OS_UWP::run() {
while (!force_quit) {
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
- if (managed_object->alert_close_handle)
+ if (managed_object->alert_close_handle) {
continue;
+ }
process_events(); // get rid of pending events
- if (Main::iteration())
+ if (Main::iteration()) {
break;
- };
+ }
+ }
main_loop->finish();
}
diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp
index 5064f6b97f..3b2c6fe9f6 100644
--- a/platform/windows/crash_handler_windows.cpp
+++ b/platform/windows/crash_handler_windows.cpp
@@ -80,8 +80,9 @@ public:
std::string name() { return std::string(sym->Name); }
std::string undecorated_name() {
- if (*sym->Name == '\0')
+ if (*sym->Name == '\0') {
return "<couldn't map PC to fn name>";
+ }
std::vector<char> und_name(max_name_len);
UnDecorateSymbolName(sym->Name, &und_name[0], max_name_len, UNDNAME_COMPLETE);
return std::string(&und_name[0], strlen(&und_name[0]));
@@ -131,12 +132,14 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
fprintf(stderr, "\n================================================================\n");
fprintf(stderr, "%s: Program crashed\n", __FUNCTION__);
- if (OS::get_singleton()->get_main_loop())
+ if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
+ }
// Load the symbols:
- if (!SymInitialize(process, nullptr, false))
+ if (!SymInitialize(process, nullptr, false)) {
return EXCEPTION_CONTINUE_SEARCH;
+ }
SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
EnumProcessModules(process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cbNeeded);
@@ -193,18 +196,21 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
if (frame.AddrPC.Offset != 0) {
std::string fnName = symbol(process, frame.AddrPC.Offset).undecorated_name();
- if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line))
+ if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) {
fprintf(stderr, "[%d] %s (%s:%d)\n", n, fnName.c_str(), line.FileName, line.LineNumber);
- else
+ } else {
fprintf(stderr, "[%d] %s\n", n, fnName.c_str());
- } else
+ }
+ } else {
fprintf(stderr, "[%d] ???\n", n);
+ }
n++;
}
- if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr))
+ if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) {
break;
+ }
} while (frame.AddrReturn.Offset != 0 && n < 256);
fprintf(stderr, "-- END OF BACKTRACE --\n");
@@ -225,8 +231,9 @@ CrashHandler::~CrashHandler() {
}
void CrashHandler::disable() {
- if (disabled)
+ if (disabled) {
return;
+ }
disabled = true;
}
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 20268b3f6a..e1ab2d1c83 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -231,7 +231,7 @@ String DisplayServerWindows::clipboard_get() const {
String ret;
if (!OpenClipboard(windows[last_focused_window].hWnd)) {
ERR_FAIL_V_MSG("", "Unable to open clipboard.");
- };
+ }
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
@@ -240,8 +240,8 @@ String DisplayServerWindows::clipboard_get() const {
if (ptr != nullptr) {
ret = String::utf16((const char16_t *)ptr);
GlobalUnlock(mem);
- };
- };
+ }
+ }
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
@@ -250,9 +250,9 @@ String DisplayServerWindows::clipboard_get() const {
if (ptr != nullptr) {
ret.parse_utf8((const char *)ptr);
GlobalUnlock(mem);
- };
- };
- };
+ }
+ }
+ }
CloseClipboard();
@@ -422,8 +422,9 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr;
if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) {
- if (Shcore)
+ if (Shcore) {
FreeLibrary(Shcore);
+ }
Shcore = (HMODULE)INVALID_HANDLE_VALUE;
}
}
@@ -545,6 +546,9 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod
if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) {
wd.no_focus = true;
}
+ if (p_flags & WINDOW_FLAG_POPUP_BIT) {
+ wd.is_popup = true;
+ }
// Inherit icons from MAIN_WINDOW for all sub windows.
HICON mainwindow_icon = (HICON)SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_GETICON, ICON_SMALL, 0);
@@ -562,13 +566,14 @@ void DisplayServerWindows::show_window(WindowID p_id) {
ERR_FAIL_COND(!windows.has(p_id));
WindowData &wd = windows[p_id];
+ popup_open(p_id);
if (p_id != MAIN_WINDOW_ID) {
_update_window_style(p_id);
}
- ShowWindow(wd.hWnd, wd.no_focus ? SW_SHOWNOACTIVATE : SW_SHOW); // Show the window.
- if (!wd.no_focus) {
+ ShowWindow(wd.hWnd, (wd.no_focus || wd.is_popup) ? SW_SHOWNOACTIVATE : SW_SHOW); // Show the window.
+ if (!wd.no_focus && !wd.is_popup) {
SetForegroundWindow(wd.hWnd); // Slightly higher priority.
SetFocus(wd.hWnd); // Set keyboard focus.
}
@@ -580,6 +585,8 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window));
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window cannot be deleted.");
+ popup_close(p_window);
+
WindowData &wd = windows[p_window];
while (wd.transient_children.size()) {
@@ -830,6 +837,23 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window
_update_real_mouse_position(p_window);
}
+void DisplayServerWindows::window_set_exclusive(WindowID p_window, bool p_exclusive) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ if (wd.exclusive != p_exclusive) {
+ wd.exclusive = p_exclusive;
+ if (wd.transient_parent != INVALID_WINDOW_ID) {
+ WindowData &wd_parent = windows[wd.transient_parent];
+ if (wd.exclusive) {
+ SetWindowLongPtr(wd.hWnd, GWLP_HWNDPARENT, (LONG_PTR)wd_parent.hWnd);
+ } else {
+ SetWindowLongPtr(wd.hWnd, GWLP_HWNDPARENT, (LONG_PTR) nullptr);
+ }
+ }
+ }
+}
+
void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_parent) {
_THREAD_SAFE_METHOD_
@@ -852,7 +876,9 @@ void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_pa
wd_window.transient_parent = INVALID_WINDOW_ID;
wd_parent.transient_children.erase(p_window);
- SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR) nullptr);
+ if (wd_window.exclusive) {
+ SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR) nullptr);
+ }
} else {
ERR_FAIL_COND(!windows.has(p_parent));
ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
@@ -861,7 +887,9 @@ void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_pa
wd_window.transient_parent = p_parent;
wd_parent.transient_children.insert(p_window);
- SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR)wd_parent.hWnd);
+ if (wd_window.exclusive) {
+ SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR)wd_parent.hWnd);
+ }
}
}
@@ -997,6 +1025,7 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
r_style_ex = WS_EX_WINDOWEDGE;
if (p_main_window) {
r_style_ex |= WS_EX_APPWINDOW;
+ r_style |= WS_VISIBLE;
}
if (p_fullscreen || p_borderless) {
@@ -1015,14 +1044,17 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU;
}
}
- if (!p_borderless) {
- r_style |= WS_VISIBLE;
- }
if (p_no_activate_focus) {
r_style_ex |= WS_EX_TOPMOST | WS_EX_NOACTIVATE;
}
+
+ if (!p_borderless && !p_no_activate_focus) {
+ r_style |= WS_VISIBLE;
+ }
+
r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ r_style_ex |= WS_EX_ACCEPTFILES;
}
void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint) {
@@ -1034,12 +1066,12 @@ void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repain
DWORD style = 0;
DWORD style_ex = 0;
- _get_window_style(p_window == MAIN_WINDOW_ID, wd.fullscreen, wd.multiwindow_fs, wd.borderless, wd.resizable, wd.maximized, wd.no_focus, style, style_ex);
+ _get_window_style(p_window == MAIN_WINDOW_ID, wd.fullscreen, wd.multiwindow_fs, wd.borderless, wd.resizable, wd.maximized, wd.no_focus || wd.is_popup, style, style_ex);
SetWindowLongPtr(wd.hWnd, GWL_STYLE, style);
SetWindowLongPtr(wd.hWnd, GWL_EXSTYLE, style_ex);
- SetWindowPos(wd.hWnd, wd.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | (wd.no_focus ? SWP_NOACTIVATE : 0));
+ SetWindowPos(wd.hWnd, wd.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | ((wd.no_focus || wd.is_popup) ? SWP_NOACTIVATE : 0));
if (p_repaint) {
RECT rect;
@@ -1099,10 +1131,10 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
if (p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
wd.multiwindow_fs = false;
- _update_window_style(false);
+ _update_window_style(p_window, false);
} else {
wd.multiwindow_fs = true;
- _update_window_style(false);
+ _update_window_style(p_window, false);
}
if ((p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) && !wd.fullscreen) {
@@ -1123,7 +1155,7 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
wd.maximized = false;
wd.minimized = false;
- _update_window_style(false);
+ _update_window_style(p_window, false);
MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
@@ -1190,6 +1222,7 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
wd.borderless = p_enabled;
_update_window_style(p_window);
_update_window_mouse_passthrough(p_window);
+ ShowWindow(wd.hWnd, (wd.no_focus || wd.is_popup) ? SW_SHOWNOACTIVATE : SW_SHOW); // Show the window.
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID && p_enabled, "Transient windows can't become on top");
@@ -1203,6 +1236,11 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
wd.no_focus = p_enabled;
_update_window_style(p_window);
} break;
+ case WINDOW_FLAG_POPUP: {
+ ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
+ ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
+ wd.is_popup = p_enabled;
+ } break;
case WINDOW_FLAG_MAX:
break;
}
@@ -1229,6 +1267,9 @@ bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window
case WINDOW_FLAG_NO_FOCUS: {
return wd.no_focus;
} break;
+ case WINDOW_FLAG_POPUP: {
+ return wd.is_popup;
+ } break;
case WINDOW_FLAG_MAX:
break;
}
@@ -1257,7 +1298,9 @@ void DisplayServerWindows::window_move_to_foreground(WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
- SetForegroundWindow(wd.hWnd);
+ if (!wd.no_focus && !wd.is_popup) {
+ SetForegroundWindow(wd.hWnd);
+ }
}
bool DisplayServerWindows::window_can_draw(WindowID p_window) const {
@@ -1304,8 +1347,9 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI
wd.im_position = p_pos;
HIMC himc = ImmGetContext(wd.hWnd);
- if (himc == (HIMC)0)
+ if (himc == (HIMC)0) {
return;
+ }
COMPOSITIONFORM cps;
cps.dwStyle = CFS_FORCE_POSITION;
@@ -1873,16 +1917,14 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
void DisplayServerWindows::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
_THREAD_SAFE_METHOD_
#if defined(VULKAN_ENABLED)
- // TODO disabling for now
- //context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
+ context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
#endif
}
DisplayServer::VSyncMode DisplayServerWindows::window_get_vsync_mode(WindowID p_window) const {
_THREAD_SAFE_METHOD_
#if defined(VULKAN_ENABLED)
- //TODO disabling for now
- //return context_vulkan->get_vsync_mode(p_window);
+ return context_vulkan->get_vsync_mode(p_window);
#endif
return DisplayServer::VSYNC_ENABLED;
}
@@ -1967,33 +2009,145 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event)
Variant ret;
Callable::CallError ce;
+ {
+ List<WindowID>::Element *E = popup_list.front();
+ if (E && Object::cast_to<InputEventKey>(*p_event)) {
+ // Redirect keyboard input to active popup.
+ if (windows.has(E->get())) {
+ Callable callable = windows[E->get()].input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ }
+ in_dispatch_input_event = false;
+ return;
+ }
+ }
+
Ref<InputEventFromWindow> event_from_window = p_event;
if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
// Send to a single window.
- if (!windows.has(event_from_window->get_window_id())) {
- in_dispatch_input_event = false;
- ERR_FAIL_MSG("DisplayServerWindows: Invalid window id in input event.");
- }
- Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
- if (callable.is_null()) {
- in_dispatch_input_event = false;
- return;
+ if (windows.has(event_from_window->get_window_id())) {
+ Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
}
- callable.call((const Variant **)&evp, 1, ret, ce);
} else {
// Send to all windows.
for (const KeyValue<WindowID, WindowData> &E : windows) {
const Callable callable = E.value.input_event_callback;
- if (callable.is_null()) {
- continue;
+ if (callable.is_valid()) {
+ callable.call((const Variant **)&evp, 1, ret, ce);
}
- callable.call((const Variant **)&evp, 1, ret, ce);
}
}
in_dispatch_input_event = false;
}
+LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam) {
+ DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());
+ if (ds_win) {
+ return ds_win->MouseProc(code, wParam, lParam);
+ } else {
+ return ::CallNextHookEx(nullptr, code, wParam, lParam);
+ }
+}
+
+DisplayServer::WindowID DisplayServerWindows::window_get_active_popup() const {
+ const List<WindowID>::Element *E = popup_list.back();
+ if (E) {
+ return E->get();
+ } else {
+ return INVALID_WINDOW_ID;
+ }
+}
+
+void DisplayServerWindows::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.parent_safe_rect = p_rect;
+}
+
+Rect2i DisplayServerWindows::window_get_popup_safe_rect(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Rect2i());
+ const WindowData &wd = windows[p_window];
+ return wd.parent_safe_rect;
+}
+
+void DisplayServerWindows::popup_open(WindowID p_window) {
+ WindowData &wd = windows[p_window];
+ if (wd.is_popup) {
+ // Close all popups, up to current popup parent, or every popup if new window is not transient.
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ if (wd.transient_parent != E->get() || wd.transient_parent == INVALID_WINDOW_ID) {
+ _send_window_event(windows[E->get()], DisplayServerWindows::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ } else {
+ break;
+ }
+ }
+
+ time_since_popup = OS::get_singleton()->get_ticks_msec();
+ popup_list.push_back(p_window);
+ }
+}
+
+void DisplayServerWindows::popup_close(WindowID p_window) {
+ List<WindowID>::Element *E = popup_list.find(p_window);
+ while (E) {
+ _send_window_event(windows[E->get()], DisplayServerWindows::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->next();
+ popup_list.erase(E);
+ E = F;
+ }
+}
+
+LRESULT DisplayServerWindows::MouseProc(int code, WPARAM wParam, LPARAM lParam) {
+ _THREAD_SAFE_METHOD_
+ uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_popup;
+ if (delta > 250) {
+ switch (wParam) {
+ case WM_NCLBUTTONDOWN:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCMBUTTONDOWN:
+ case WM_LBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_MBUTTONDOWN: {
+ MOUSEHOOKSTRUCT *ms = (MOUSEHOOKSTRUCT *)lParam;
+ Point2i pos = Point2i(ms->pt.x, ms->pt.y);
+ List<WindowID>::Element *E = popup_list.back();
+ while (E) {
+ // Popup window area.
+ Rect2i win_rect = Rect2i(window_get_position(E->get()), window_get_size(E->get()));
+ // Area of the parent window, which responsible for opening sub-menu.
+ Rect2i safe_rect = window_get_popup_safe_rect(E->get());
+ if (win_rect.has_point(pos)) {
+ break;
+ } else if (safe_rect != Rect2i() && safe_rect.has_point(pos)) {
+ break;
+ } else {
+ _send_window_event(windows[E->get()], DisplayServerWindows::WINDOW_EVENT_CLOSE_REQUEST);
+ List<WindowID>::Element *F = E->prev();
+ popup_list.erase(E);
+ E = F;
+ }
+ }
+
+ } break;
+ }
+ }
+ return ::CallNextHookEx(mouse_monitor, code, wParam, lParam);
+}
+
// Our default window procedure to handle processing of window-related system messages/events.
// Also known as DefProc or DefWindowProc.
// See: https://docs.microsoft.com/en-us/windows/win32/winmsg/window-procedures
@@ -2004,7 +2158,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} else {
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
- };
+ }
WindowID window_id = INVALID_WINDOW_ID;
bool window_created = false;
@@ -2026,6 +2180,13 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
// Process window messages.
switch (uMsg) {
+ case WM_MOUSEACTIVATE: {
+ if (windows[window_id].no_focus) {
+ return MA_NOACTIVATEANDEAT; // Do not activate, and discard mouse messages.
+ } else if (windows[window_id].is_popup) {
+ return MA_NOACTIVATE; // Do not activate, but process mouse messages.
+ }
+ } break;
case WM_SETFOCUS: {
windows[window_id].window_has_focus = true;
last_focused_window = window_id;
@@ -2109,8 +2270,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case SC_MONITORPOWER: // Monitor trying to enter powersave?
return 0; // Prevent from happening.
case SC_KEYMENU:
- if ((lParam >> 16) <= 0)
+ if ((lParam >> 16) <= 0) {
return 0;
+ }
}
} break;
case WM_CLOSE: // Did we receive a close message?
@@ -2142,8 +2304,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0;
}
- if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
+ if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
+ }
RAWINPUT *raw = (RAWINPUT *)lpb;
@@ -2238,8 +2401,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
ScreenToClient(windows[window_id].hWnd, &coords);
// Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
- if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
+ if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) {
break;
+ }
Ref<InputEventMouseMotion> mm;
mm.instantiate();
@@ -2284,8 +2448,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
old_x = mm->get_position().x;
old_y = mm->get_position().y;
- if (windows[window_id].window_has_focus)
+ if (windows[window_id].window_has_focus || window_get_active_popup() == window_id) {
Input::get_singleton()->parse_input_event(mm);
+ }
}
return 0;
}
@@ -2425,7 +2590,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
old_x = mm->get_position().x;
old_y = mm->get_position().y;
- if (windows[window_id].window_has_focus) {
+ if (windows[window_id].window_has_focus || window_get_active_popup() == window_id) {
Input::get_singleton()->parse_input_event(mm);
}
@@ -2525,8 +2690,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
old_x = mm->get_position().x;
old_y = mm->get_position().y;
- if (windows[window_id].window_has_focus)
+ if (windows[window_id].window_has_focus || window_get_active_popup() == window_id) {
Input::get_singleton()->parse_input_event(mm);
+ }
} break;
case WM_LBUTTONDOWN:
@@ -2672,8 +2838,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
if (mb->is_pressed()) {
- if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED)
+ if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) {
SetCapture(hWnd);
+ }
} else {
if (--pressrc <= 0) {
if (mouse_mode != MOUSE_MODE_CAPTURED) {
@@ -2748,13 +2915,14 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
window.width = window_client_rect.size.width;
window.height = window_client_rect.size.height;
-#if defined(VULKAN_ENABLED)
- if (context_vulkan && window_created) {
- context_vulkan->window_resize(window_id, window.width, window.height);
- }
-#endif
rect_changed = true;
}
+#if defined(VULKAN_ENABLED)
+ if (context_vulkan && window_created) {
+ // Note: Trigger resize event to update swapchains when window is minimized/restored, even if size is not changed.
+ context_vulkan->window_resize(window_id, window.width, window.height);
+ }
+#endif
}
if (!window.minimized && (!(window_pos_params->flags & SWP_NOMOVE) || window_pos_params->flags & SWP_FRAMECHANGED)) {
@@ -2801,14 +2969,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_SYSKEYUP:
case WM_KEYUP:
case WM_KEYDOWN: {
- if (wParam == VK_SHIFT)
+ if (wParam == VK_SHIFT) {
shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
- if (wParam == VK_CONTROL)
+ }
+ if (wParam == VK_CONTROL) {
control_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
+ }
if (wParam == VK_MENU) {
alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
- if (lParam & (1 << 24))
+ if (lParam & (1 << 24)) {
gr_mem = alt_mem;
+ }
}
if (mouse_mode == MOUSE_MODE_CAPTURED) {
@@ -2817,10 +2988,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
_send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
}
}
- /*
- if (wParam==VK_WIN) TODO wtf is this?
- meta_mem=uMsg==WM_KEYDOWN;
- */
[[fallthrough]];
}
case WM_CHAR: {
@@ -2835,10 +3002,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
ke.uMsg = uMsg;
ke.window_id = window_id;
- if (ke.uMsg == WM_SYSKEYDOWN)
+ if (ke.uMsg == WM_SYSKEYDOWN) {
ke.uMsg = WM_KEYDOWN;
- if (ke.uMsg == WM_SYSKEYUP)
+ }
+ if (ke.uMsg == WM_SYSKEYUP) {
ke.uMsg = WM_KEYUP;
+ }
ke.wParam = wParam;
ke.lParam = lParam;
@@ -2866,7 +3035,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
_drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID);
} else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) {
_touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);
- };
+ }
}
bHandled = TRUE;
} else {
@@ -2879,7 +3048,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (bHandled) {
CloseTouchInputHandle((HTOUCHINPUT)lParam);
return 0;
- };
+ }
} break;
case WM_DEVICECHANGE: {
@@ -2933,8 +3102,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
default: {
if (user_proc) {
return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
- };
- };
+ }
+ }
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
@@ -2942,10 +3111,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());
- if (ds_win)
+ if (ds_win) {
return ds_win->WndProc(hWnd, uMsg, wParam, lParam);
- else
+ } else {
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
}
void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM wParam, LPARAM lParam) {
@@ -3012,8 +3182,9 @@ void DisplayServerWindows::_process_key_events() {
k->set_ctrl_pressed(false);
}
- if (k->get_unicode() < 32)
+ if (k->get_unicode() < 32) {
k->set_unicode(0);
+ }
Input::get_singleton()->parse_input_event(k);
} else {
@@ -3068,8 +3239,9 @@ void DisplayServerWindows::_process_key_events() {
k->set_ctrl_pressed(false);
}
- if (k->get_unicode() < 32)
+ if (k->get_unicode() < 32) {
k->set_unicode(0);
+ }
k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
@@ -3373,7 +3545,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
wc.cbWndExtra = 0;
wc.hInstance = hInstance ? hInstance : GetModuleHandle(nullptr);
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
- wc.hCursor = nullptr; //LoadCursor(nullptr, IDC_ARROW);
+ wc.hCursor = nullptr;
wc.hbrBackground = nullptr;
wc.lpszMenuName = nullptr;
wc.lpszClassName = L"Engine";
@@ -3424,11 +3596,13 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
return;
}
- // gl_manager->set_use_vsync(current_videomode.use_vsync);
+ //gl_manager->set_use_vsync(current_videomode.use_vsync);
RasterizerGLES3::make_current();
}
#endif
+ HHOOK mouse_monitor = SetWindowsHookEx(WH_MOUSE, ::MouseProc, nullptr, GetCurrentThreadId());
+
Point2i window_position(
(screen_get_size(0).width - p_resolution.width) / 2,
(screen_get_size(0).height - p_resolution.height) / 2);
@@ -3454,14 +3628,13 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
#endif
- //set_ime_active(false);
-
if (!OS::get_singleton()->is_in_low_processor_usage_mode()) {
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
DWORD index = 0;
HANDLE handle = AvSetMmThreadCharacteristics("Games", &index);
- if (handle)
+ if (handle) {
AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL);
+ }
// This is needed to make sure that background work does not starve the main thread.
// This is only setting the priority of this thread, not the whole process.
@@ -3513,12 +3686,16 @@ DisplayServerWindows::~DisplayServerWindows() {
cursors_cache.clear();
+ if (mouse_monitor) {
+ UnhookWindowsHookEx(mouse_monitor);
+ }
+
if (user_proc) {
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
- };
+ }
#ifdef GLES3_ENABLED
- // destroy windows .. NYI?
+ // destroy windows .. NYI?
#endif
if (windows.has(MAIN_WINDOW_ID)) {
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index d36ca97ebe..a56a2b83ac 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -339,6 +339,7 @@ class DisplayServerWindows : public DisplayServer {
bool always_on_top = false;
bool no_focus = false;
bool window_has_focus = false;
+ bool exclusive = false;
// Used to transfer data between events using timer.
WPARAM saved_wparam;
@@ -386,9 +387,15 @@ class DisplayServerWindows : public DisplayServer {
WindowID transient_parent = INVALID_WINDOW_ID;
Set<WindowID> transient_children;
+
+ bool is_popup = false;
+ Rect2i parent_safe_rect;
};
JoypadWindows *joypad;
+ HHOOK mouse_monitor = nullptr;
+ List<WindowID> popup_list;
+ uint64_t time_since_popup = 0;
WindowID _create_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect);
WindowID window_id_counter = MAIN_WINDOW_ID;
@@ -439,6 +446,10 @@ class DisplayServerWindows : public DisplayServer {
public:
LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ LRESULT MouseProc(int code, WPARAM wParam, LPARAM lParam);
+
+ void popup_open(WindowID p_window);
+ void popup_close(WindowID p_window);
virtual bool has_feature(Feature p_feature) const override;
virtual String get_name() const override;
@@ -473,6 +484,10 @@ public:
virtual void show_window(WindowID p_window) override;
virtual void delete_sub_window(WindowID p_window) override;
+ virtual WindowID window_get_active_popup() const override;
+ virtual void window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) override;
+ virtual Rect2i window_get_popup_safe_rect(WindowID p_window) const override;
+
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
@@ -499,6 +514,7 @@ public:
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
+ virtual void window_set_exclusive(WindowID p_window, bool p_exclusive) override;
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index d30d0afc5c..5ebc930735 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -30,6 +30,9 @@
#include "export_plugin.h"
+#include "core/config/project_settings.h"
+#include "editor/editor_node.h"
+
Error EditorExportPlatformWindows::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
if (p_preset->get("codesign/enable")) {
return _code_sign(p_preset, p_path);
diff --git a/platform/windows/export/export_plugin.h b/platform/windows/export/export_plugin.h
index 89e5b1b635..86e9d49b05 100644
--- a/platform/windows/export/export_plugin.h
+++ b/platform/windows/export/export_plugin.h
@@ -34,7 +34,6 @@
#include "core/io/file_access.h"
#include "core/os/os.h"
#include "editor/editor_export.h"
-#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "platform/windows/logo.gen.h"
diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp
index 74b5f48502..a97fa99d7f 100644
--- a/platform/windows/gl_manager_windows.cpp
+++ b/platform/windows/gl_manager_windows.cpp
@@ -56,14 +56,9 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int
int GLManager_Windows::_find_or_create_display(GLWindow &win) {
// find display NYI, only 1 supported so far
- if (_displays.size())
+ if (_displays.size()) {
return 0;
-
- // for (unsigned int n = 0; n < _displays.size(); n++) {
- // const GLDisplay &d = _displays[n];
- // if (d.x11_display == p_x11_display)
- // return n;
- // }
+ }
// create
GLDisplay d_temp = {};
@@ -230,23 +225,27 @@ void GLManager_Windows::window_destroy(DisplayServer::WindowID p_window_id) {
}
void GLManager_Windows::release_current() {
- if (!_current_window)
+ if (!_current_window) {
return;
+ }
wglMakeCurrent(_current_window->hDC, nullptr);
}
void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) {
- if (p_window_id == -1)
+ if (p_window_id == -1) {
return;
+ }
GLWindow &win = _windows[p_window_id];
- if (!win.in_use)
+ if (!win.in_use) {
return;
+ }
// noop
- if (&win == _current_window)
+ if (&win == _current_window) {
return;
+ }
const GLDisplay &disp = get_display(win.gldisplay_id);
wglMakeCurrent(win.hDC, disp.hRC);
@@ -255,8 +254,9 @@ void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id)
}
void GLManager_Windows::make_current() {
- if (!_current_window)
+ if (!_current_window) {
return;
+ }
if (!_current_window->in_use) {
WARN_PRINT("current window not in use!");
return;
@@ -269,8 +269,9 @@ void GLManager_Windows::swap_buffers() {
// NO NEED TO CALL SWAP BUFFERS for each window...
// see https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXSwapBuffers.xml
- if (!_current_window)
+ if (!_current_window) {
return;
+ }
if (!_current_window->in_use) {
WARN_PRINT("current window not in use!");
return;
@@ -304,12 +305,15 @@ void GLManager_Windows::set_use_vsync(bool p_use) {
if (!setup) {
setup = true;
String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
- if (extensions.find("GLX_EXT_swap_control") != -1)
+ if (extensions.find("GLX_EXT_swap_control") != -1) {
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT");
- if (extensions.find("GLX_MESA_swap_control") != -1)
+ }
+ if (extensions.find("GLX_MESA_swap_control") != -1) {
glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA");
- if (extensions.find("GLX_SGI_swap_control") != -1)
+ }
+ if (extensions.find("GLX_SGI_swap_control") != -1) {
glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI");
+ }
}
int val = p_use ? 1 : 0;
if (glXSwapIntervalMESA) {
@@ -319,8 +323,9 @@ void GLManager_Windows::set_use_vsync(bool p_use) {
} else if (glXSwapIntervalEXT) {
GLXDrawable drawable = glXGetCurrentDrawable();
glXSwapIntervalEXT(x11_display, drawable, val);
- } else
+ } else {
return;
+ }
use_vsync = p_use;
*/
}
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index 618d5670d2..ad4e3ae77c 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -163,8 +163,9 @@ int widechar_main(int argc, wchar_t **argv) {
return 255;
}
- if (Main::start())
+ if (Main::start()) {
os.run();
+ }
Main::cleanup();
for (int i = 0; i < argc; ++i) {
@@ -173,7 +174,7 @@ int widechar_main(int argc, wchar_t **argv) {
delete[] argv_utf8;
return os.get_exit_code();
-};
+}
int _main() {
LPWSTR *wc_argv;
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index b0dd86a4b7..494e0b9105 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -60,8 +60,9 @@ JoypadWindows::JoypadWindows(HWND *hwnd) {
load_xinput();
- for (int i = 0; i < JOYPADS_MAX; i++)
+ for (int i = 0; i < JOYPADS_MAX; i++) {
attached_joypads[i] = false;
+ }
HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr);
if (result == DI_OK) {
@@ -144,8 +145,9 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
HRESULT hr;
int num = input->get_unused_joy_id();
- if (have_device(instance->guidInstance) || num == -1)
+ if (have_device(instance->guidInstance) || num == -1) {
return false;
+ }
d_joypads[num] = dinput_gamepad();
dinput_gamepad *joy = &d_joypads[num];
@@ -196,27 +198,28 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
DIPROPRANGE prop_range;
DIPROPDWORD dilong;
LONG ofs;
- if (ob->guidType == GUID_XAxis)
+ if (ob->guidType == GUID_XAxis) {
ofs = DIJOFS_X;
- else if (ob->guidType == GUID_YAxis)
+ } else if (ob->guidType == GUID_YAxis) {
ofs = DIJOFS_Y;
- else if (ob->guidType == GUID_ZAxis)
+ } else if (ob->guidType == GUID_ZAxis) {
ofs = DIJOFS_Z;
- else if (ob->guidType == GUID_RxAxis)
+ } else if (ob->guidType == GUID_RxAxis) {
ofs = DIJOFS_RX;
- else if (ob->guidType == GUID_RyAxis)
+ } else if (ob->guidType == GUID_RyAxis) {
ofs = DIJOFS_RY;
- else if (ob->guidType == GUID_RzAxis)
+ } else if (ob->guidType == GUID_RzAxis) {
ofs = DIJOFS_RZ;
- else if (ob->guidType == GUID_Slider) {
+ } else if (ob->guidType == GUID_Slider) {
if (slider_count < 2) {
ofs = DIJOFS_SLIDER(slider_count);
slider_count++;
} else {
return;
}
- } else
+ } else {
return;
+ }
prop_range.diph.dwSize = sizeof(DIPROPRANGE);
prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
prop_range.diph.dwObj = ob->dwType;
@@ -227,8 +230,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
dinput_gamepad &joy = d_joypads[p_joy_id];
res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_RANGE, &prop_range.diph);
- if (FAILED(res))
+ if (FAILED(res)) {
return;
+ }
dilong.diph.dwSize = sizeof(dilong);
dilong.diph.dwHeaderSize = sizeof(dilong.diph);
@@ -237,8 +241,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
dilong.dwData = 0;
res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_DEADZONE, &dilong.diph);
- if (FAILED(res))
+ if (FAILED(res)) {
return;
+ }
joy.joy_axis.push_back(ofs);
}
@@ -268,8 +273,9 @@ void JoypadWindows::close_joypad(int id) {
return;
}
- if (!d_joypads[id].attached)
+ if (!d_joypads[id].attached) {
return;
+ }
d_joypads[id].di_joy->Unacquire();
d_joypads[id].di_joy->Release();
@@ -355,16 +361,18 @@ void JoypadWindows::process_joypads() {
}
} else if (joy.vibrating && joy.ff_end_timestamp != 0) {
uint64_t current_time = OS::get_singleton()->get_ticks_usec();
- if (current_time >= joy.ff_end_timestamp)
+ if (current_time >= joy.ff_end_timestamp) {
joypad_vibration_stop_xinput(i, current_time);
+ }
}
}
for (int i = 0; i < JOYPADS_MAX; i++) {
dinput_gamepad *joy = &d_joypads[i];
- if (!joy->attached)
+ if (!joy->attached) {
continue;
+ }
DIJOYSTATE2 js;
hr = joy->di_joy->Poll();
@@ -404,9 +412,9 @@ void JoypadWindows::process_joypads() {
if (joy->joy_axis[j] == axes[k]) {
input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k]));
break;
- };
- };
- };
+ }
+ }
+ }
}
return;
}
@@ -446,7 +454,7 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
dpad_val = (HatMask)(HatMask::LEFT | HatMask::UP);
}
input->joy_hat(p_device, dpad_val);
-};
+}
float JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
if (Math::abs(p_val) < MIN_JOY_AXIS) {
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index 0e3d03fa52..4f15bcf080 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -86,8 +86,9 @@ private:
attached = false;
confirmed = false;
- for (int i = 0; i < MAX_JOY_BUTTONS; i++)
+ for (int i = 0; i < MAX_JOY_BUTTONS; i++) {
last_buttons[i] = false;
+ }
}
};
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index d844531071..13e3aa7883 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -46,6 +46,7 @@
#include "windows_terminal_logger.h"
#include <avrt.h>
+#include <bcrypt.h>
#include <direct.h>
#include <knownfolders.h>
#include <process.h>
@@ -106,8 +107,9 @@ void RedirectIOToConsole() {
}
BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) {
- if (!EngineDebugger::is_active())
+ if (!EngineDebugger::is_active()) {
return FALSE;
+ }
switch (dwCtrlType) {
case CTRL_C_EVENT:
@@ -165,8 +167,9 @@ void OS_Windows::initialize() {
}
void OS_Windows::delete_main_loop() {
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
}
@@ -179,8 +182,9 @@ void OS_Windows::finalize() {
driver_midi.close();
#endif
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
}
@@ -192,6 +196,12 @@ void OS_Windows::finalize_core() {
NetSocketPosix::cleanup();
}
+Error OS_Windows::get_entropy(uint8_t *r_buffer, int p_bytes) {
+ NTSTATUS status = BCryptGenRandom(nullptr, r_buffer, p_bytes, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ERR_FAIL_COND_V(status, FAILED);
+ return OK;
+}
+
Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
String path = p_path.replace("/", "\\");
@@ -281,8 +291,9 @@ OS::Time OS_Windows::get_time(bool p_utc) const {
OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
TIME_ZONE_INFORMATION info;
bool daylight = false;
- if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT)
+ if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) {
daylight = true;
+ }
TimeZoneInfo ret;
if (daylight) {
@@ -315,10 +326,11 @@ double OS_Windows::get_unix_time() const {
}
void OS_Windows::delay_usec(uint32_t p_usec) const {
- if (p_usec < 1000)
+ if (p_usec < 1000) {
Sleep(1);
- else
+ } else {
Sleep(p_usec / 1000);
+ }
}
uint64_t OS_Windows::get_ticks_usec() const {
@@ -423,7 +435,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
if (p_pipe_mutex) {
p_pipe_mutex->unlock();
}
- };
+ }
CloseHandle(pipe[0]); // Close pipe read handle.
} else {
WaitForSingleObject(pi.pi.hProcess, INFINITE);
@@ -439,7 +451,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
CloseHandle(pi.pi.hThread);
return OK;
-};
+}
Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) {
String path = p_path.replace("/", "\\");
@@ -471,7 +483,7 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg
process_map->insert(pid, pi);
return OK;
-};
+}
Error OS_Windows::kill(const ProcessID &p_pid) {
ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED);
@@ -485,15 +497,16 @@ Error OS_Windows::kill(const ProcessID &p_pid) {
CloseHandle(pi.hThread);
return ret != 0 ? OK : FAILED;
-};
+}
int OS_Windows::get_process_id() const {
return _getpid();
}
Error OS_Windows::set_cwd(const String &p_cwd) {
- if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0)
+ if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) {
return ERR_CANT_OPEN;
+ }
return OK;
}
@@ -516,7 +529,7 @@ bool OS_Windows::has_environment(const String &p_var) const {
free(env);
return has_env;
#endif
-};
+}
String OS_Windows::get_environment(const String &p_var) const {
WCHAR wval[0x7fff]; // MSDN says 32767 char is the maximum
@@ -535,7 +548,7 @@ String OS_Windows::get_stdin_string(bool p_block) {
if (p_block) {
char buff[1024];
return fgets(buff, 1024, stdin);
- };
+ }
return String();
}
@@ -573,17 +586,20 @@ String OS_Windows::get_locale() const {
int sublang = SUBLANGID(langid);
while (wl->locale) {
- if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL)
+ if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL) {
neutral = wl->locale;
+ }
- if (lang == wl->main_lang && sublang == wl->sublang)
+ if (lang == wl->main_lang && sublang == wl->sublang) {
return String(wl->locale).replace("-", "_");
+ }
wl++;
}
- if (!neutral.is_empty())
+ if (!neutral.is_empty()) {
return String(neutral).replace("-", "_");
+ }
return "en";
}
@@ -610,25 +626,48 @@ BOOL is_wow64() {
int OS_Windows::get_processor_count() const {
SYSTEM_INFO sysinfo;
- if (is_wow64())
+ if (is_wow64()) {
GetNativeSystemInfo(&sysinfo);
- else
+ } else {
GetSystemInfo(&sysinfo);
+ }
return sysinfo.dwNumberOfProcessors;
}
+String OS_Windows::get_processor_name() const {
+ const String id = "Hardware\\Description\\System\\CentralProcessor\\0";
+
+ HKEY hkey;
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCWSTR)(id.utf16().get_data()), 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) {
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+ }
+
+ WCHAR buffer[256];
+ DWORD buffer_len = 256;
+ DWORD vtype = REG_SZ;
+ if (RegQueryValueExW(hkey, L"ProcessorNameString", NULL, &vtype, (LPBYTE)buffer, &buffer_len) == ERROR_SUCCESS) {
+ RegCloseKey(hkey);
+ return String::utf16((const char16_t *)buffer, buffer_len).strip_edges();
+ } else {
+ RegCloseKey(hkey);
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+ }
+}
+
void OS_Windows::run() {
- if (!main_loop)
+ if (!main_loop) {
return;
+ }
main_loop->initialize();
while (!force_quit) {
DisplayServer::get_singleton()->process_events(); // get rid of pending events
- if (Main::iteration())
+ if (Main::iteration()) {
break;
- };
+ }
+ }
main_loop->finalize();
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 28baa855b4..5bfd24327e 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -40,8 +40,6 @@
#include "drivers/winmidi/midi_driver_winmidi.h"
#include "key_mapping_windows.h"
#include "servers/audio_server.h"
-#include "servers/rendering/renderer_compositor.h"
-#include "servers/rendering_server.h"
#ifdef XAUDIO2_ENABLED
#include "drivers/xaudio2/audio_driver_xaudio2.h"
#endif
@@ -108,6 +106,8 @@ protected:
public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
+ virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override;
+
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override;
virtual Error close_dynamic_library(void *p_library_handle) override;
virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override;
@@ -142,6 +142,7 @@ public:
virtual String get_locale() const override;
virtual int get_processor_count() const override;
+ virtual String get_processor_name() const override;
virtual String get_config_path() const override;
virtual String get_data_path() const override;
diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp
index 0d5f0e617c..df21977698 100644
--- a/platform/windows/windows_terminal_logger.cpp
+++ b/platform/windows/windows_terminal_logger.cpp
@@ -44,25 +44,29 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er
const unsigned int BUFFER_SIZE = 16384;
char buf[BUFFER_SIZE + 1]; // +1 for the terminating character
int len = vsnprintf(buf, BUFFER_SIZE, p_format, p_list);
- if (len <= 0)
+ if (len <= 0) {
return;
- if ((unsigned int)len >= BUFFER_SIZE)
+ }
+ if ((unsigned int)len >= BUFFER_SIZE) {
len = BUFFER_SIZE; // Output is too big, will be truncated
+ }
buf[len] = 0;
int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, nullptr, 0);
- if (wlen < 0)
+ if (wlen < 0) {
return;
+ }
wchar_t *wbuf = (wchar_t *)memalloc((len + 1) * sizeof(wchar_t));
ERR_FAIL_NULL_MSG(wbuf, "Out of memory.");
MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen);
wbuf[wlen] = 0;
- if (p_err)
+ if (p_err) {
fwprintf(stderr, L"%ls", wbuf);
- else
+ } else {
wprintf(L"%ls", wbuf);
+ }
memfree(wbuf);