X11 Xinerama Virtual Displays and OpenNX

The idea: I want to have multiple monitors hooked up to my workstation. I have two 23” monitors for my main workspace, but I’d like to have another monitor over where I solder (for reference, BOM, etc.) and another one or two over in the other area of my office for similar reasons. Multiple monitors on X11 is pretty much a no-brainer these days. The nVidia card I use now has two outputs that drive those 23” monitors and X11 is configured to use TwinView, which is an nVidia-adaptation of Xinerama which is a little smarter when it comes to window placement and is supposedly faster as well. This works great for the two monitors run from one card, but I want to go beyond this.


From Wikipedia : The general mode of operation is that multiple X screens (as denoted normally by .0, .1, etc.) can be unified into a single workspace via enabling Xinerama in the X server. This creates a single unified work area that allows windows to be transferred across X screens.

This is what I’m after. I’d also like to be able to hint somehow that the two 23” are the main display, and the other screens are never targets for new windows unless they are the active screen. Xinerama-aware window managers (pretty much anything these days) can do this.

Window Placement Managers

There is also xpra which is kind of like screen for X11, and of course x0vncserver but I’m trying to avoid VNC/RDP.

Virtual Screens

I figured that since X11 supported multiple screens then I should just be able to add a virtual framebuffer or two and that would give me the ability to drag things over to a screen that I could then effectively transport anywhere with NX. Unfortunately the virtual framebuffer is its own X server, not just a driver that I can select. This means I can’t use the normal Xorg server and have two screens with the nv driver, a few screens with various USB video cards or maybe another nVidia card and then some virtual screens with some kind of virtual driver. What I would have ended up with would be two X servers running: one for physical screens and one for virtual ones. (e.g. .0, .1, .2 for real screens and :1.0, :1.1 for virtual ones). It would not have been possible to drag windows around between the servers.

Thankfully there is the dummy video driver. Ubuntu has it in the xserver-xorg-video-dummy package. The dummy driver is exactly what it sounds like; it was developed for testing X changes that didn’t rely on hardware.

Setting up the dummy driver

Section "Monitor" 
        Identifier      "VirtualMonitor0" 
        HorizSync       22-82
        VertRefresh     50-80

Section "Device" 
        Identifier      "VirtualDevice0" 
        Driver          "dummy" 

Section "Screen" 
        Identifier      "VirtualScreen0" 
        Device          "VirtualDevice0" 
        Monitor         "VirtualMonitor0" 
        DefaultDepth    24
        Subsection      "Display" 
                Depth   24
                Modes   "1280x800" 

Then I added another screen to the ServerLayout section:

Section "ServerLayout" 
    Identifier     "Layout0" 
    Screen      0  "Screen0" 0 0
    Screen      1  "VirtualScreen0" LeftOf "Screen0" 
    InputDevice    "Keyboard0" "CoreKeyboard" 
    InputDevice    "Mouse0" "CorePointer" 
    Option         "Xinerama" "0" 

I don’t know yet if I should leave Xinerama off or not; TwinView is being used by the nv driver, and adding a screen seems to bugger up some of its smartness, so maybe Xinerama is automatically getting enabled. I have more testing to do, and the answer is probably staring me in the face in the X logfile.

The only downside I have with this setup is that it is possible to mouse over into the virtual area and “lose” the mouse since it’s not on any screen. Also, NX’s shadow mode seems to assume I want screen 0 (I can’t select the screen to shadow) and if I make the virtual screen screen 0 then lxdm is showing the login on the virtual screen. I’m sure I can tell lxdm to move.

There was a little bit of screwing around needed in order to be able to specify resolutions for the virtual screen. That’s why I specified timing constraints for the virtual monitor. See Ubuntu Headless VNC VESA 800×600 Fix for the nitty gritty details. The config is listed above, so if the blog disappears it’s ok since the important info is here.


NX Supports the idea of shadow sessions; these are sessions which effectively poll the framebuffer for changes, encode them and send them over the existing NX transport. I don’t want to share the entire (4+ screen) desktop, but rather just one of the screens (e.g. .1 or .3 or something). Unfortunately right at this point in time, the OpenNX client does not allow me to select which screen to shadow. It always defaults to the first one. I posted a bug report but it might actually be a feature request.


Can I attach NX to an existing X session?
Implementing Desktop Sharing Functionality in NX
X.Org/Dual Monitors
Switchscreen mouse control


The switchscreen link led me down a bit of a rabbit hole; the jail program mentioned (which looks at the mouse position ever 1msec and moves the mouse back if it moved out of the window it started in) is a 404, but an interesting script using xdotool turned up from this link. The script is copied here for posterity.

jail.sh Magnifier - keeps the mouse within a defined rectangle (1.55 KB) Andrew Kohlsmith, 12/02/2018 08:31 PM

switchscreen-0.4.tar.gz (8.71 KB) Andrew Kohlsmith, 12/02/2018 08:33 PM

dualscreen-mouse-utils-0.5.tar.gz (12.5 KB) Andrew Kohlsmith, 12/02/2018 08:36 PM

Add picture from clipboard (Maximum size: 1 GB)