Detect window state upon restart and map them correctly.

There is the XWindowAttributes that holds all important information
about a window; using this I can restore the pre-restart state.