Skip to content

Commit

Permalink
flip mouse coordinates with top coordinate of current screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkosivulainen committed Dec 21, 2022
1 parent 506c6b8 commit 9ffb69b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 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

0 comments on commit 9ffb69b

Please sign in to comment.