|
105 | 105 | if (current_process_id != 0 && is_embedding_completed()) { |
106 | 106 | ds->remove_embedded_process(current_process_id); |
107 | 107 | } |
| 108 | + DisplayServer *ds = DisplayServer::get_singleton(); |
| 109 | + for (int i = 0; i < DisplayServer::CURSOR_MAX; i++) { |
| 110 | + ds->cursor_set_custom_image(Ref<Resource>(), (DisplayServer::CursorShape)i, Vector2()); |
| 111 | + } |
| 112 | + if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) { |
| 113 | + ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); |
| 114 | + } |
108 | 115 | current_process_id = 0; |
109 | 116 | embedding_state = EmbeddingState::IDLE; |
110 | 117 | context_id = 0; |
|
222 | 229 | } break; |
223 | 230 | case NOTIFICATION_FOCUS_ENTER: { |
224 | 231 | // Restore mouse capture, if necessary. |
225 | | - DisplayServer *ds = DisplayServer::get_singleton(); |
226 | | - if (process->get_mouse_mode() != ds->mouse_get_mode()) { |
227 | | - // Restore embedded process mouse mode. |
228 | | - ds->mouse_set_mode(process->get_mouse_mode()); |
229 | | - } |
230 | 232 | if (!window_focused && script_debugger) { |
| 233 | + DisplayServer *ds = DisplayServer::get_singleton(); |
| 234 | + if (process->get_mouse_mode() != ds->mouse_get_mode()) { |
| 235 | + // Restore embedded process mouse mode. |
| 236 | + ds->mouse_set_mode(process->get_mouse_mode()); |
| 237 | + } |
231 | 238 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN }); |
232 | 239 | window_focused = true; |
233 | 240 | } |
|
243 | 250 | } break; |
244 | 251 | case NOTIFICATION_FOCUS_EXIT: { |
245 | 252 | // Temporarily set mouse state back to visible, so the user can interact with the editor. |
246 | | - DisplayServer *ds = DisplayServer::get_singleton(); |
247 | | - if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) { |
248 | | - ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); |
249 | | - } |
250 | 253 | if (window_focused && script_debugger) { |
| 254 | + DisplayServer *ds = DisplayServer::get_singleton(); |
| 255 | + if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) { |
| 256 | + ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); |
| 257 | + } |
251 | 258 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT }); |
252 | 259 | window_focused = false; |
253 | 260 | } |
|
266 | 273 | for (int i = 0; i < DisplayServer::CURSOR_MAX; i++) { |
267 | 274 | ds->cursor_set_custom_image(Ref<Resource>(), (DisplayServer::CursorShape)i, Vector2()); |
268 | 275 | } |
| 276 | + if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) { |
| 277 | + ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); |
| 278 | + } |
269 | 279 | } |
270 | 280 | } break; |
271 | 281 | case NOTIFICATION_WM_WINDOW_FOCUS_IN: { |
272 | 282 | if (!window_focused && script_debugger) { |
| 283 | + DisplayServer *ds = DisplayServer::get_singleton(); |
| 284 | + if (process->get_mouse_mode() != ds->mouse_get_mode()) { |
| 285 | + // Restore embedded process mouse mode. |
| 286 | + ds->mouse_set_mode(process->get_mouse_mode()); |
| 287 | + } |
273 | 288 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN }); |
274 | 289 | window_focused = true; |
275 | 290 | } |
276 | 291 | } break; |
277 | 292 | case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { |
278 | 293 | if (window_focused && script_debugger) { |
| 294 | + DisplayServer *ds = DisplayServer::get_singleton(); |
| 295 | + if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) { |
| 296 | + ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); |
| 297 | + } |
279 | 298 | script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT }); |
280 | 299 | window_focused = false; |
281 | 300 | } |
|
0 commit comments