Trigger events when removing foreground window.

Removed window moves to background and the new foreground window is
notified.
Small fixes.