fix the max and restore of window function.
fix the conflict between emacs and system
fix the conflict