summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/spin_box.cpp3
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/main/window.cpp12
-rw-r--r--scene/main/window.h2
5 files changed, 18 insertions, 3 deletions
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 517c83545c..ca81a61001 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -105,8 +105,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 764fc60bc1..c80d5a69d3 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1103,7 +1103,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 bf50ca0956..b1890bdbe6 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -974,6 +974,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 aa32edbb04..954e8e8122 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();