diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-11-10 18:23:10 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-11-11 07:52:16 +0100 |
commit | 52d75c9b35a8a25fb439dad335716a1a3f6d5007 (patch) | |
tree | f72aee0ff5ca31c9698ba333a50b07c38d85659f /platform/linuxbsd/x11 | |
parent | dca5cb8e40fd2a348a59ea73c597eb742c14c980 (diff) |
Fix unsent WINDOW_EVENT_MOUSE_ENTER event on mouse_mode-change
coauthor: @bruvzg
On linuxbsd and macOS the WINDOW_EVENT_MOUSE_ENTER was not sent,
when the mouse became visible again after a mouse_mode-change.
Diffstat (limited to 'platform/linuxbsd/x11')
-rw-r--r-- | platform/linuxbsd/x11/display_server_x11.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index c3a86c69e1..2e60ad8f45 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -376,10 +376,18 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) { } // The only modes that show a cursor are VISIBLE and CONFINED - bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED); + bool show_cursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED); + bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED); + + if (show_cursor && !previously_shown) { + WindowID window_id = get_window_at_screen_position(mouse_get_position()); + if (window_id != INVALID_WINDOW_ID) { + _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER); + } + } for (const KeyValue<WindowID, WindowData> &E : windows) { - if (showCursor) { + if (show_cursor) { XDefineCursor(x11_display, E.value.x11_window, cursors[current_cursor]); // show cursor } else { XDefineCursor(x11_display, E.value.x11_window, null_cursor); // hide cursor |