Moved mouse button handling to separate function, handle_button_event. The single app mode has been enhanced: The minimazation now works better.