Now I got two laptops and want to work on both simultaneously. I found this article.
https://www.linuxjournal.com/content/share-keyboardmouse-between-multiple-computers-x2x
It introduced x2x and two ways to use it. (1) through SSL tunnel, which is secure, easier, and (2) through X TCP port 6000. The article mentioned that the second way is insecure, more difficult to set up, but the benefit is that copy and past now works.
My own experience.
Way (1) works. Simple and secure. Copy and paste in fact works. Just ctrl-v or right click / paste does not work. Use mid button.
Way (2) works. Open up TCP port 6000 takes some effort because each Ubuntu version uses different display manager and the required configuration differs. Also the effect of way 2 is not good, the mouse pointer's response is delayed.
Conclusion: I will just stick with (1)
primary $ ssh -X secondary x2x -east -to :0