My husband had made the wood backing for the cushion when we first built the window seat. Cut your foam to be flush or just a tad bigger than your backing.
I like to lay the cushion centered on top of my fabric for stapling. I go around the cushion with my staple gun tugging on the fabric but not too tightly, just enough to get a nice, smooth fit.