Skip to content

Commit

Permalink
fix warp_mouse not triggering events such as mouse_entered on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
BimDav committed Mar 28, 2024
1 parent 86415f0 commit c8cecdd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,30 @@
if (mouse_mode != MOUSE_MODE_CONFINED && mouse_mode != MOUSE_MODE_CONFINED_HIDDEN) {
CGAssociateMouseAndMouseCursorPosition(true);
}

NSPoint delta = NSMakePoint(pointInWindowRect.origin.x - wd.mouse_pos.x, pointInWindowRect.origin.y - wd.mouse_pos.y);
NSPoint mpos = pointInWindowRect.origin;

if (update_mouse_wrap(wd, delta, mpos, [[NSProcessInfo processInfo] systemUptime])) {
return;
}

Ref<InputEventMouseMotion> mm;
mm.instantiate();

mm->set_window_id(window_id);
mm->set_button_mask(mouse_get_button_state());
update_mouse_pos(wd, mpos);
mm->set_position(wd.mouse_pos);
mm->set_pressure(0);
mm->set_global_position(wd.mouse_pos);
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
mm->set_screen_velocity(mm->get_velocity());
const Vector2i relativeMotion = Vector2i(delta.x, delta.y) * screen_get_max_scale();
mm->set_relative(relativeMotion);
mm->set_relative_screen_position(relativeMotion);

Input::get_singleton()->parse_input_event(mm);
}
}

Expand Down

0 comments on commit c8cecdd

Please sign in to comment.