From 3a51d41ef450ae25570fff098d8ca8a8a7dd3cd8 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Fri, 15 Apr 2022 22:07:08 +0200 Subject: [PATCH] Adjust rect to match swing coordinate system --- macos/src/main/objcpp/Decorations.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macos/src/main/objcpp/Decorations.mm b/macos/src/main/objcpp/Decorations.mm index 109121a6..67b482fd 100644 --- a/macos/src/main/objcpp/Decorations.mm +++ b/macos/src/main/objcpp/Decorations.mm @@ -174,9 +174,13 @@ JNF_COCOA_ENTER(env); if (minimizeButton) rect = join(rect, minimizeButton); if (zoomButton) rect = join(rect, zoomButton); + if (rect.size.width >= 0 && rect.size.height >= 0) { + rect.origin.y = nsWindow.contentView.bounds.size.height - (rect.origin.y + rect.size.height); + } + jfloatArray bounds = env->NewFloatArray(4); jfloat rawBounds[4] = {rect.origin.x, rect.origin.y, rect.size.width, rect.size.height}; - env->SetFloatArrayRegion(bounds, 0, 0, rawBounds); + env->SetFloatArrayRegion(bounds, 0, 4, rawBounds); return bounds; JNF_COCOA_EXIT(env);