Kasperian Moving Parts

kinda like batman, but with a wife and 3 kids

Multi-Monitor Setup On A Single Physical Head (Now Better!)

| 17 Comments

That’s a big title, eh? I blogged previously about setting up a multi-head X environment for development and testing, even though I’m working on a laptop with only one card. My previous attempt used Xdmx and multiple Xephyr displays, and there were some problems with it. Thankfully, Lubos commented about his nifty little fakexinerama library that achieves the same result only MUCH easier (easierly?) and without any of the problems that I’d seen using Xdmx/Xephyr(1..n). Here, then, is a description of what I’ve done and the results….

This is a screenshot from within the Xephyr session, showing the 1600×1200 Xephyr display. The cool thing is that using ksnapshot from within the Xephyr session will actually capture the entire display, not just what fits on your host display. This is important for me because my laptop LCD display is only 1680×1050, so I can’t actually fit the entire Xephyr display inside my real physical display. Nice to know, definitely, since this means that I can create a monstrous Xephyr display that doesn’t fit inside my actual host display and still get full-display snapshots out of it. So what you see here is a KDE3 session spanning all 4 Xinerama heads. Kicker correctly only spans head 1. VMware Workstation is on head 2, in full-screen mode, but only full-screened on the second head. It can span more than 1 head as I’ll show further down.

screenshot-ws-fullscreen-enabled

To achieve this, I downloaded seli’s fakexinerama library, compiled it in ~/build/ like this:

gcc -O2 -Wall Xinerama.c -fPIC -o libXinerama.so.1.0 -shared
ln -s libXinerama.so.1.0 libXinerama.so.1
ln -s libXinerama.so.1 libXinerama.so

I then copied the real /usr/lib/libXinerama.so.1.0.0 to /usr/lib/libXinerama.so.1.0.0.real (make sure you backup your library!) and set up an alias in my ~/.profile so that I can easily switch on and off this fake xinerama library. When I start up my real host session, I don’t want to be using fakexinerama, but when I launch my Xephyr session for multimon development, I do need it to be there.

xin () {
if [ “$1″ = “real” ]
then
sudo cp /usr/lib/libXinerama.so.1.0.0.real /usr/lib/libXinerama.so.1.0.0
elif [ “$1″ = “fake” ]
then
sudo cp ~/builds/libXinerama.so.1.0 /usr/lib/libXinerama.so.1.0.0
else
echo “real or fake?”
fi
}

Here’s the contents of my ~/.fakexinerama config file:

#Configuration file ~/.fakexinerama
#
# The format of the file is rather strict. Lines beginning with # are comments. First line is one
# number, specifying number of screens. This line must be followed by this number of lines, each
# containing four numbers: X Y W H, i.e. screen’s X and Y origin, width and height.
4
0 0 800 600
800 0 800 600
0 600 800 600
800 600 800 600

This establishes a 2×2 4-head xinerama configuration. Next up is creating the Xephyr display. From within your regular host session:

Xephyr :2.0 -ac -br +xinerama -screen 1600×1200 &
xterm -display :2&

You should now have a single Xephyr screen that’s 1600×1200 pixels with an xterm running inside of it. Now switch focus to the new xterm window and turn on the fakexinerama library and start up a KDE3 session:

xin fake
startkde
# (and when you’re done with this little environment, make sure you return your system to sanity by running “xin real”)

That’s about it. Really cool stuff. One last little screenshot… This one shows VMware Workstation spanning multiple heads. This obviously works with real external monitors as well. The way it works is by clicking the little monitor button to the right of the “View” menu. This tells Workstation to cycle through the available display topologies. So, on first press, Workstation spread across all 4 heads (fullscreen multimonitor, largest topology). Second press took on this configuration that I screengrabbed (vertical span). Third press spread Workstation horizontally across the first 2 heads. And then 4th press returned Workstation to just fullscreen on head 2 (where I started it from).

screenshot-ws-fullscreen-enabled-multimonvert

One last thought on the subject… One of the things I’m hopefully going to be able to work on in the next couple of months is implementing the new EWMH _NET_WM_FULLSCREEN_MONITORS hint in various X window managers. Currently, Workstation does some internal gyrations to convince window managers to allow our undecorated fullscreen window to maximize over multiple monitors/heads. _NET_WM_FULLSCREEN_MONITORS was the hint that was recently added to the EWMH spec to correctly accomplish this, but as far as I know, it hasn’t been added to any window managers yet. I’m excited about getting the chance to get up to speed on some window manager internals again! It’s been a while since I’ve last had the chance to do that (bbkeys/blackbox days of yore!).

