From d896eab16620f80e3cae9b164eb62f71b47f6e45 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 13 Jun 2025 17:48:02 +0200 Subject: [PATCH] Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our viewports. Amend 7ac99a4 for docking. (#8644) --- backends/imgui_impl_osx.mm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index 2c82bd615..6fb28bd64 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -699,10 +699,15 @@ static ImGuiMouseSource GetMouseSource(NSEvent* event) static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) { // Only process events from the window containing ImGui view - if (event.window != view.window) + void* event_handle = (__bridge void*)(event.window); + void* view_handle = (__bridge void*)(view.window); + if (event_handle == nullptr || view_handle == nullptr) + return false; + ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(view_handle); + if (viewport == nullptr || viewport->PlatformHandleRaw != event_handle) return false; - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::GetIO(); if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown) { int button = (int)[event buttonNumber];