Also, it would be nice to have tests for the case when `rect.left != win->parent->client_rect.left - win->parent->window_rect.left` (same goes for `top`). Specifically, the test should prevent the suggested code from regressing.
I submitted the test as MR !5836. This MR (!5665) fails the added test, and my suggestion fixes it.