It took me hours of researching and try and error to find a solution. Resizing the window with wmctrl did only work, after I resized it once with my mouse and was therefore not suited for a mouse and keyboard-less setup. Furthermore did I want to achieve a true Fullscreen-mode for the best kiosk-like experience. This is how it finally worked for me:
First set your second display in clone-mode, so that it clones display one (in my case at a Raspberry Pi 4 HDMI-1 and HDMI-2):
xrandr --output HDMI-2 --same-as HDMI-1
Next determine your screen dimensions:
xrandr
This gives you a list of connected screens and their resolutions. You then have to compute the total screen size of all monitors together by adding them up. I attached two 1280x1024 monitors, so my total screen size combined is 2560x1024. As xrandr does not allow us to set a screen size larger than the monitor itself via the --fb flag, we use the --panning option:
xrandr --output HDMI-1 --panning 2560x1024+0+0/0x0+0+0/0/0/0/0
This sets a larger screen but only displays a portion of it on monitor 1. It also disables mouse panning, as we want monitor 2 to display the rest of the image. Last we have to pan monitor 2 to the right half of the large screen with:
xrandr --output HDMI-2 --pos 1280x0
and 1280 being the end of monitor 1.
You can now put the three commands in autostart to have them enabled on startup.
Some final remarks:
If you are on a SSH-Session, you have to add DISPLAY=:0 at the beginning of your xrandr-commands (e.g. DISPLAY=:0 xrandr --output HDMI-2 --same-as HDMI-1).
When you want to achieve a videowall like look, you can easily implement bezel-compensation by enlarging your virtual screen. In my case the bezels of my monitor are roughly 64 pixels thick, so you would set your output on monitor 1 to 2624 instead of 2560. Then you set your second monitor to start at pos 1344x0 leaving 64 pixels not displayed.
Links that helped:
https://bbs.archlinux.org/viewtopic.php?id=214841 http://www.straightrunning.com/tools/xrandr.html#sect3 http://www.mshopf.de/pub/Fosdem_2009_randr13_Slides.pdf Treat 2 displays as 1 in Raspbian
Good luck!