summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorC.Even <c.even@live.cn>2022-03-24 18:04:41 +0800
committerC.Even <c.even@live.cn>2022-03-24 18:04:41 +0800
commit6866eee64185c1f71c4d2a6603621dc0a1b368c1 (patch)
tree53d3c245c6de51d8531660ebf6c6410e786afee4
parentbab2ad4d3283a9b4e6050a2345a4ea408001484e (diff)
Fix PopupMenu behavior on MacOS when multiple monitors are used
* DisplayServerOSX::mouse_get_position returns wrong x axis data in multi-monitor case, which makes mouse_process_popups send WINDOW_EVENT_CLOSE_REQUEST, then eventually make PopupMenu close on mouse down without activating item.
-rw-r--r--platform/osx/display_server_osx.mm6
1 files changed, 5 insertions, 1 deletions
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 9e32cab5ed..8820201c10 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -1682,7 +1682,11 @@ Point2i DisplayServerOSX::mouse_get_position() const {
for (NSScreen *screen in [NSScreen screens]) {
NSRect frame = [screen frame];
if (NSMouseInRect(mouse_pos, frame, NO)) {
- return Vector2i((int)mouse_pos.x, (int)-mouse_pos.y) * scale + _get_screens_origin();
+ Vector2i pos = Vector2i((int)mouse_pos.x, (int)mouse_pos.y);
+ pos *= scale;
+ pos -= _get_screens_origin();
+ pos.y *= -1;
+ return pos;
}
}
return Vector2i();