In my case, running Yosemite and the latest version of xquartz, going through
ssh -X to CentOS 6.5 in VMWare Fusion, I could not resolve that problem with switching layouts. US and Russian layouts, in my case. When I started, for example,
gnome-terminal, I just couldn't switch to my RU language, using any key combinations. So, after half a day of experimenting (I am not really a Linux geek, just kinda "half-of-a-power" user), I found a solution.
~/.profile should look like this:
If you use another language, change
LC_ALL= for your language in your MacOs.
Then you need to add the following line at the end of your
~/.bash_profile on your ssh-connected machine (in my case - CentOS 6.5)
setxkbmap -rules evdev -model pc104 -layout us,ru
This goes correctly, especially for the Russian language. But I am sure your OS must have another collection of layouts. And, at the end - ensure, than you enabled "Follow system keyboard layout" in X11->Preferences->Input tab.
After these manipulations, forwarded through ssh-X11, the GUI of your application will be able to switch layouts, using your usual MacOS shortcut. In my case, Command+Space. Don't forget to restart X11.
Maybe this will help someone ;-)
P.S.: in this example, I worked only with the Russian layout and keymap, so, again, change parameters for your own!