diff options
| author | Sergey Pusnei | 2017-03-27 21:37:23 -0400 |
|---|---|---|
| committer | Rémi Verschelde | 2017-04-05 08:08:08 +0200 |
| commit | e5d63aaece5310aee39ba1da9a595fc7a8410a50 (patch) | |
| tree | 80809f6e8c072f8e864f67ffb5e39d477772a198 | |
| parent | 1c17e5b38d180a35be24104456f6d87c50c10b8c (diff) | |
| download | godot-e5d63aaece5310aee39ba1da9a595fc7a8410a50.tar.gz godot-e5d63aaece5310aee39ba1da9a595fc7a8410a50.tar.zst godot-e5d63aaece5310aee39ba1da9a595fc7a8410a50.zip | |
8145 - Mouse Position is unknown until first mouse event on X11 & Win
- X11 update input->pos on EnterNotify
- X11 & Win call first-time events processing before main initialization
(cherry picked from commit c79e998d1f12b281530b15d3015e7128418c8a60)
| -rw-r--r-- | platform/windows/os_windows.cpp | 3 | ||||
| -rw-r--r-- | platform/x11/os_x11.cpp | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2b9574458..436c6ebf4 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2176,6 +2176,9 @@ void OS_Windows::run() { if (!main_loop) return; + // Process all events before the main initialization so the cursor will get initialized properly + process_events(); // get rid of pending events + main_loop->init(); uint64_t last_ticks = get_ticks_usec(); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5a829d62d..3975a6184 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1282,8 +1282,12 @@ void OS_X11::process_xevents() { if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER); - if (input) + if (input) { + // Update mouse position. It is triggered before mouse motion. + Point2i pos(event.xmotion.x, event.xmotion.y); + input->set_mouse_pos(pos); input->set_mouse_in_window(true); + } } break; case FocusIn: minimized = false; @@ -1893,6 +1897,9 @@ void OS_X11::run() { if (!main_loop) return; + // Process all events before the main initialization so the cursor will get initialized properly + process_xevents(); // get rid of pending events + main_loop->init(); // uint64_t last_ticks=get_ticks_usec(); |
