Skip to content

Commit ff612b6

Browse files
authored
Merge pull request #64574 from Begah/fix_transient_window_wrap_mouse
2 parents 0c63942 + 5ac5c8b commit ff612b6

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

scene/gui/spin_box.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ void SpinBox::_range_click_timeout() {
109109
void SpinBox::_release_mouse() {
110110
if (drag.enabled) {
111111
drag.enabled = false;
112-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
112+
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_HIDDEN);
113113
warp_mouse(drag.capture_pos);
114+
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
114115
}
115116
}
116117

scene/main/viewport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ Vector2 Viewport::get_mouse_position() const {
11041104

11051105
void Viewport::warp_mouse(const Vector2 &p_position) {
11061106
Transform2D xform = get_screen_transform();
1107-
Vector2 gpos = xform.xform(p_position).round();
1107+
Vector2 gpos = xform.xform(p_position);
11081108
Input::get_singleton()->warp_mouse(gpos);
11091109
}
11101110

scene/main/viewport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ class Viewport : public Node {
563563
bool is_input_disabled() const;
564564

565565
Vector2 get_mouse_position() const;
566-
void warp_mouse(const Vector2 &p_position);
566+
virtual void warp_mouse(const Vector2 &p_position);
567567

568568
void set_physics_object_picking(bool p_enable);
569569
bool get_physics_object_picking();

scene/main/window.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,18 @@ DisplayServer::WindowID Window::get_window_id() const {
966966
return window_id;
967967
}
968968

969+
void Window::warp_mouse(const Vector2 &p_position) {
970+
Transform2D xform = get_screen_transform();
971+
Vector2 gpos = xform.xform(p_position);
972+
973+
if (transient_parent && !transient_parent->is_embedding_subwindows()) {
974+
Transform2D window_trans = Transform2D().translated(get_position() + (transient_parent->get_visible_rect().size - transient_parent->get_real_size()));
975+
gpos = window_trans.xform(gpos);
976+
}
977+
978+
Input::get_singleton()->warp_mouse(gpos);
979+
}
980+
969981
void Window::set_wrap_controls(bool p_enable) {
970982
wrap_controls = p_enable;
971983
if (wrap_controls) {

scene/main/window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ class Window : public Viewport {
239239
void set_use_font_oversampling(bool p_oversampling);
240240
bool is_using_font_oversampling() const;
241241

242+
void warp_mouse(const Vector2 &p_position) override;
243+
242244
void set_wrap_controls(bool p_enable);
243245
bool is_wrapping_controls() const;
244246
void child_controls_changed();

0 commit comments

Comments
 (0)