diff options
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r-- | platform/x11/os_x11.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index fe162370aa..4606a90835 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -94,7 +94,6 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au last_button_state = 0; xmbstring = NULL; - event_id = 0; x11_window = 0; last_click_ms = 0; args = OS::get_singleton()->get_cmdline_args(); @@ -1143,7 +1142,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { /* Phase 7, send event to Window */ InputEvent event; - event.ID = ++event_id; event.type = InputEvent::KEY; event.device = 0; event.key.mod = state; @@ -1279,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; @@ -1334,7 +1336,6 @@ void OS_X11::process_xevents() { } InputEvent mouse_event; - mouse_event.ID = ++event_id; mouse_event.type = InputEvent::MOUSE_BUTTON; mouse_event.device = 0; mouse_event.mouse_button.mod = get_key_modifier_state(event.xbutton.state); @@ -1360,7 +1361,6 @@ void OS_X11::process_xevents() { last_click_ms = 0; last_click_pos = Point2(-100, -100); mouse_event.mouse_button.doubleclick = true; - mouse_event.ID = ++event_id; } else { last_click_ms += diff; @@ -1447,7 +1447,6 @@ void OS_X11::process_xevents() { Point2i rel = pos - last_mouse_pos; InputEvent motion_event; - motion_event.ID = ++event_id; motion_event.type = InputEvent::MOUSE_MOTION; motion_event.device = 0; @@ -1905,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(); @@ -1916,7 +1918,7 @@ void OS_X11::run() { process_xevents(); // get rid of pending events #ifdef JOYDEV_ENABLED - event_id = joypad->process_joypads(event_id); + joypad->process_joypads(); #endif if (Main::iteration() == true) break; |