On Thu Aug 31 12:01:48 2023 +0000, Alexandros Frantzis wrote:
My concern with the above is that the window (and backing wayland surface) could be destroyed (from a different thread) between getting the `hwnd` and setting it as the pointer focus, so we will end up with an invalid `pointer.hwnd` value. Although I am not a big fan of double locking either, having an inconsistent state like this also scares me. That being said, I think that *at the moment* such an inconsistency would be inconsequential, *as long as the HWND value is not reused* (at least not in any reasonable timeframe). Is there a strong practical guarantee about this? In such a case sending input events to the destroyed HWND would be nops and we would use `wayland_surface_lock_hwnd()` to get the surface when we need it (e.g, in `enter` to set the cursor, and in the future we will need it in `motion` for proper input coordinate system transformations), which would return NULL for a destroyed HWND. If this approach sounds more appealing than what is currently proposed, I will need to explore it more and ensure (for some value of "ensure") that there aren't any other races or edge cases that could affect us (especially related to concurrent window destruction).
I believe user handles have a generation that should guarantee against re-use.