Esme Povirk (@madewokherd) commented about dlls/uiautomationcore/uia_com_client.c:
LIST_FOR_EACH_ENTRY(event, &entry->handlers_list, struct uia_com_event, event_handler_map_list_entry){if (uia_hwnd_map_check_hwnd(&event->focus_hwnd_map, hwnd))continue;/* Advise provider that we're listening for focus events. */hr = uia_event_advise_node((struct uia_event *)event->event, node);if (FAILED(hr))WARN("uia_event_advise_node failed with hr %#lx\n", hr);hr = uia_hwnd_map_add_hwnd(&event->focus_hwnd_map, hwnd);if (FAILED(hr))WARN("Failed to add hwnd for focus winevent, hr %#lx\n", hr);}- }
There should probably be a corresponding EVENT_OBJECT_DESTROY handler in case hwnds are reused.