On Wed Jun 7 20:54:05 2023 +0000, Rémi Bernon wrote:
Looking at it again, I'm not sure it's a good idea to duplicate the parent / old_parent information, because then it's not obvious that it is in sync with `NtUserGetAncestor(hwnd, GA_PARENT)`. I also don't see any reason there to keep parent except to compare with old_parent. Instead, what do you think about comparing something like `has_surface != needs_surface`, checking the current window parent if needed, and decide whether to create or destroy the surface according to that. If you want to be notified of parent changes, I think you can implement the SetParent driver callback, but I guess you know that already and that it would come later.
Thanks, I will replace the `old_parent/parent` approach with more robust handling.
Actually, in my latest (non-upstream) code, I ended up not using the `SetParent` callback at all, since it has been more convenient to centralize parent handling (regardless of whether it comes from `NtUserSetParent` or `NtUserCreateWindowEx`) in the `WindowPosChanged` callback (which also is transitively called from `NtUserSetParent`). But please let me know if you think that depending on `WindowPosChanged` could prove to be fragile for this, so that I can adapt accordingly.