Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions platform/macos/editor/embedded_process_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
if (current_process_id != 0 && is_embedding_completed()) {
ds->remove_embedded_process(current_process_id);
}
DisplayServer *ds = DisplayServer::get_singleton();
for (int i = 0; i < DisplayServer::CURSOR_MAX; i++) {
ds->cursor_set_custom_image(Ref<Resource>(), (DisplayServer::CursorShape)i, Vector2());
}
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
current_process_id = 0;
embedding_state = EmbeddingState::IDLE;
context_id = 0;
Expand Down Expand Up @@ -226,12 +233,12 @@
} break;
case NOTIFICATION_FOCUS_ENTER: {
// Restore mouse capture, if necessary.
DisplayServer *ds = DisplayServer::get_singleton();
if (process->get_mouse_mode() != ds->mouse_get_mode()) {
// Restore embedded process mouse mode.
ds->mouse_set_mode(process->get_mouse_mode());
}
if (!window_focused && script_debugger) {
DisplayServer *ds = DisplayServer::get_singleton();
if (process->get_mouse_mode() != ds->mouse_get_mode()) {
// Restore embedded process mouse mode.
ds->mouse_set_mode(process->get_mouse_mode());
}
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN });
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN });
window_focused = true;
Expand All @@ -249,11 +256,11 @@
} break;
case NOTIFICATION_FOCUS_EXIT: {
// Temporarily set mouse state back to visible, so the user can interact with the editor.
DisplayServer *ds = DisplayServer::get_singleton();
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
if (window_focused && script_debugger) {
DisplayServer *ds = DisplayServer::get_singleton();
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT });
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_OUT });
window_focused = false;
Expand All @@ -274,11 +281,22 @@
for (int i = 0; i < DisplayServer::CURSOR_MAX; i++) {
ds->cursor_set_custom_image(Ref<Resource>(), (DisplayServer::CursorShape)i, Vector2());
}
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
}
} break;
case NOTIFICATION_APPLICATION_FOCUS_IN:
case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
if (has_focus() && !window_focused && script_debugger) {
DisplayServer *ds = DisplayServer::get_singleton();
if (process->get_mouse_mode() != ds->mouse_get_mode()) {
// Restore embedded process mouse mode.
ds->mouse_set_mode(process->get_mouse_mode());
if (process->get_mouse_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
get_window()->grab_focus();
}
}
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN });
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN });
window_focused = true;
Expand All @@ -287,6 +305,10 @@
case NOTIFICATION_APPLICATION_FOCUS_OUT:
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
if (has_focus() && window_focused && script_debugger) {
DisplayServer *ds = DisplayServer::get_singleton();
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT });
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_OUT });
window_focused = false;
Expand Down