The window hiding logic is mostly the same both in X11 and Wayland windows, so let's move it in Window to share the same code.