Merge pull request #80439 from bruvzg/macos_mouse_enter_exit
[macOS] Fix missing mouse exit events on window close.
This commit is contained in:
commit
11ea4dc466
@ -171,6 +171,7 @@ private:
|
|||||||
int current_layout = 0;
|
int current_layout = 0;
|
||||||
bool keyboard_layout_dirty = true;
|
bool keyboard_layout_dirty = true;
|
||||||
|
|
||||||
|
WindowID window_mouseover_id = INVALID_WINDOW_ID;
|
||||||
WindowID last_focused_window = INVALID_WINDOW_ID;
|
WindowID last_focused_window = INVALID_WINDOW_ID;
|
||||||
WindowID window_id_counter = MAIN_WINDOW_ID;
|
WindowID window_id_counter = MAIN_WINDOW_ID;
|
||||||
float display_max_scale = 1.f;
|
float display_max_scale = 1.f;
|
||||||
@ -240,6 +241,8 @@ public:
|
|||||||
bool get_is_resizing() const;
|
bool get_is_resizing() const;
|
||||||
void reparent_check(WindowID p_window);
|
void reparent_check(WindowID p_window);
|
||||||
WindowID _get_focused_window_or_popup() const;
|
WindowID _get_focused_window_or_popup() const;
|
||||||
|
void mouse_enter_window(WindowID p_window);
|
||||||
|
void mouse_exit_window(WindowID p_window);
|
||||||
|
|
||||||
void window_update(WindowID p_window);
|
void window_update(WindowID p_window);
|
||||||
void window_destroy(WindowID p_window);
|
void window_destroy(WindowID p_window);
|
||||||
|
@ -366,6 +366,25 @@ DisplayServer::WindowID DisplayServerMacOS::_get_focused_window_or_popup() const
|
|||||||
return last_focused_window;
|
return last_focused_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayServerMacOS::mouse_enter_window(WindowID p_window) {
|
||||||
|
if (window_mouseover_id != p_window) {
|
||||||
|
if (window_mouseover_id != INVALID_WINDOW_ID) {
|
||||||
|
send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
|
||||||
|
}
|
||||||
|
window_mouseover_id = p_window;
|
||||||
|
if (p_window != INVALID_WINDOW_ID) {
|
||||||
|
send_window_event(windows[p_window], WINDOW_EVENT_MOUSE_ENTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayServerMacOS::mouse_exit_window(WindowID p_window) {
|
||||||
|
if (window_mouseover_id == p_window && p_window != INVALID_WINDOW_ID) {
|
||||||
|
send_window_event(windows[p_window], WINDOW_EVENT_MOUSE_EXIT);
|
||||||
|
}
|
||||||
|
window_mouseover_id = INVALID_WINDOW_ID;
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayServerMacOS::_dispatch_input_events(const Ref<InputEvent> &p_event) {
|
void DisplayServerMacOS::_dispatch_input_events(const Ref<InputEvent> &p_event) {
|
||||||
((DisplayServerMacOS *)(get_singleton()))->_dispatch_input_event(p_event);
|
((DisplayServerMacOS *)(get_singleton()))->_dispatch_input_event(p_event);
|
||||||
}
|
}
|
||||||
@ -2069,9 +2088,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
|
|||||||
|
|
||||||
if (show_cursor && !previously_shown) {
|
if (show_cursor && !previously_shown) {
|
||||||
window_id = get_window_at_screen_position(mouse_get_position());
|
window_id = get_window_at_screen_position(mouse_get_position());
|
||||||
if (window_id != INVALID_WINDOW_ID) {
|
mouse_enter_window(window_id);
|
||||||
send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_mode == MOUSE_MODE_CAPTURED) {
|
if (p_mode == MOUSE_MODE_CAPTURED) {
|
||||||
|
@ -505,9 +505,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayServerMacOS::WindowData &wd = ds->get_window(window_id);
|
|
||||||
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) {
|
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) {
|
||||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_MOUSE_EXIT);
|
ds->mouse_exit_window(window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,9 +516,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayServerMacOS::WindowData &wd = ds->get_window(window_id);
|
|
||||||
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) {
|
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_CAPTURED) {
|
||||||
ds->send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_MOUSE_ENTER);
|
ds->mouse_enter_window(window_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ds->cursor_update_shape();
|
ds->cursor_update_shape();
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
ds->window_set_transient(window_id, DisplayServerMacOS::INVALID_WINDOW_ID);
|
ds->window_set_transient(window_id, DisplayServerMacOS::INVALID_WINDOW_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ds->mouse_exit_window(window_id);
|
||||||
ds->window_destroy(window_id);
|
ds->window_destroy(window_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user