@@ -40,20 +40,6 @@ void EmbeddedProcess::_notification(int p_what) {
4040 case NOTIFICATION_ENTER_TREE: {
4141 window = get_window ();
4242 } break ;
43- case NOTIFICATION_PROCESS: {
44- _check_focused_process_id ();
45- _check_mouse_over ();
46-
47- // We need to detect when the control globally changes location or size on the screen.
48- // NOTIFICATION_RESIZED and NOTIFICATION_WM_POSITION_CHANGED are not enough to detect
49- // resized parent to siblings controls that can affect global position.
50- Rect2i new_global_rect = get_global_rect ();
51- if (last_global_rect != new_global_rect) {
52- last_global_rect = new_global_rect;
53- queue_update_embedded_process ();
54- }
55-
56- } break ;
5743 case NOTIFICATION_DRAW: {
5844 _draw ();
5945 } break ;
@@ -192,7 +178,7 @@ void EmbeddedProcess::embed_process(OS::ProcessID p_pid) {
192178 current_process_id = p_pid;
193179 start_embedding_time = OS::get_singleton ()->get_ticks_msec ();
194180 embedding_grab_focus = has_focus ();
195- set_process ( true );
181+ timer_update_embedded_process-> start ( );
196182 set_notify_transform (true );
197183
198184 // Attempt to embed the process, but if it has just started and the window is not ready yet,
@@ -209,7 +195,7 @@ void EmbeddedProcess::reset() {
209195 start_embedding_time = 0 ;
210196 embedding_grab_focus = false ;
211197 timer_embedding->stop ();
212- set_process ( false );
198+ timer_update_embedded_process-> stop ( );
213199 set_notify_transform (false );
214200 queue_redraw ();
215201}
@@ -242,18 +228,31 @@ bool EmbeddedProcess::_is_embedded_process_updatable() {
242228}
243229
244230void EmbeddedProcess::queue_update_embedded_process () {
245- if (updated_embedded_process_queued || !_is_embedded_process_updatable ()) {
246- return ;
247- }
248-
249231 updated_embedded_process_queued = true ;
232+ }
250233
251- callable_mp (this , &EmbeddedProcess::_update_embedded_process).call_deferred ();
234+ void EmbeddedProcess::_timer_update_embedded_process_timeout () {
235+ _check_focused_process_id ();
236+ _check_mouse_over ();
237+
238+ if (!updated_embedded_process_queued) {
239+ // We need to detect when the control globally changes location or size on the screen.
240+ // NOTIFICATION_RESIZED and NOTIFICATION_WM_POSITION_CHANGED are not enough to detect
241+ // resized parent to siblings controls that can affect global position.
242+ Rect2i new_global_rect = get_global_rect ();
243+ if (last_global_rect != new_global_rect) {
244+ last_global_rect = new_global_rect;
245+ queue_update_embedded_process ();
246+ }
247+ }
248+
249+ if (updated_embedded_process_queued) {
250+ updated_embedded_process_queued = false ;
251+ _update_embedded_process ();
252+ }
252253}
253254
254255void EmbeddedProcess::_update_embedded_process () {
255- updated_embedded_process_queued = false ;
256-
257256 if (!_is_embedded_process_updatable ()) {
258257 return ;
259258 }
@@ -352,6 +351,12 @@ EmbeddedProcess::EmbeddedProcess() {
352351 timer_embedding->set_one_shot (true );
353352 add_child (timer_embedding);
354353 timer_embedding->connect (" timeout" , callable_mp (this , &EmbeddedProcess::_timer_embedding_timeout));
354+
355+ timer_update_embedded_process = memnew (Timer);
356+ timer_update_embedded_process->set_wait_time (0.1 );
357+ add_child (timer_update_embedded_process);
358+ timer_update_embedded_process->connect (" timeout" , callable_mp (this , &EmbeddedProcess::_timer_update_embedded_process_timeout));
359+
355360 set_focus_mode (FOCUS_ALL);
356361}
357362
0 commit comments