Skip to content

Commit

Permalink
Merge pull request #56755 from madmiraal/fix-45592-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jan 24, 2022
2 parents 50a672e + b754563 commit ed86972
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
15 changes: 8 additions & 7 deletions main/input_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,20 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
Ref<InputEventMouseMotion> mm = p_event;

if (mm.is_valid()) {
Point2 pos = mm->get_global_position();
if (mouse_pos != pos) {
set_mouse_position(pos);
Point2 position = mm->get_global_position();
if (mouse_pos != position) {
set_mouse_position(position);
}
Vector2 relative = mm->get_relative();
mouse_speed_track.update(relative);

if (main_loop && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) {
Ref<InputEventScreenDrag> drag_event;
drag_event.instance();

drag_event->set_position(mm->get_position());
drag_event->set_relative(mm->get_relative());
drag_event->set_speed(mm->get_speed());
drag_event->set_position(position);
drag_event->set_relative(relative);
drag_event->set_speed(get_last_mouse_speed());

main_loop->input_event(drag_event);
}
Expand Down Expand Up @@ -552,7 +554,6 @@ void InputDefault::set_main_loop(MainLoop *p_main_loop) {
}

void InputDefault::set_mouse_position(const Point2 &p_posf) {
mouse_speed_track.update(p_posf - mouse_pos);
mouse_pos = p_posf;
}

Expand Down
1 change: 0 additions & 1 deletion platform/javascript/os_javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ void OS_JavaScript::mouse_move_callback(double p_x, double p_y, double p_rel_x,
ev->set_global_position(ev->get_position());

ev->set_relative(Vector2(p_rel_x, p_rel_y));
os->input->set_mouse_position(ev->get_position());
ev->set_speed(os->input->get_last_mouse_speed());

os->input->parse_input_event(ev);
Expand Down
1 change: 0 additions & 1 deletion platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ - (void)mouseMoved:(NSEvent *)event {
mm->set_relative(relativeMotion);
get_key_modifier_state([event modifierFlags], mm);

OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
OS_OSX::singleton->push_input(mm);
}

Expand Down
4 changes: 0 additions & 4 deletions platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

mm->set_position(c);
mm->set_global_position(c);
input->set_mouse_position(c);
mm->set_speed(Vector2(0, 0));

if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) {
Expand Down Expand Up @@ -504,7 +503,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetCursorPos(pos.x, pos.y);
}

input->set_mouse_position(mm->get_position());
mm->set_speed(input->get_last_mouse_speed());

if (old_invalid) {
Expand Down Expand Up @@ -648,7 +646,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetCursorPos(pos.x, pos.y);
}

input->set_mouse_position(mm->get_position());
mm->set_speed(input->get_last_mouse_speed());

if (old_invalid) {
Expand Down Expand Up @@ -750,7 +747,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetCursorPos(pos.x, pos.y);
}

input->set_mouse_position(mm->get_position());
mm->set_speed(input->get_last_mouse_speed());

if (old_invalid) {
Expand Down
1 change: 0 additions & 1 deletion platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2828,7 +2828,6 @@ void OS_X11::process_xevents() {
mm->set_button_mask(get_mouse_button_state());
mm->set_position(posi);
mm->set_global_position(posi);
input->set_mouse_position(posi);
mm->set_speed(input->get_last_mouse_speed());

mm->set_relative(rel);
Expand Down

0 comments on commit ed86972

Please sign in to comment.