|
@@ -233,10 +233,16 @@ EmbeddedProcessMacOS::~EmbeddedProcessMacOS() {
|
|
|
|
|
|
void LayerHost::_notification(int p_what) {
|
|
void LayerHost::_notification(int p_what) {
|
|
switch (p_what) {
|
|
switch (p_what) {
|
|
- case NOTIFICATION_FOCUS_ENTER: {
|
|
|
|
|
|
+ case NOTIFICATION_MOUSE_ENTER: {
|
|
|
|
+ DisplayServer *ds = DisplayServer::get_singleton();
|
|
|
|
+ for (const KeyValue<DisplayServer::CursorShape, CustomCursor> &E : custom_cursors) {
|
|
|
|
+ ds->cursor_set_custom_image(E.value.image, E.key, E.value.hotspot);
|
|
|
|
+ }
|
|
if (script_debugger) {
|
|
if (script_debugger) {
|
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_MOUSE_ENTER });
|
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_MOUSE_ENTER });
|
|
}
|
|
}
|
|
|
|
+ } break;
|
|
|
|
+ case NOTIFICATION_FOCUS_ENTER: {
|
|
// Restore mouse capture, if necessary.
|
|
// Restore mouse capture, if necessary.
|
|
DisplayServer *ds = DisplayServer::get_singleton();
|
|
DisplayServer *ds = DisplayServer::get_singleton();
|
|
if (process->get_mouse_mode() != ds->mouse_get_mode()) {
|
|
if (process->get_mouse_mode() != ds->mouse_get_mode()) {
|
|
@@ -244,10 +250,16 @@ void LayerHost::_notification(int p_what) {
|
|
ds->mouse_set_mode(process->get_mouse_mode());
|
|
ds->mouse_set_mode(process->get_mouse_mode());
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
- case NOTIFICATION_FOCUS_EXIT: {
|
|
|
|
|
|
+ case NOTIFICATION_MOUSE_EXIT: {
|
|
|
|
+ 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 (script_debugger) {
|
|
if (script_debugger) {
|
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_MOUSE_EXIT });
|
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_MOUSE_EXIT });
|
|
}
|
|
}
|
|
|
|
+ } break;
|
|
|
|
+ case NOTIFICATION_FOCUS_EXIT: {
|
|
// Temporarily set mouse state back to visible, so the user can interact with the editor.
|
|
// Temporarily set mouse state back to visible, so the user can interact with the editor.
|
|
DisplayServer *ds = DisplayServer::get_singleton();
|
|
DisplayServer *ds = DisplayServer::get_singleton();
|
|
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
|
|
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
|
|
@@ -261,9 +273,22 @@ void LayerHost::_notification(int p_what) {
|
|
script_debugger->send_message("embed:ime_update", { ime_text, ime_selection });
|
|
script_debugger->send_message("embed:ime_update", { ime_text, ime_selection });
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
|
|
+ case NOTIFICATION_EXIT_TREE:
|
|
|
|
+ case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
+ if (!is_visible_in_tree()) {
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void LayerHost::cursor_set_custom_image(const Ref<Image> &p_image, DisplayServer::CursorShape p_shape, const Vector2 &p_hotspot) {
|
|
|
|
+ custom_cursors[p_shape] = CustomCursor(p_image, p_hotspot);
|
|
|
|
+}
|
|
|
|
+
|
|
void LayerHost::gui_input(const Ref<InputEvent> &p_event) {
|
|
void LayerHost::gui_input(const Ref<InputEvent> &p_event) {
|
|
if (!process->is_embedding_completed()) {
|
|
if (!process->is_embedding_completed()) {
|
|
return;
|
|
return;
|