window: Move handlers' code to the separate file