diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/node.cpp | 10 | ||||
-rw-r--r-- | scene/main/node.h | 10 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 8 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 8 | ||||
-rw-r--r-- | scene/main/viewport.h | 2 | ||||
-rw-r--r-- | scene/main/window.cpp | 25 | ||||
-rw-r--r-- | scene/main/window.h | 1 |
7 files changed, 48 insertions, 16 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 1bf828a03b..88f9730f78 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2857,8 +2857,8 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_MOUSE_ENTER); BIND_CONSTANT(NOTIFICATION_WM_MOUSE_EXIT); - BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN); - BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT); + BIND_CONSTANT(NOTIFICATION_WM_WINDOW_FOCUS_IN); + BIND_CONSTANT(NOTIFICATION_WM_WINDOW_FOCUS_OUT); BIND_CONSTANT(NOTIFICATION_WM_CLOSE_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_SIZE_CHANGED); @@ -2867,8 +2867,10 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_ABOUT); BIND_CONSTANT(NOTIFICATION_CRASH); BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE); - BIND_CONSTANT(NOTIFICATION_APP_RESUMED); - BIND_CONSTANT(NOTIFICATION_APP_PAUSED); + BIND_CONSTANT(NOTIFICATION_APPLICATION_RESUMED); + BIND_CONSTANT(NOTIFICATION_APPLICATION_PAUSED); + BIND_CONSTANT(NOTIFICATION_APPLICATION_FOCUS_IN); + BIND_CONSTANT(NOTIFICATION_APPLICATION_FOCUS_OUT); BIND_ENUM_CONSTANT(PAUSE_MODE_INHERIT); BIND_ENUM_CONSTANT(PAUSE_MODE_STOP); diff --git a/scene/main/node.h b/scene/main/node.h index 7595aabd9a..c3972e2d8e 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -243,8 +243,8 @@ public: NOTIFICATION_WM_MOUSE_ENTER = 1002, NOTIFICATION_WM_MOUSE_EXIT = 1003, - NOTIFICATION_WM_FOCUS_IN = 1004, - NOTIFICATION_WM_FOCUS_OUT = 1005, + NOTIFICATION_WM_WINDOW_FOCUS_IN = 1004, + NOTIFICATION_WM_WINDOW_FOCUS_OUT = 1005, NOTIFICATION_WM_CLOSE_REQUEST = 1006, NOTIFICATION_WM_GO_BACK_REQUEST = 1007, NOTIFICATION_WM_SIZE_CHANGED = 1008, @@ -255,8 +255,10 @@ public: NOTIFICATION_WM_ABOUT = MainLoop::NOTIFICATION_WM_ABOUT, NOTIFICATION_CRASH = MainLoop::NOTIFICATION_CRASH, NOTIFICATION_OS_IME_UPDATE = MainLoop::NOTIFICATION_OS_IME_UPDATE, - NOTIFICATION_APP_RESUMED = MainLoop::NOTIFICATION_APP_RESUMED, - NOTIFICATION_APP_PAUSED = MainLoop::NOTIFICATION_APP_PAUSED + NOTIFICATION_APPLICATION_RESUMED = MainLoop::NOTIFICATION_APPLICATION_RESUMED, + NOTIFICATION_APPLICATION_PAUSED = MainLoop::NOTIFICATION_APPLICATION_PAUSED, + NOTIFICATION_APPLICATION_FOCUS_IN = MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN, + NOTIFICATION_APPLICATION_FOCUS_OUT = MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT }; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 3c3c7533a3..a418883506 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -587,9 +587,11 @@ void SceneTree::_notification(int p_notification) { case NOTIFICATION_OS_IME_UPDATE: case NOTIFICATION_WM_ABOUT: case NOTIFICATION_CRASH: - case NOTIFICATION_APP_RESUMED: - case NOTIFICATION_APP_PAUSED: { - get_root()->propagate_notification(p_notification); + case NOTIFICATION_APPLICATION_RESUMED: + case NOTIFICATION_APPLICATION_PAUSED: + case NOTIFICATION_APPLICATION_FOCUS_IN: + case NOTIFICATION_APPLICATION_FOCUS_OUT: { + get_root()->propagate_notification(p_notification); //pass these to nodes, since they are mirrored } break; default: diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 606f39370b..0d5d222f5e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -815,7 +815,7 @@ void Viewport::_notification(int p_what) { } break; case NOTIFICATION_WM_MOUSE_EXIT: - case NOTIFICATION_WM_FOCUS_OUT: { + case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { _drop_physics_mouseover(); if (gui.mouse_focus && !gui.forced_mouse_focus) { @@ -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 a9be8a1eff..8604bb78ac 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -316,13 +316,13 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { } break; case DisplayServer::WINDOW_EVENT_FOCUS_IN: { focused = true; - _propagate_window_notification(this, NOTIFICATION_WM_FOCUS_IN); + _propagate_window_notification(this, NOTIFICATION_WM_WINDOW_FOCUS_IN); emit_signal("focus_entered"); } break; case DisplayServer::WINDOW_EVENT_FOCUS_OUT: { focused = false; - _propagate_window_notification(this, NOTIFICATION_WM_FOCUS_OUT); + _propagate_window_notification(this, NOTIFICATION_WM_WINDOW_FOCUS_OUT); emit_signal("focus_exited"); } break; case DisplayServer::WINDOW_EVENT_CLOSE_REQUEST: { @@ -398,6 +398,18 @@ void Window::set_visible(bool p_visible) { emit_signal(SceneStringNames::get_singleton()->visibility_changed); RS::get_singleton()->viewport_set_active(get_viewport_rid(), visible); + + //update transient exclusive + if (transient_parent) { + if (exclusive && visible) { + ERR_FAIL_COND_MSG(transient_parent->exclusive_child && transient_parent->exclusive_child != this, "Transient parent has another exclusive child."); + transient_parent->exclusive_child = this; + } else { + if (transient_parent->exclusive_child == this) { + transient_parent->exclusive_child = nullptr; + } + } + } } void Window::_clear_transient() { @@ -862,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 @@ -878,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; |