These instructions are to create an "additional" screen for your linux machine using a tablet or any computer through a VNC client.
I made these steps in Mageia3 32Bit (have not tried 64bit) but should be similar for other distros as well (i.e. Ubuntu).
Make sure you have all the required packages with the following terminal command:
sudo apt-get install gcc autoconf automake x11-font-util libtool libxi-devel ibopenssl-devel libxfont1-devel libpam-devel x11-util-macros x11-xtrans-devel x11-server-xvfb x11-server-xdmx x11-server-devel x11-server-source
Once you have all the above packages, issue these commands:
cd /usr/share/x11-server-sources/
./autogen.sh
./configure --with-fontrootdir=/usr/share/fonts --with-xkb-path=/usr/share/X11/xkb --with-xkb-output=/usr/share/X11/xkb/compiled --enable-dmx
make
If you don't get any errors, patch Xdmx (simply put, it has been "broken" for some time):
open /usr/share/x11-server-sources/hw/dmx/input/dmxevents.c
, and change line 730:
change this:
POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
to this:
POINTER_RELATIVE | POINTER_DESKTOP, &mask);
IF line 730 is different use this section to find correct line:
Orginal section - line to change marked with *
case ButtonPress:
case ButtonRelease:
detail = dmxGetButtonMapping(dmxLocal, detail);
valuator_mask_zero(&mask);
QueuePointerEvents(p, type, detail,
* POINTER_RELATIVE | POINTER_DESKTOP, &mask);
return;
Check your version of Xdmx by running ./configure --version
in /usr/share/x11-server-source/
, for Xdmx 1.13 and older you also have to make these changes (for 1.14 and newer you can skip to the "make" step below):
open /usr/share/x11-server-sources/dix/getevents.c
, line 1395:
change this:
if (flags & POINTER_SCREEN ) { /* valuators are in screen coords */
To this:
if (flags & ( POINTER_SCREEN | POINTER_DESKTOP) ) { /* valuators are in screen coords */
(Original section - line to change marked with *)
/* valuators are in driver-native format (rel or abs) */
if (flags & POINTER_ABSOLUTE) {
* if (flags & POINTER_SCREEN ) { /* valuators are in screen coords */
sx = valuator_mask_get(&mask, 0);
sy = valuator_mask_get(&mask, 1);
open /usr/share/x11-server-sources/Xext/xtest.c
, line 311:
change this:
flags = POINTER_ABSOLUTE | POINTER_SCREEN;
to this:
flags = POINTER_ABSOLUTE | POINTER_DESKTOP;
(original section - line to change marked with *)
case MotionNotify:
dev = PickPointer(client);
valuators[0] = ev->u.keyButtonPointer.rootX;
valuators[1] = ev->u.keyButtonPointer.rootY;
numValuators = 2;
firstValuator = 0;
if (ev->u.u.detail == xFalse)
* flags = POINTER_ABSOLUTE | POINTER_DESKTOP;
break;
/usr/share/x11-server-sources/include/input.h
, line 73:
Add this line after the line starting with #define POINTER_EMULATED
:
#define POINTER_DESKTOP (1 << 7)
After making the above changes, re-execute (in /usr/share/x11-server-sources/
):
make
You should have a new Xdmx file in /usr/share/x11-server-sources/hw/dmx/
. We need to install that globally for ease, so I recommend renaming your existing one:
sudo mv /bin/Xdmx /bin/Xdmx-old
and copy the new one in place of it:
cp /usr/share/x11-server-sources/hw/dmx/Xdmx /bin
Now you're ready to do your first trial, the following commands allow you to keep your main/existing display (:0
) running and open a new display with the multi-monitor support.
I am using icewm with these commands to make it a little more lightweight (I use KDE on my main display :0
and open any large-multi-monitor application in the new multi-head display).
You can most definitely script these commands for ease of use (it's what I did) -- Any of these commands can be executed on console and/or terminal window of any display, the only requirement is that they are executed in order.
This command creates your new display as a frame buffer for your VNC display :2
(adjust screen size as desired):
Xvfb :2 +xinerama -screen 0 1024x1280x24 -ac &
This starts a new lightweight X session on your physical display as display :1
(there are different ways to do this):
startx 'icewm' -- :1
This command starts the multi-display between your physical screen and the virtual screen and starts icewm for window manager:
Xdmx :3 +xinerama -display :1 -display :2 -norender -noglxproxy -ac & DISPLAY=:3 starticewm
Now open a terminal window and start the vnc server (change password as desired):
x11vnc -display :3 -passwd test -clip xinerama1 -noshm -forever -nowireframe &
The only thing left to do now is to fire up your VNC client and connect to your VNC -- you may need to disable or add an exception to your firewall to port 5900 so you can connect to it.
Another thing to keep in mind is that some VNC clients don't display the remote cursor position, I certify that "Mocha VNC" for iOS works great if you turn off the option "local mouse".
Enjoy dragging windows between your main monitor and your new virtual second monitor (while also being able to use the tablet to click/type on things in the second monitor).
To close Xdmx press Ctrl+Alt+Backspace twice.
Automation:
I use this bash script to start the whole process (also kills Xvfb on exit):
Xvfb :2 +xinerama -screen 0 1024x1280x24 -ac &
xinit dual -- :1
ps | grep Xvfb | awk '{print $1}' | xargs kill
Then I have a custom ~/.xinitrc
file with this:
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [[ $1 == "" ]]
then
exec startkde
elif [[ $1 == "xterm" ]]
then
exec xterm
elif [[ $1 == "dual" ]]
then
exec Xdmx :3 +xinerama -display :1 -display :2 -norender -noglxproxy -ac & DISPLAY=:3 starticewm & x11vnc -display :3 -passwd test -clip xinerama1 -noshm -forever -nowireframe
else
exec $1
fi
Troubleshooting:
When running Xdmx if you get an error saying sh: /usr/local/bin/xkbcomp: No such file or directory
you may need to do execute: cd /usr/local/bin" and "ln -s /bin/xkbcomp
, then try Xdmx again.
Ctrl+Alt+F1 through F7 is supposed to work in Xdmx to switch to other consoles/xsessions but for some reason it doesn't work, what I do is simply execute sudo chvt X
(where X is a console/xsession number) to switch to my main display. Also when you switch back to Xdmx you may get some drawing issues on any open windows, I just click on the taskbar to hide/show the window again forcing a redraw.