fix a bug when minimizing a maximized window

Pull request redirected.

Fix a minimize bug.