Merge "Postpone window_state_changed events until the window is added" into tm-dev