Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ImGui_ImplOSX_GetWindowSize and ConvertNSRect #6009

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions backends/imgui_impl_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,18 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
mousePoint = NSEvent.mouseLocation;
mousePoint.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mousePoint.y; // Normalize y coordinate to top-left of main display.
NSScreen* screen = nil;

for (NSScreen* _s : [NSScreen screens])
{
if (NSMouseInRect(mousePoint,[_s frame],false))
{
screen = _s;
break;
}
}

mousePoint.y = screen.frame.size.height - mousePoint.y; // Normalize y coordinate to top-left of current display
}
else
{
Expand Down Expand Up @@ -816,7 +827,7 @@ - (BOOL)canBecomeKeyWindow

static void ConvertNSRect(NSScreen* screen, NSRect* r)
{
r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
r->origin.y = screen.frame.size.height - r->origin.y - r->size.height;
}

static void ImGui_ImplOSX_CreateWindow(ImGuiViewport* viewport)
Expand Down Expand Up @@ -924,7 +935,7 @@ static ImVec2 ImGui_ImplOSX_GetWindowSize(ImGuiViewport* viewport)

NSWindow* window = data->Window;
NSSize size = window.contentLayoutRect.size;
return ImVec2(size.width, size.width);
return ImVec2(size.width, size.height);
}

static void ImGui_ImplOSX_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
Expand Down