summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/expression.cpp2
-rw-r--r--core/ustring.cpp85
-rw-r--r--core/ustring.h10
-rw-r--r--core/variant.cpp2
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp3
-rw-r--r--drivers/unix/net_socket_posix.cpp2
-rw-r--r--editor/editor_file_system.cpp6
-rw-r--r--editor/editor_properties.cpp10
-rw-r--r--editor/editor_resource_preview.cpp6
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/scene_tree_dock.cpp27
-rw-r--r--main/main.cpp4
-rw-r--r--main/tests/test_string.cpp2
-rw-r--r--modules/gdnative/gdnative/string.cpp6
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs2
-rw-r--r--platform/linuxbsd/display_server_x11.cpp42
-rw-r--r--platform/linuxbsd/display_server_x11.h9
-rw-r--r--scene/2d/ray_cast_2d.cpp3
-rw-r--r--scene/3d/ray_cast_3d.cpp3
-rw-r--r--scene/main/viewport.cpp6
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/main/window.cpp9
-rw-r--r--scene/main/window.h1
-rw-r--r--servers/rendering/rasterizer_rd/shader_compiler_rd.cpp3
-rw-r--r--servers/rendering/shader_language.cpp26
-rw-r--r--servers/rendering/shader_language.h1
28 files changed, 147 insertions, 141 deletions
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 6421606ca2..13a49feb6b 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -1064,7 +1064,7 @@ Error Expression::_get_token(Token &r_token) {
if (is_float) {
r_token.value = num.to_double();
} else {
- r_token.value = num.to_int64();
+ r_token.value = num.to_int();
}
return OK;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 444338d5ae..be242140a2 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1618,49 +1618,7 @@ String::String(const StrRange &p_range) {
copy_from(p_range.c_str, p_range.len);
}
-int String::hex_to_int(bool p_with_prefix) const {
- if (p_with_prefix && length() < 3) {
- return 0;
- }
-
- const CharType *s = ptr();
-
- int sign = s[0] == '-' ? -1 : 1;
-
- if (sign < 0) {
- s++;
- }
-
- if (p_with_prefix) {
- if (s[0] != '0' || s[1] != 'x') {
- return 0;
- }
- s += 2;
- }
-
- int hex = 0;
-
- while (*s) {
- CharType c = LOWERCASE(*s);
- int n;
- if (c >= '0' && c <= '9') {
- n = c - '0';
- } else if (c >= 'a' && c <= 'f') {
- n = (c - 'a') + 10;
- } else {
- return 0;
- }
-
- ERR_FAIL_COND_V_MSG(hex > INT32_MAX / 16, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
- hex *= 16;
- hex += n;
- s++;
- }
-
- return hex * sign;
-}
-
-int64_t String::hex_to_int64(bool p_with_prefix) const {
+int64_t String::hex_to_int(bool p_with_prefix) const {
if (p_with_prefix && length() < 3) {
return 0;
}
@@ -1702,7 +1660,7 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
return hex * sign;
}
-int64_t String::bin_to_int64(bool p_with_prefix) const {
+int64_t String::bin_to_int(bool p_with_prefix) const {
if (p_with_prefix && length() < 3) {
return 0;
}
@@ -1742,32 +1700,7 @@ int64_t String::bin_to_int64(bool p_with_prefix) const {
return binary * sign;
}
-int String::to_int() const {
- if (length() == 0) {
- return 0;
- }
-
- int to = (find(".") >= 0) ? find(".") : length();
-
- int integer = 0;
- int sign = 1;
-
- for (int i = 0; i < to; i++) {
- CharType c = operator[](i);
- if (c >= '0' && c <= '9') {
- ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
- integer *= 10;
- integer += c - '0';
-
- } else if (integer == 0 && c == '-') {
- sign = -sign;
- }
- }
-
- return integer * sign;
-}
-
-int64_t String::to_int64() const {
+int64_t String::to_int() const {
if (length() == 0) {
return 0;
}
@@ -1780,7 +1713,7 @@ int64_t String::to_int64() const {
for (int i = 0; i < to; i++) {
CharType c = operator[](i);
if (c >= '0' && c <= '9') {
- ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
+ ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as an integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
integer += c - '0';
@@ -1792,7 +1725,7 @@ int64_t String::to_int64() const {
return integer * sign;
}
-int String::to_int(const char *p_str, int p_len) {
+int64_t String::to_int(const char *p_str, int p_len) {
int to = 0;
if (p_len >= 0) {
to = p_len;
@@ -1802,13 +1735,13 @@ int String::to_int(const char *p_str, int p_len) {
}
}
- int integer = 0;
- int sign = 1;
+ int64_t integer = 0;
+ int64_t sign = 1;
for (int i = 0; i < to; i++) {
char c = p_str[i];
if (c >= '0' && c <= '9') {
- ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
+ ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as an integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
integer += c - '0';
@@ -3838,7 +3771,7 @@ bool String::is_valid_ip_address() const {
continue;
}
if (n.is_valid_hex_number(false)) {
- int nint = n.hex_to_int(false);
+ int64_t nint = n.hex_to_int(false);
if (nint < 0 || nint > 0xffff) {
return false;
}
diff --git a/core/ustring.h b/core/ustring.h
index 5b13a1c704..a86849b932 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -245,13 +245,11 @@ public:
bool is_numeric() const;
double to_double() const;
float to_float() const;
- int hex_to_int(bool p_with_prefix = true) const;
- int to_int() const;
- int64_t hex_to_int64(bool p_with_prefix = true) const;
- int64_t bin_to_int64(bool p_with_prefix = true) const;
- int64_t to_int64() const;
- static int to_int(const char *p_str, int p_len = -1);
+ int64_t hex_to_int(bool p_with_prefix = true) const;
+ int64_t bin_to_int(bool p_with_prefix = true) const;
+ int64_t to_int() const;
+ static int64_t to_int(const char *p_str, int p_len = -1);
static double to_double(const char *p_str);
static double to_double(const CharType *p_str, const CharType **r_end = nullptr);
static int64_t to_int(const CharType *p_str, int p_len = -1, bool p_clamp = false);
diff --git a/core/variant.cpp b/core/variant.cpp
index 21aaa0fe9e..f6b7e2821a 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1409,7 +1409,7 @@ Variant::operator int64_t() const {
case FLOAT:
return _data._float;
case STRING:
- return operator String().to_int64();
+ return operator String().to_int();
default: {
return 0;
}
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index 2e36de5c79..a5e85424b7 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -247,6 +247,9 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
for (int i = 0; i < fnode->arguments.size(); i++) {
if (i > 0)
header += ", ";
+ if (fnode->arguments[i].is_const) {
+ header += "const ";
+ }
if (fnode->arguments[i].type == SL::TYPE_STRUCT) {
header += _qualstr(fnode->arguments[i].qualifier) + _mkid(fnode->arguments[i].type_str) + " " + _mkid(fnode->arguments[i].name);
} else {
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 15ad187ab4..186804dbb1 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -245,7 +245,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
continue;
}
- if_v6id = (uint32_t)c.index.to_int64();
+ if_v6id = (uint32_t)c.index.to_int();
if (type == IP::TYPE_IPV6) {
break; // IPv6 uses index.
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index d88c61d7b2..9ca3d387d9 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -233,9 +233,9 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type = split[1];
- fc.modification_time = split[2].to_int64();
- fc.import_modification_time = split[3].to_int64();
- fc.import_valid = split[4].to_int64() != 0;
+ fc.modification_time = split[2].to_int();
+ fc.import_modification_time = split[3].to_int();
+ fc.import_valid = split[4].to_int() != 0;
fc.import_group_file = split[5].strip_edges();
fc.script_class_name = split[6].get_slice("<>", 0);
fc.script_class_extends = split[6].get_slice("<>", 1);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index eee610e9a8..23db6ebb4e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -377,13 +377,13 @@ void EditorPropertyMember::_property_select() {
selector->select_method_from_base_type(hint_text, current);
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_method_from_instance(instance, current);
}
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
@@ -408,13 +408,13 @@ void EditorPropertyMember::_property_select() {
selector->select_property_from_base_type(hint_text, current);
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_property_from_instance(instance, current);
}
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
@@ -488,7 +488,7 @@ void EditorPropertyEnum::setup(const Vector<String> &p_options) {
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
if (text_split.size() != 1) {
- current_val = text_split[1].to_int64();
+ current_val = text_split[1].to_int();
}
options->add_item(text_split[0]);
options->set_item_metadata(i, current_val);
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 7ac8fae156..d2250fed7a 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -110,7 +110,7 @@ void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Textur
uint64_t modified_time = 0;
if (p_str.begins_with("ID:")) {
- hash = uint32_t(p_str.get_slicec(':', 2).to_int64());
+ hash = uint32_t(p_str.get_slicec(':', 2).to_int());
path = "ID:" + p_str.get_slicec(':', 1);
} else {
modified_time = FileAccess::get_modified_time(path);
@@ -257,9 +257,9 @@ void EditorResourcePreview::_thread() {
_generate_preview(texture, small_texture, item, cache_base);
} else {
uint64_t modtime = FileAccess::get_modified_time(item.path);
- int tsize = f->get_line().to_int64();
+ int tsize = f->get_line().to_int();
bool has_small_texture = f->get_line().to_int();
- uint64_t last_modtime = f->get_line().to_int64();
+ uint64_t last_modtime = f->get_line().to_int();
bool cache_valid = true;
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index fd415d40da..72d287c35c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -538,7 +538,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
if (p_save) {
- apply_scripts();
+ _menu_option(FILE_SAVE);
}
Ref<Script> script = current->get_edited_resource();
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 49b9ca167b..f4838d336f 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -597,7 +597,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_method_from_instance(instance, v);
}
@@ -607,7 +607,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
@@ -646,7 +646,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_property_from_instance(instance, v);
}
@@ -657,7 +657,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 04ac809d03..9831f1bd31 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -741,17 +741,28 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
_delete_confirm();
} else {
- if (remove_list.size() >= 2) {
- delete_dialog->set_text(vformat(TTR("Delete %d nodes?"), remove_list.size()));
- } else if (remove_list.size() == 1 && remove_list[0] == editor_data->get_edited_scene_root()) {
- delete_dialog->set_text(vformat(TTR("Delete the root node \"%s\"?"), remove_list[0]->get_name()));
- } else if (remove_list.size() == 1 && remove_list[0]->get_filename() == "" && remove_list[0]->get_child_count() >= 1) {
- // Display this message only for non-instanced scenes
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\" and its children?"), remove_list[0]->get_name()));
+ String msg;
+ if (remove_list.size() > 1) {
+ bool any_children = false;
+ for (int i = 0; !any_children && i < remove_list.size(); i++) {
+ any_children = remove_list[i]->get_child_count() > 0;
+ }
+
+ msg = vformat(any_children ? TTR("Delete %d nodes and any children?") : TTR("Delete %d nodes?"), remove_list.size());
} else {
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\"?"), remove_list[0]->get_name()));
+ Node *node = remove_list[0];
+ if (node == editor_data->get_edited_scene_root()) {
+ msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name());
+ } else if (node->get_filename() == "" && node->get_child_count() > 0) {
+ // Display this message only for non-instanced scenes
+ msg = vformat(TTR("Delete node \"%s\" and its children?"), node->get_name());
+ } else {
+ msg = vformat(TTR("Delete node \"%s\"?"), node->get_name());
+ }
}
+ delete_dialog->set_text(msg);
+
// Resize the dialog to its minimum size.
// This prevents the dialog from being too wide after displaying
// a deletion confirmation for a node with a long name.
diff --git a/main/main.cpp b/main/main.cpp
index 0cccccdab3..76175780a3 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -856,7 +856,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "--allow_focus_steal_pid") { // not exposed to user
if (I->next()) {
- allow_focus_steal_pid = I->next()->get().to_int64();
+ allow_focus_steal_pid = I->next()->get().to_int();
N = I->next()->next();
} else {
OS::get_singleton()->print("Missing editor PID argument, aborting.\n");
@@ -1620,7 +1620,7 @@ bool Main::start() {
{
DirAccessRef da = DirAccess::open(doc_tool);
- ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a base Godot build directory.");
+ ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
}
#ifndef MODULE_MONO_ENABLED
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 775c039282..5a14492be5 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -370,7 +370,7 @@ bool test_22() {
static const int num[4] = { 1237461283, -22, 0, -1123412 };
for (int i = 0; i < 4; i++) {
- OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n", nums[i], String(nums[i]).to_int());
+ OS::get_singleton()->print("\tString: \"%s\" as Int is %lli\n", nums[i], (long long)(String(nums[i]).to_int()));
if (String(nums[i]).to_int() != num[i]) {
return false;
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 724a4b56cb..f89f647aca 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -613,19 +613,19 @@ int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_le
int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
- return self->hex_to_int64(false);
+ return self->hex_to_int(false);
}
int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) {
const String *self = (const String *)p_self;
- return self->hex_to_int64();
+ return self->hex_to_int();
}
int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
- return self->to_int64();
+ return self->to_int();
}
double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 2db42601c6..82def3f877 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -952,16 +952,16 @@ void GDScriptTokenizerText::_advance() {
INCPOS(i);
if (hexa_found) {
- int64_t val = str.hex_to_int64();
+ int64_t val = str.hex_to_int();
_make_constant(val);
} else if (bin_found) {
- int64_t val = str.bin_to_int64();
+ int64_t val = str.bin_to_int();
_make_constant(val);
} else if (period_found || exponent_found) {
double val = str.to_double();
_make_constant(val);
} else {
- int64_t val = str.to_int64();
+ int64_t val = str.to_int();
_make_constant(val);
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
index ae05710f4f..b30c857c64 100644
--- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
@@ -10,7 +10,7 @@ namespace GodotTools
public override void _Notification(int what)
{
- if (what == Node.NotificationWmFocusIn)
+ if (what == Node.NotificationWmWindowFocusIn)
{
RestartTimer();
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 94c2e989f1..cb4b0d745b 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -2339,6 +2339,24 @@ void DisplayServerX11::_send_window_event(const WindowData &wd, WindowEvent p_ev
void DisplayServerX11::process_events() {
_THREAD_SAFE_METHOD_
+ if (app_focused) {
+ //verify that one of the windows has focus, else send focus out notification
+ bool focus_found = false;
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (E->get().focused) {
+ focus_found = true;
+ }
+ }
+
+ if (!focus_found) {
+ if (OS::get_singleton()->get_main_loop()) {
+ OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
+ }
+
+ app_focused = false;
+ }
+ }
+
do_mouse_warp = false;
// Is the current mouse mode one where it needs to be grabbed.
@@ -2533,12 +2551,12 @@ void DisplayServerX11::process_events() {
break;
case NoExpose:
- minimized = true;
+ windows[window_id].minimized = true;
break;
case VisibilityNotify: {
XVisibilityEvent *visibility = (XVisibilityEvent *)&event;
- minimized = (visibility->state == VisibilityFullyObscured);
+ windows[window_id].minimized = (visibility->state == VisibilityFullyObscured);
} break;
case LeaveNotify: {
if (!mouse_mode_grab) {
@@ -2552,10 +2570,8 @@ void DisplayServerX11::process_events() {
}
} break;
case FocusIn:
- minimized = false;
- window_has_focus = true;
+ windows[window_id].focused = true;
_send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN);
- window_focused = true;
if (mouse_mode_grab) {
// Show and update the cursor if confined and the window regained focus.
@@ -2582,13 +2598,19 @@ void DisplayServerX11::process_events() {
if (windows[window_id].xic) {
XSetICFocus(windows[window_id].xic);
}
+
+ if (!app_focused) {
+ if (OS::get_singleton()->get_main_loop()) {
+ OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN);
+ }
+ app_focused = true;
+ }
break;
case FocusOut:
- window_has_focus = false;
+ windows[window_id].focused = false;
Input::get_singleton()->release_pressed_events();
_send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT);
- window_focused = false;
if (mouse_mode_grab) {
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
@@ -2727,7 +2749,7 @@ void DisplayServerX11::process_events() {
Point2i new_center = pos;
pos = last_mouse_pos + xi.relative_motion;
center = new_center;
- do_mouse_warp = window_has_focus; // warp the cursor if we're focused in
+ do_mouse_warp = windows[window_id].focused; // warp the cursor if we're focused in
}
if (!last_mouse_pos_valid) {
@@ -2787,7 +2809,7 @@ void DisplayServerX11::process_events() {
// Don't propagate the motion event unless we have focus
// this is so that the relative motion doesn't get messed up
// after we regain focus.
- if (window_has_focus || !mouse_mode_grab) {
+ if (windows[window_id].focused || !mouse_mode_grab) {
Input::get_singleton()->accumulate_input_event(mm);
}
@@ -3764,8 +3786,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
requested = None;
- window_has_focus = true; // Set focus to true at init
-
/*if (p_desired.layered) {
set_window_per_pixel_transparency_enabled(true);
}*/
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 3b2ff0e08d..3d0b2c7e8a 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -139,6 +139,8 @@ class DisplayServerX11 : public DisplayServer {
bool borderless = false;
bool resize_disabled = false;
Vector2i last_position_before_fs;
+ bool focused = false;
+ bool minimized = false;
};
Map<WindowID, WindowData> windows;
@@ -164,6 +166,7 @@ class DisplayServerX11 : public DisplayServer {
uint64_t last_click_ms;
int last_click_button_index;
uint32_t last_button_state;
+ bool app_focused = false;
struct {
int opcode;
@@ -195,8 +198,8 @@ class DisplayServerX11 : public DisplayServer {
void _handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo = false);
- bool minimized;
- bool window_has_focus;
+ //bool minimized;
+ //bool window_has_focus;
bool do_mouse_warp;
const char *cursor_theme;
@@ -210,7 +213,7 @@ class DisplayServerX11 : public DisplayServer {
bool layered_window;
String rendering_driver;
- bool window_focused;
+ //bool window_focused;
//void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled);
void set_wm_above(bool p_enabled);
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 5020940c5c..9fd24b5294 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -325,8 +325,7 @@ void RayCast2D::_bind_methods() {
}
RayCast2D::RayCast2D() {
- enabled = false;
-
+ enabled = true;
collided = false;
against_shape = 0;
collision_mask = 1;
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index 68f4b3132c..2a922e3cda 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -383,8 +383,7 @@ void RayCast3D::_clear_debug_shape() {
}
RayCast3D::RayCast3D() {
- enabled = false;
-
+ enabled = true;
collided = false;
against_shape = 0;
collision_mask = 1;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8042f02fa6..0d5d222f5e 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2913,6 +2913,10 @@ void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
return;
}
+ if (!_can_consume_input_events()) {
+ return;
+ }
+
if (!is_input_handled()) {
get_tree()->_call_input_pause(input_group, "_input", ev, this); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
}
@@ -2926,7 +2930,7 @@ void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
ERR_FAIL_COND(!is_inside_tree());
- if (disable_input) {
+ if (disable_input || !_can_consume_input_events()) {
return;
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 11fe4f00d2..d45b321f73 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -441,6 +441,8 @@ private:
bool _sub_windows_forward_input(const Ref<InputEvent> &p_event);
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
+ virtual bool _can_consume_input_events() const { return true; }
+
protected:
void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 7f2160c6a5..8604bb78ac 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -874,6 +874,10 @@ void Window::child_controls_changed() {
call_deferred("_update_child_controls");
}
+bool Window::_can_consume_input_events() const {
+ return exclusive_child == nullptr;
+}
+
void Window::_window_input(const Ref<InputEvent> &p_ev) {
if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_ev.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_ev))) {
return; //avoid joy input on editor
@@ -890,10 +894,13 @@ void Window::_window_input(const Ref<InputEvent> &p_ev) {
if (exclusive_child != nullptr) {
exclusive_child->grab_focus();
- return; //has an exclusive child, can't get events until child is closed
+ if (!is_embedding_subwindows()) { //not embedding, no need for event
+ return;
+ }
}
emit_signal(SceneStringNames::get_singleton()->window_input, p_ev);
+
input(p_ev);
if (!is_input_handled()) {
unhandled_input(p_ev);
diff --git a/scene/main/window.h b/scene/main/window.h
index adaa5ca3be..89c94753da 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -130,6 +130,7 @@ private:
void _window_drop_files(const Vector<String> &p_files);
void _rect_changed_callback(const Rect2i &p_callback);
void _event_callback(DisplayServer::WindowEvent p_event);
+ virtual bool _can_consume_input_events() const;
protected:
Viewport *_get_embedder() const;
diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
index 79bb990649..1820c39c5a 100644
--- a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
@@ -399,6 +399,9 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S
if (i > 0) {
header += ", ";
}
+ if (fnode->arguments[i].is_const) {
+ header += "const ";
+ }
if (fnode->arguments[i].type == SL::TYPE_STRUCT) {
header += _qualstr(fnode->arguments[i].qualifier) + _mkid(fnode->arguments[i].type_str) + " " + _mkid(fnode->arguments[i].name);
} else {
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 809b03520b..99cc76b2e3 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -643,7 +643,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
}
if (hexa_found) {
- tk.constant = (double)str.hex_to_int64(true);
+ tk.constant = (double)str.hex_to_int(true);
} else {
tk.constant = str.to_double();
}
@@ -982,6 +982,9 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
if (r_struct_name) {
*r_struct_name = function->arguments[i].type_str;
}
+ if (r_is_const) {
+ *r_is_const = function->arguments[i].is_const;
+ }
return true;
}
}
@@ -3553,7 +3556,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
for (int i = 0; i < call_function->arguments.size(); i++) {
int argidx = i + 1;
if (argidx < func->arguments.size()) {
- if (call_function->arguments[i].qualifier == ArgumentQualifier::ARGUMENT_QUALIFIER_OUT || call_function->arguments[i].qualifier == ArgumentQualifier::ARGUMENT_QUALIFIER_INOUT) {
+ if (call_function->arguments[i].is_const || call_function->arguments[i].qualifier == ArgumentQualifier::ARGUMENT_QUALIFIER_OUT || call_function->arguments[i].qualifier == ArgumentQualifier::ARGUMENT_QUALIFIER_INOUT) {
bool error = false;
Node *n = func->arguments[argidx];
if (n->type == Node::TYPE_CONSTANT || n->type == Node::TYPE_OPERATOR) {
@@ -6780,15 +6783,29 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
break;
}
+ bool is_const = false;
+ if (tk.type == TK_CONST) {
+ is_const = true;
+ tk = _get_token();
+ }
+
ArgumentQualifier qualifier = ARGUMENT_QUALIFIER_IN;
if (tk.type == TK_ARG_IN) {
qualifier = ARGUMENT_QUALIFIER_IN;
tk = _get_token();
} else if (tk.type == TK_ARG_OUT) {
+ if (is_const) {
+ _set_error("'out' qualifier cannot be used within a function parameter declared with 'const'.");
+ return ERR_PARSE_ERROR;
+ }
qualifier = ARGUMENT_QUALIFIER_OUT;
tk = _get_token();
} else if (tk.type == TK_ARG_INOUT) {
+ if (is_const) {
+ _set_error("'inout' qualifier cannot be used within a function parameter declared with 'const'.");
+ return ERR_PARSE_ERROR;
+ }
qualifier = ARGUMENT_QUALIFIER_INOUT;
tk = _get_token();
}
@@ -6877,6 +6894,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
arg.tex_builtin_check = false;
arg.tex_argument_filter = FILTER_DEFAULT;
arg.tex_argument_repeat = REPEAT_DEFAULT;
+ arg.is_const = is_const;
func_node->arguments.push_back(arg);
@@ -7273,6 +7291,10 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
calltip += CharType(0xFFFF);
}
+ if (shader->functions[i].function->arguments[j].is_const) {
+ calltip += "const ";
+ }
+
if (shader->functions[i].function->arguments[j].qualifier != ArgumentQualifier::ARGUMENT_QUALIFIER_IN) {
if (shader->functions[i].function->arguments[j].qualifier == ArgumentQualifier::ARGUMENT_QUALIFIER_OUT) {
calltip += "out ";
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index bc8f03774a..faf06a9a85 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -554,6 +554,7 @@ public:
TextureRepeat tex_argument_repeat;
bool tex_builtin_check;
StringName tex_builtin;
+ bool is_const;
Map<StringName, Set<int>> tex_argument_connect;
};