My sample of code does letterbox for screen. Is this what you need?
I have tried your code. It seems to work but it is not really...
In most screens (battlescape, geoscape, introduction) the image is put on the left, it is ugly.
Change the size multiple times after the game start, and you are doomed.
Not speaking you consider there are only wide screens (I love my 5/4 secondary screen and play most games with it), and why the hell should fullscreen mode not be letterboxed if the user wish it?
I must admit your idea is a good base: this method handle mouse cursor very well. Increasing the size of the screen before enlarging it is probably the only way to draw the cursor in the black bands. But your ten lines of code are not enough at all.
Edit:
For GeoScape, I have tried using centerAllSurfaces(), but the globe does not like this. It's better using an offset for the surface, globe, and each button.
With Battlescape, centerAllSurfaces() works better, but the scrolling with mouse cursor does not function, it seems to uses coordinates relatives to the window rather than relative to the shown screen.