summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-01 16:28:20 +0200
committerGitHub <noreply@github.com>2020-07-01 16:28:20 +0200
commit2fc3c5bb9f0250cb5caecb79f8dc00c100d1e189 (patch)
treec6c45a4db687fe5ae42019e9f6ac677393f69c4d /scene/main
parent34e011c8a5ba4b9482a44b5601c28c68d65588d3 (diff)
parent239942cfefc51a907b3fe7eff72818b4a7732726 (diff)
Merge pull request #40015 from reduz/fix-embedded_subwindow-input
Ensure embedded mode works again
Diffstat (limited to 'scene/main')
-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
4 files changed, 16 insertions, 2 deletions
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;