This patch replaces global variable 'window-system-version' with the function which returns the window system version for the specified frame. An obvious reason for this is to have correct results when Emacs is running with both TTY and X frames. Dmitry