summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-03-30 10:34:30 +0200
committerGitHub <noreply@github.com>2017-03-30 10:34:30 +0200
commitaab668752351fb2ad47e2df2826ac332a83c6477 (patch)
tree03167e0b43436c8df606fd8019a2972ad09f012d
parent84bd039851e2b9466599057284cbac40eab430b5 (diff)
parentc79e998d1f12b281530b15d3015e7128418c8a60 (diff)
Merge pull request #8180 from sergey-push/8145-Mouse_Position_is_unknown_until_first_mouse_event
8145 - Mouse Position is unknown until first mouse event on X11
-rw-r--r--platform/windows/os_windows.cpp3
-rw-r--r--platform/x11/os_x11.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index f1a9ba5598..83a6aa6079 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2167,6 +2167,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 6aeab21c7f..4606a90835 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1277,8 +1277,12 @@ void OS_X11::process_xevents() {
case EnterNotify: {
if (main_loop && !mouse_mode_grab)
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;
@@ -1900,6 +1904,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();