Copied initial window ui logic from Siiri's commit (that was tragically lost)