summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-19 00:10:11 +0200
committerGitHub <noreply@github.com>2019-06-19 00:10:11 +0200
commitbb16dd71d1f95ef2f2b63c2c700112ff1a2fc59b (patch)
tree2cd11f819b5a9833d446b2605828e44761353233
parent58fe658f9d9312ff5c1dac727c4754960c0a975f (diff)
parente19b6296e32f9a6241b5c3a79b6f1caaa2813357 (diff)
Merge pull request #29876 from bruvzg/init_mouse_pos_macos
Update macOS global mouse position at startup
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm11
2 files changed, 12 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 0ca94e3a63..1e996608af 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -188,6 +188,7 @@ public:
virtual void warp_mouse_position(const Point2 &p_to);
virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
+ void update_real_mouse_position();
virtual void set_window_title(const String &p_title);
virtual Size2 get_window_size() const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index dade07ffda..4f84ae9c50 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1569,6 +1569,9 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
if (p_desired.layered) {
set_window_per_pixel_transparency_enabled(true);
}
+
+ update_real_mouse_position();
+
return OK;
}
@@ -1907,6 +1910,12 @@ void OS_OSX::warp_mouse_position(const Point2 &p_to) {
}
}
+void OS_OSX::update_real_mouse_position() {
+
+ get_mouse_pos([window_object mouseLocationOutsideOfEventStream], [window_view backingScaleFactor]);
+ input->set_mouse_position(Point2(mouse_x, mouse_y));
+}
+
Point2 OS_OSX::get_mouse_position() const {
return Vector2(mouse_x, mouse_y);
@@ -2357,6 +2366,8 @@ void OS_OSX::set_window_position(const Point2 &p_position) {
// Godot passes a positive value
position.y *= -1;
set_native_window_position(get_screens_origin() + position);
+
+ update_real_mouse_position();
};
Size2 OS_OSX::get_window_size() const {