@@ -101,12 +101,6 @@ void WindowWrapper::_set_window_enabled_with_rect(bool p_visible, const Rect2 p_
101101
102102 Node *parent = _get_wrapped_control_parent ();
103103
104- // In the GameView plugin, we need to the the signal before the window is actually closed
105- // to prevent the embedded game to be seen the parent window for a fraction of a second.
106- if (!p_visible) {
107- emit_signal (" window_before_closing" );
108- }
109-
110104 if (wrapped_control->get_parent () != parent) {
111105 // Move the control to the window.
112106 wrapped_control->reparent (parent, false );
@@ -120,7 +114,7 @@ void WindowWrapper::_set_window_enabled_with_rect(bool p_visible, const Rect2 p_
120114 }
121115
122116 window->set_visible (p_visible);
123- if (!p_visible) {
117+ if (!p_visible && !override_close_request ) {
124118 emit_signal (" window_close_requested" );
125119 }
126120 emit_signal (" window_visibility_changed" , p_visible);
@@ -141,10 +135,17 @@ void WindowWrapper::_window_size_changed() {
141135 emit_signal (SNAME (" window_size_changed" ));
142136}
143137
138+ void WindowWrapper::_window_close_request () {
139+ if (override_close_request) {
140+ emit_signal (" window_close_requested" );
141+ } else {
142+ set_window_enabled (false );
143+ }
144+ }
145+
144146void WindowWrapper::_bind_methods () {
145147 ADD_SIGNAL (MethodInfo (" window_visibility_changed" , PropertyInfo (Variant::BOOL, " visible" )));
146148 ADD_SIGNAL (MethodInfo (" window_close_requested" ));
147- ADD_SIGNAL (MethodInfo (" window_before_closing" ));
148149 ADD_SIGNAL (MethodInfo (" window_size_changed" ));
149150}
150151
@@ -330,6 +331,10 @@ void WindowWrapper::grab_window_focus() {
330331 }
331332}
332333
334+ void WindowWrapper::set_override_close_request (bool p_enabled) {
335+ override_close_request = p_enabled;
336+ }
337+
333338WindowWrapper::WindowWrapper () {
334339 if (!EditorNode::get_singleton ()->is_multi_window_enabled ()) {
335340 return ;
@@ -342,7 +347,7 @@ WindowWrapper::WindowWrapper() {
342347 add_child (window);
343348 window->hide ();
344349
345- window->connect (" close_requested" , callable_mp (this , &WindowWrapper::set_window_enabled). bind ( false ));
350+ window->connect (" close_requested" , callable_mp (this , &WindowWrapper::_window_close_request ));
346351 window->connect (" size_changed" , callable_mp (this , &WindowWrapper::_window_size_changed));
347352
348353 ShortcutBin *capturer = memnew (ShortcutBin);
0 commit comments