From 86f2af2bc7a0e828f9aebd6d03d0547db45d663f Mon Sep 17 00:00:00 2001 From: Akira Maezawa Date: Wed, 2 Nov 2022 01:52:20 +0900 Subject: [PATCH] Backends: OSX: Fixed mouse coordinate before clicking on the host window. (#5842) --- backends/imgui_impl_osx.mm | 3 +++ docs/CHANGELOG.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index 054776ff..2505bbd3 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -23,6 +23,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2022-11-02: Fixed mouse coordinates before clicking the host window. // 2022-10-06: Fixed mouse inputs on flipped views. // 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported). // 2022-05-03: Inputs: Removed ImGui_ImplOSX_HandleEvent() from backend API in favor of backend automatically handling event capture. @@ -631,6 +632,8 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged) { NSPoint mousePoint = event.locationInWindow; + if (event.window == nil) + mousePoint = [[view window] convertPointFromScreen:mousePoint]; mousePoint = [view convertPoint:mousePoint fromView:nil]; if ([view isFlipped]) mousePoint = NSMakePoint(mousePoint.x, mousePoint.y); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b10e57dc..630a1d81 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -193,6 +193,7 @@ Other Changes: - Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz] - Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738). - Backends: OSX: Fixed mouse inputs on flipped views. (#5756) [@Nemirtingas] +- Backends: OSX: Fixed mouse coordinate before clicking on the host window. (#5842) [@maezawa-akira] - Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]