diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-26 13:54:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 13:54:23 +0200 |
commit | ff612b6916876f890113d0241b39273d400314b6 (patch) | |
tree | fd6cc7e596c080012ee98d65766d9c94af239ace /scene | |
parent | 0c639428dd4e4d92a6211c3bb4d04c3af1a4d266 (diff) | |
parent | 5ac5c8bc0693465ab5bd8e21adcded10898c1a55 (diff) |
Merge pull request #64574 from Begah/fix_transient_window_wrap_mouse
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/spin_box.cpp | 3 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.h | 2 | ||||
-rw-r--r-- | scene/main/window.cpp | 12 | ||||
-rw-r--r-- | scene/main/window.h | 2 |
5 files changed, 18 insertions, 3 deletions
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 0ac4d9d8ce..65c4a09c84 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -109,8 +109,9 @@ void SpinBox::_range_click_timeout() { void SpinBox::_release_mouse() { if (drag.enabled) { drag.enabled = false; - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_HIDDEN); warp_mouse(drag.capture_pos); + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 36cc8ebfa2..cc8bced780 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1104,7 +1104,7 @@ Vector2 Viewport::get_mouse_position() const { void Viewport::warp_mouse(const Vector2 &p_position) { Transform2D xform = get_screen_transform(); - Vector2 gpos = xform.xform(p_position).round(); + Vector2 gpos = xform.xform(p_position); Input::get_singleton()->warp_mouse(gpos); } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index a0ec2d54dd..83083cd65a 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -563,7 +563,7 @@ public: bool is_input_disabled() const; Vector2 get_mouse_position() const; - void warp_mouse(const Vector2 &p_position); + virtual void warp_mouse(const Vector2 &p_position); void set_physics_object_picking(bool p_enable); bool get_physics_object_picking(); diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 68037a1211..35414da9ed 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -966,6 +966,18 @@ DisplayServer::WindowID Window::get_window_id() const { return window_id; } +void Window::warp_mouse(const Vector2 &p_position) { + Transform2D xform = get_screen_transform(); + Vector2 gpos = xform.xform(p_position); + + if (transient_parent && !transient_parent->is_embedding_subwindows()) { + Transform2D window_trans = Transform2D().translated(get_position() + (transient_parent->get_visible_rect().size - transient_parent->get_real_size())); + gpos = window_trans.xform(gpos); + } + + Input::get_singleton()->warp_mouse(gpos); +} + void Window::set_wrap_controls(bool p_enable) { wrap_controls = p_enable; if (wrap_controls) { diff --git a/scene/main/window.h b/scene/main/window.h index b1ae633997..4146390e97 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -239,6 +239,8 @@ public: void set_use_font_oversampling(bool p_oversampling); bool is_using_font_oversampling() const; + void warp_mouse(const Vector2 &p_position) override; + void set_wrap_controls(bool p_enable); bool is_wrapping_controls() const; void child_controls_changed(); |