Track hovered `Window` in `DisplayServerX11`
Send mouse-entered/exited window-events only when necessary
This commit is contained in:
parent
16a93563bf
commit
a7c5849f98
|
@ -379,7 +379,11 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
|
|||
|
||||
if (show_cursor && !previously_shown) {
|
||||
WindowID window_id = get_window_at_screen_position(mouse_get_position());
|
||||
if (window_id != INVALID_WINDOW_ID) {
|
||||
if (window_id != INVALID_WINDOW_ID && window_mouseover_id != window_id) {
|
||||
if (window_mouseover_id != INVALID_WINDOW_ID) {
|
||||
_send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
|
||||
}
|
||||
window_mouseover_id = window_id;
|
||||
_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
|
||||
}
|
||||
}
|
||||
|
@ -1449,6 +1453,11 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
|
|||
|
||||
DEBUG_LOG_X11("delete_sub_window: %lu (%u) \n", wd.x11_window, p_id);
|
||||
|
||||
if (window_mouseover_id == p_id) {
|
||||
window_mouseover_id = INVALID_WINDOW_ID;
|
||||
_send_window_event(windows[p_id], WINDOW_EVENT_MOUSE_EXIT);
|
||||
}
|
||||
|
||||
window_set_rect_changed_callback(Callable(), p_id);
|
||||
window_set_window_event_callback(Callable(), p_id);
|
||||
window_set_input_event_callback(Callable(), p_id);
|
||||
|
@ -4291,7 +4300,8 @@ void DisplayServerX11::process_events() {
|
|||
break;
|
||||
}
|
||||
|
||||
if (!mouse_mode_grab) {
|
||||
if (!mouse_mode_grab && window_mouseover_id == window_id) {
|
||||
window_mouseover_id = INVALID_WINDOW_ID;
|
||||
_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
|
||||
}
|
||||
|
||||
|
@ -4303,7 +4313,11 @@ void DisplayServerX11::process_events() {
|
|||
break;
|
||||
}
|
||||
|
||||
if (!mouse_mode_grab) {
|
||||
if (!mouse_mode_grab && window_mouseover_id != window_id) {
|
||||
if (window_mouseover_id != INVALID_WINDOW_ID) {
|
||||
_send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
|
||||
}
|
||||
window_mouseover_id = window_id;
|
||||
_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -225,6 +225,7 @@ class DisplayServerX11 : public DisplayServer {
|
|||
|
||||
List<WindowID> popup_list;
|
||||
|
||||
WindowID window_mouseover_id = INVALID_WINDOW_ID;
|
||||
WindowID last_focused_window = INVALID_WINDOW_ID;
|
||||
|
||||
WindowID window_id_counter = MAIN_WINDOW_ID;
|
||||
|
|
Loading…
Reference in New Issue