This is also my understanding [...]
Thanks, I have updated the MR to use the simpler approach, as discussed above.
Fwiw you could perhaps also do wl_surface_set_user_data(wl_surface, 0) when it is destroyed, but I don't know how whether it synchronizes properly or if it would then require locking.
Access to Wayland object user data is not internally synchronized, and would require locking similar to what we do with the `xdg_surface` user data. In addition, I don't find the benefit to be substantial enough: even if we clear the HWND on `wl_surface` destruction, we are only decreasing, not eliminating, the possibility of an event handler using an invalid HWND value (e.g., the window may be destroyed right after we read the HWND in `pointer_handle_enter`)