Anyway, hope this helps someone else set up a multi-head dev/test environment, should the need arise. =:)

Author: Jason 'vanRijn' Kasper

My name is Jason 'vanRijn' Kasper. I am the ring leader of the amazing Kasper family. I am unashamedly a Christian Geek. These are our stories....

17 Comments

  1. I wonder if it is possible to tie different workspaces to each xinerama head? THAT would be great!

    When I work with xinerama on two monitors, I would love to switch workspace independently on each monitor(with kwin)

  2. Very sweet. This means that one can now use one single monitor and fake two displays !
    So I could use one half of a 32” 1900×1080 big LCD TV-screen to display pdf files in “full window mode” and the other half to do real work, using maximized windows who never will obscure my pdfs… I like it :-D

  3. … only MUCH more easily …

  4. Thanks for these posts.

    But shouldn’t this work too:

    Xephyr :1 -ac -br +xinerama -origin 0,0 -screen 640×480 -origin 640,0 -screen 640×480 -origin 0,480 -screen 640×480 -origin 640,480 -screen 640×480

    ?

    You have 4 ‘real’-Xephyr windows but the mouse movement is a little strange.

  5. Hi Bert! =:) I tried your command, but I only got one Xephyr window? It does think it has 4 heads, but there’s only one Xephyr window, sized 640×480??

  6. KDE 4.2b2 should now have suport for _NET_WM_FULLSCREEN_MONITORS EWMH spec hint
    http://techbase.kde.org/Schedules/KDE4/4.2_Changelog#KWin

  7. Hi Daniel! =:) Yep, I know… I put it there. =:)

  8. I was wondering where that background is from…the dark one with the katana ? Would it be possible to get it ?

    Thanks :)

    devilhorns

  9. Hey @Christopher! I believe it’s this one: http://web.me.com/ctt1wbw/Katana2.jpg.The filename I have on my hard drive is 200807052623-7698.jpg. I think I got it from deviantart or socwall originally. HTH! =:)

  10. Thank you very much Jason ! :) I noticed on one of your other posts that you were modifying window managers…I am a developer for Enlightenment so if there is anything I can do for you, let me know :)

    Cheers,
    devilhorns

  11. Have you got the http://ktown.kde.org/~seli/fakexinerama/ file. This website is down. I can’t find it !

    Thanks !

  12. Hey there! Aw, man, I’m sorry, Christopher, I didn’t see your comment until now. =:( Thanks for the offer!!!

    @rivsc: Yeah, I do have it. I just saw this though, and this looks like it might be even easier: http://lists.suckless.org/dev/0910/1599.html Yeah, in fact, that looks better. But here’s what I have:

    http://pastebin.com/Gz8wE7CB

    And here’s instructions for how to use it:

    http://superuser.com/questions/115076/how-to-vertically-split-widescreen-into-two-virtual-workspaces-on-ubuntu-gnome

    Hope this helps! =:)

  13. i get this error when i try to compile fakeXinerama file
    any suggestion, what can i do.

    thanks

    gcc -O2 -Wall Xinerama.c -fPIC -o libXinerama.so.1.0 -shared
    Xinerama.c:29:37: fatal error: X11/extensions/Xinerama.h: No such file or directory
    compilation terminated.

  14. Jason,
    Great article

    Do you happen to know if its possible to specify a program to launch on a particular fake xinerama display?

    Thanks
    Jon

  15. Hey Jon, If the program takes a -display parameter or respects the $DISPLAY environment variable, then you can open a new X program on your fake Xinerama display that way.

  16. Jason,

    Cheers for the reply,

    Do you mean in respect of DISPLAY=”0.1″ for example?

    I have a strange question, I’m trying to get this set up on one physical monitor in portrait mode (2x 960×1080). I’ve got it working in fedora core 16. I’m not using xephyr as this needs to be permanently this way. Problem is, when set up landscape everything works great and windows will maximize and fullscreen to a particular fake display. In portrait however, windows in the lower fake screen still maximize in the top half.

    To be honest this doesnt bother me if i can launch a program to a particular screen. Basically what i need is virtualbox running fullscreen in the top half and a kiosk locked down browser running fullscreen in the second half, no window decorations at all.

    Thanks so much for your help, excellent website.

    Jon

Leave a Reply

Required fields are marked *.