summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-03-07 11:18:46 +0100
committerGitHub <noreply@github.com>2019-03-07 11:18:46 +0100
commit69761816381f11536980441265345ba055ad1c26 (patch)
tree7ea21a7ea06ebb26b506292138abb692d94cd93c
parenteb4a6a8147ad268802f59a9a2273a39e3da4a35e (diff)
parentb717eb714c02c12c8a0475e32439b569d9cf40bf (diff)
Merge pull request #26696 from TweaklabOrg/master
OS X: update mouse position on mouse down
-rw-r--r--platform/osx/os_osx.mm11
1 files changed, 4 insertions, 7 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 0b19f8c002..b45d0d80e6 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -102,8 +102,6 @@ static void push_to_key_event_buffer(const OS_OSX::KeyEvent &p_event) {
static int mouse_x = 0;
static int mouse_y = 0;
-static int prev_mouse_x = 0;
-static int prev_mouse_y = 0;
static int button_mask = 0;
static bool mouse_down_control = false;
@@ -601,12 +599,13 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
Ref<InputEventMouseButton> mb;
mb.instance();
-
+ const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
+ const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
get_key_modifier_state([event modifierFlags], mb);
mb->set_button_index(index);
mb->set_pressed(pressed);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
+ mb->set_position(pos);
+ mb->set_global_position(pos);
mb->set_button_mask(button_mask);
if (index == BUTTON_LEFT && pressed) {
mb->set_doubleclick([event clickCount] == 2);
@@ -642,8 +641,6 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
mm.instance();
mm->set_button_mask(button_mask);
- prev_mouse_x = mouse_x;
- prev_mouse_y = mouse_y;
const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
mm->set_position(pos);