Pārlūkot izejas kodu

Merge pull request #64574 from Begah/fix_transient_window_wrap_mouse

Rémi Verschelde 3 gadi atpakaļ
vecāks
revīzija
ff612b6916

+ 2 - 1
scene/gui/spin_box.cpp

@@ -109,8 +109,9 @@ void SpinBox::_range_click_timeout() {
 void SpinBox::_release_mouse() {
 void SpinBox::_release_mouse() {
 	if (drag.enabled) {
 	if (drag.enabled) {
 		drag.enabled = false;
 		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);
 		warp_mouse(drag.capture_pos);
+		Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
 	}
 	}
 }
 }
 
 

+ 1 - 1
scene/main/viewport.cpp

@@ -1104,7 +1104,7 @@ Vector2 Viewport::get_mouse_position() const {
 
 
 void Viewport::warp_mouse(const Vector2 &p_position) {
 void Viewport::warp_mouse(const Vector2 &p_position) {
 	Transform2D xform = get_screen_transform();
 	Transform2D xform = get_screen_transform();
-	Vector2 gpos = xform.xform(p_position).round();
+	Vector2 gpos = xform.xform(p_position);
 	Input::get_singleton()->warp_mouse(gpos);
 	Input::get_singleton()->warp_mouse(gpos);
 }
 }
 
 

+ 1 - 1
scene/main/viewport.h

@@ -563,7 +563,7 @@ public:
 	bool is_input_disabled() const;
 	bool is_input_disabled() const;
 
 
 	Vector2 get_mouse_position() 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);
 	void set_physics_object_picking(bool p_enable);
 	bool get_physics_object_picking();
 	bool get_physics_object_picking();

+ 12 - 0
scene/main/window.cpp

@@ -966,6 +966,18 @@ DisplayServer::WindowID Window::get_window_id() const {
 	return window_id;
 	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) {
 void Window::set_wrap_controls(bool p_enable) {
 	wrap_controls = p_enable;
 	wrap_controls = p_enable;
 	if (wrap_controls) {
 	if (wrap_controls) {

+ 2 - 0
scene/main/window.h

@@ -239,6 +239,8 @@ public:
 	void set_use_font_oversampling(bool p_oversampling);
 	void set_use_font_oversampling(bool p_oversampling);
 	bool is_using_font_oversampling() const;
 	bool is_using_font_oversampling() const;
 
 
+	void warp_mouse(const Vector2 &p_position) override;
+
 	void set_wrap_controls(bool p_enable);
 	void set_wrap_controls(bool p_enable);
 	bool is_wrapping_controls() const;
 	bool is_wrapping_controls() const;
 	void child_controls_changed();
 	void child_controls_changed();