Multi-monitor on Linux

UPDD has comprehensive support for a wide range of multi-monitor configurations in Linux. In many cases however some manual setup is required, due to variations in the implementation of various components in Linux and supporting software. This document explains the relevant UPDD and system terminology and gives a workable approach to identifying the required configuration, for the uinput and the X interface. It applies to UPDD 6 and UPDD 7; where they differ this is noted.

You will need to use the upddutils command line interface throughout. For clarity the bare commands are listed here, omitting the path and environment setup: e.g. you might use the actual command ./upddenv ./upddutils monitors where this document refers to just upddutils monitors.

Note

In multi-monitor systems the driver automatically tracks the monitor metrics and this data is used to direct the point of touch to the correct position within the monitor metrics. Nevertheless there are some situations where monitor metric layouts need to be defined manually. See Monitors: identify, bind, metrics and segments to understand monitor metrics in greater detail.

Terminology

TermMeaning
Monitor metricsThe settings UPDD uses internally to identify the placement of monitors used with touch. Usually this refers to the global setting monitorsetupmetrics.
Physical monitorThe actual display hardware.
Logical monitorA conceptual device. You might for example have two physical monitors but in some cases the operating system will report just one monitor, which it "sees" as a concatenation of the two.

In the example below we have a system with four monitors each 1920x1080 arranged as shown here.

But the operating system reports it as a single 3840x2160 device:

Kernel interfaceThe interface used to deliver touches to the operating system. UPDD uses two methods: uinput, a user mode virtual input device, shown as Touch in the UPDD Console; and the X interface (xtouch), which uses APIs provided by X, shown as Mouse. How to select one is described in Selecting the interface.
Co-ordinate rangeThe range of x/y co-ordinates used in any given context. In the four monitor example above the logical monitor has a co-ordinate range of 0,0 to 3839,2159 and monitor 2 has a co-ordinate range of 1920,0 to 3839,1079. For any given physical monitor there can be different co-ordinate ranges depending on the context, e.g. the calibration program, the X interface and uinput might each have a different co-ordinate range.
SegmentsA segment is a UPDD artefact that describes the relationship between a physical monitor and its related area of the associated logical monitor. In the four monitor example above logical monitor 1 is divided into 4 segments, so UPDD would refer to these as monitor 1 segment 1 to monitor 1 segment 4.
X server, display, screenX provides a further level of abstraction by way of the DISPLAY environment variable, which can be set to identify a logical display using the server and screen numbers as described in the X documentation at https://www.x.org/archive/X11R6.8.1/doc/X.7.html. For example DISPLAY=:1.3 references screen 3 on X server 1.

How UPDD 7 maps uinput touch to monitors

UPDD 7 creates one uinput touch device for each monitor (see Virtual devices in UPDD 7) and posts touch co-ordinates relative to that monitor. Which part of the desktop each device covers is decided by the X server, through each device's Coordinate Transformation Matrix. UPDD Daemon sets each UPDD device's matrix to its own monitor's area, taken from the same monitor metrics the driver uses, and checks it again at login and whenever the display layout changes, because some desktops (GNOME, for example) apply their own mapping, which would otherwise place every touch screen on the primary monitor.

UPDD Daemon must be running for this. It does nothing on a Wayland session (which has no per-device matrix) or where the X libraries libX11 and libXi are not present; in these cases it writes a LinuxTouchMap: message to the log saying why. When it maps a device it logs LinuxTouchMap: mapped '<device>' to monitor N.

For a straightforward layout, where each touch screen is its own monitor on DISPLAY :0, this means no uinput specific setup is needed: run the identify and calibrate steps.

A step-by-step guide

This section gives a series of steps to set up a single device in a multi-monitor system, which you can then repeat for each device. As every environment is different this is not an exact guide; you will need to use the information presented here to determine how to satisfy each step.

Note

The intention of this guide is to get a single device working correctly in a multi-monitor / multi-touch environment and then extend the configuration to add support one device at a time. You should follow the steps in the order shown.

Steps

It is assumed that you have a system with all UPDD devices listed as OK as shown below and that this is a fresh install (no settings changed).

  1. Identify the device to work with. We suggest starting with the lowest numbered device in the device list, in the example above device 1. You need to determine which touch device is device 1. To do this start the calibration program for device 1:

    At this stage we are not concerned with where the calibration screen appears or touches are delivered; we are simply determining which touch device is device 1. Touch each physical monitor in turn. Only one will react. This is device 1.
  2. Get the calibration screen placed correctly. If the calibration screen appeared on the correct physical monitor in step 1 then you can skip this step. You will normally need to change the monitor number, e.g.

    In some cases you might need to set the DISPLAY variable before running calibrate. If you have monitors associated with different X displays, screens or servers then this might be the case. Example:

    Note that the syntax to set the DISPLAY environment variable might be different depending on which shell you use. You may need to experiment to find the correct combination of settings and run the command:

    after each attempt. The aim of this step is to get the white background of the calibration screen to appear wholly but not necessarily exclusively on device 1 as identified in step 1. We are not concerned with the placement of the crosses at this stage.
  3. Set up segmentation if required. If you do not have a 1:1 relationship between physical and logical monitors, i.e. the command

    shows fewer monitors than you have physical monitors, then you will need to set up segmentation. If segmentation is not needed go to step 4. Referring to our earlier four monitor example:

    Let's assume that device 1 is in fact the top right monitor. We have only one logical monitor, so segmentation is required:

    As this is a simple symmetrical 2x2 arrangement we set this with the global (nodevice) setting:

    then set the segment for the device with:
  4. Calibrate. Again use the command:

    If all is well you should see the calibration targets appear in turn as each is touched at the expected locations (10% in from each corner by default).
  5. Direct touches to the correct monitor. Touch device 1 and observe where the touch occurs. If it occurs in the correct location on the correct monitor, then you are all set. If not, there are several options available; the most appropriate one for your environment will have to be chosen by experiment. In this simple 2 monitor system we have determined that device 1 is the right-hand monitor and that has been assigned to monitor 2, but touches appear on the left monitor. For simplicity, this example assumes no segmentation:

    We can't simply change the monitor number setting as this will affect calibration. Instead we can set touch.metrics.N.l, .t, .r and .b to override the calculated monitor metrics for touch only (not calibration) on a per monitor basis, as in this example:

    This sets the left, top, right and bottom co-ordinates for monitor 2 as shown. Note we are working with monitor 2, which is associated with device 1. The values to use need to be determined on a per case basis. In this example the touch co-ordinate ranges appear to be swapped so we use the values that would have been defaulted for the left monitor.
    If using the X interface it might be necessary to adjust the mapping between UPDD monitor and X display, as described in Configuration using the X interface. For example:

    It's important to use plain/straight quotes and not smart quotes:

    This tells the driver to use DISPLAY :0 for monitor 2. A driver restart is required to make this setting change effective.

Monitor segmentation

Use the command upddutils monitors to list the monitors as seen by UPDD.

Example 1: each physical monitor is listed

In this example the system has two monitors connected and these are reported as separate monitors:

If both these monitors are associated with DISPLAY :0 then it is likely that no special setup is required.

Example 2: the number of monitors listed does not match the number physically connected

In some cases a listed monitor describes the co-ordinate range of a number of physical screens. This would be the case for example if a hardware based video splitter is used; the xorg configuration or other third party software can also give rise to such a configuration. UPDD refers to this as monitor segmentation. In this example two monitors are connected, each with resolution 640 x 480, but only one monitor is reported:

We describe this as a system having 1 logical monitor but 2 physical screens. From the example above it can be seen that the system sees this as a single co-ordinate system with the second monitor having the co-ordinate range 640,0 to 1279,478. You will need to refer to your system hardware or software configuration to determine the segmentation arrangement of each monitor. Once this is known, inform the driver of the arrangement with the monitor_segment_map setting. For the example above:

More complex arrangements are of course possible, with different stacking, e.g. vertical, multiple rows etc and differing screen resolutions. The use of monitor_segment_map is explained in more detail in Monitors: identify, bind, metrics and segments.

What this does: setting monitor_segment_map sets the co-ordinate range used in user mode. This is in turn used by the calibration utility to determine where to place calibration screens and targets during the calibration and identify processes. It also defines the segmentation used by the driver when reporting touch events to a monitor.

Identify and calibrate

To identify the screens run the command:

UPDD\ Calibrate identify

If you have configured the monitor segmentation correctly then you should see the identify window (a screen with a single cross at the horizontal centre) on each physical screen, including non-touch screens. If not, recheck the settings. This is described in more detail in Monitors: identify, bind, metrics and segments.

Follow the prompts. At the end of this process a further 4 point calibration screen may be shown (if the previous phase determined that touches were inaccurate). If not, but calibration is inaccurate, you may calibrate explicitly.

Note

Identify is not available when multiple X screens or servers are used, i.e. it can only be used when all displays are on DISPLAY :0. For other scenarios use the manual identification described in Configuration using the X interface.

Configuration using the X interface

This section is aimed at systems using the X interface.

Set X display information

X identifies displays using the DISPLAY environment variable. When using the X interface, each monitor listed by upddutils monitors must be associated with the corresponding X display and screen, with the global setting linux_display.N (N is the UPDD monitor number). If no linux_display setting is defined at all, UPDD uses screen :0.0 for monitor 1, :0.1 for monitor 2 and so on. As soon as one linux_display setting is defined, only the monitors that have one are used, so define one for every monitor. This is illustrated in the example below:

upddutils monitors

UPDD monitor layout information
  found 3 monitors
  primary monitor is 1
   Monitor 1:
     Left: 0
     Top: 0
     Right: 1919
     Bottom: 1199
   Monitor 2:
     Left: 0
     Top: 0
     Right: 1919
     Bottom: 1199
   Monitor 3:
     Left: 1920
     Top: 0
     Right: 3839
     Bottom: 1199

In the configuration above

monitor 1 is DISPLAY :0
monitor 2 is DISPLAY :0.1 (left)
monitor 3 is DISPLAY :0.1 (right)

You will need to derive this information from your system configuration.

upddutils nodevice set linux_display.1 :0
upddutils nodevice set linux_display.2 :0.1
upddutils nodevice set linux_display.3 :0.1

A driver restart is required after changing these settings.

Notes

  1. For monitor 1 it would be expected that ":0.0" would work, but we have found that in practice this sometimes does not and ":0" must be used.
  2. As can be seen above, in this example monitors 2 and 3 represent different parts of the same screen. This step only identifies the screen. The segment is identified by the monitor segment map.

Calibrating a multi X screen configuration

In a multi X screen or multi X server configuration you must set the DISPLAY variable manually before calibrating each device. Using the 3 screen example above, and assuming that UPDD device 1 = left, 2 = middle and 3 = right:

export DISPLAY=:0
UPDD\ Calibrate device=1
export DISPLAY=:0.1
UPDD\ Calibrate device=2
UPDD\ Calibrate device=3

Identifying monitors in a multi X screen configuration

As the automated identify relies on putting up dialogs on each screen in turn, which in a multi X screen configuration involves associating the process with different displays, this is not supported. In such a scenario you will need to associate each touch device with a monitor manually. The easiest way to do this is as follows:

  1. Unplug all but one touch device (the touch device, usually USB, and not the video device).
  2. Use the command upddutils devices:

    This will show one device with the status OK, others NOK. Note the handle of the OK device. In the example above this is 1.
  3. Issue the following commands, one at a time, until touches appear on the correct monitor when touching the connected device:
    upddutils device 1 set monitor_number 1
    upddutils device 1 set monitor_number 2
    upddutils device 1 set monitor_number 3
  4. Plug in the second device, note the newly OK device handle and repeat the above. Repeat for all devices.

A practical example

In this example we have 3 touch devices and 3 screens; the left is DISPLAY :0. The other 2 are both DISPLAY :0.1, with the left half of DISPLAY :0.1 corresponding to the middle screen and the right half to the rightmost screen. We assume for simplicity that UPDD devices 1, 2 and 3 relate to the left, middle and right screens.

Set all devices to use the X interface

UPDD 7:
upddutils device 1 set active_pointer_interface mouse
upddutils device 2 set active_pointer_interface mouse
upddutils device 3 set active_pointer_interface mouse

UPDD 6:
upddutils device 1 set active_touch_interface xtouch
upddutils device 2 set active_touch_interface xtouch
upddutils device 3 set active_touch_interface xtouch

Associate the UPDD monitor numbers with the X displays

upddutils nodevice set linux_display.1 :0
upddutils nodevice set linux_display.2 :0.1

The above means that UPDD monitor 1 is DISPLAY :0 and UPDD monitor 2 is DISPLAY :0.1.

Now set the UPDD monitors

upddutils device 1 set monitor_number 1
upddutils device 2 set monitor_number 2
upddutils device 3 set monitor_number 2

The above associates device 1 with DISPLAY :0 and devices 2 and 3 with DISPLAY :0.1.

Now define UPDD monitor 2 as segmented

upddutils nodevice set monitor_segment_map.2 2x1

Direct device 2 to use the left half

upddutils device 2 set monitor_segment 1

Direct device 3 to use the right half

upddutils device 3 set monitor_segment 2

Restart the driver, then calibrate the screens:

export DISPLAY=:0
UPDD\ Calibrate device=1
export DISPLAY=:0.1
UPDD\ Calibrate device=2
UPDD\ Calibrate device=3

Calibration issues

To calibrate a touch screen a number of crosses are displayed on the desktop that are touched as they appear. For cosmetic reasons only, these crosses are normally shown on a white background that covers the full screen. There are 2 scenarios whereby the crosses may be displaced, leading to offset calibration.

Desktop geometry

The calibration program can determine the geometry from the screen metrics or from the available area. Two global settings are used, taking the value screen or available:

SettingDescription
calibration.force_geometryBy default UPDD uses the available geometry to determine the placement of the calibration window (the screen geometry minus menu bar and similar areas). This setting allows the non-default option screen to be used.
segmentation.force_geometryControls the placement of a segment within the window (1x1 is treated as a single segment for consistency of processing). If not set, the value of calibration.force_geometry is used for both the window and the segment placement.

If calibration placements are offset try the screen option using the command upddutils nodevice set calibration.force_geometry screen

Full screen issues

Full screen is not always possible to achieve in Linux: full screen mode via the window manager can be inconsistent under X and there appears to be no sure fire way to implement a foolproof solution. When requesting full screen via the window manager with some Linux distributions, virtualised environments or certain visual effect settings, the method used by our calibration program to force full screen can give unpredictable results. In cases where the calibration background fails to display in full screen we offset the calibration crosses so that calibration is unaffected. To date we have seen this with VMware virtualisation, the Maemo distribution and main stream distributions with certain visual effects enabled.

On systems where the full screen issue occurs you may be able to reconfigure the system to allow full screen, or use a corner calibration, as described below.

Configure the system to allow full screen

If a window manager is preventing full screen mode try running without the window manager active (this has been necessary on systems using the TWM window manager).

Where visual effects are preventing full screen, temporarily disable the effect. We have had reports that on some Ubuntu systems the calibration screen is windowed (having a title bar) instead of taking up the entire desktop. This is due to the desktop effects interfering with the window manager. If this is experienced, open the Appearance application and navigate to the Visual Effects tab:

If Normal or Extra is selected then select None and calibrate the touch screen. When calibration is complete, select the visual effect that was in use before and click Close.

Here the auto-launcher is preventing the calibration screen covering the left-most side of the screen. This can be hidden to allow for calibration:

Full screen not possible

In cases where full screen is not possible, leading to incorrect calibration, you can achieve accurate calibration as follows:

  1. Set 4 point calibration with 0% margin and, when asked to touch the calibration point, touch in the corner of the touch screen.
  2. Use the basic 2 point corner calibration of the command line interface.

For review

  • Automatic configuration using uinput (50512) is not carried over. Its key step, upddutils nodevice set uinput.autoconfigure 1 (screenshot MMLinuxAutoConf.png), names a setting that neither the 7.1 nor the 6.0 source reads (no occurrence in C:\devl\07_01 or C:\devl\06_00). In 7.1 the per-monitor mapping is done by UPDD Daemon (daemon/linuxtouchmap.h, linuxtouchmap.cpp; updd/linux/osconnectorlinux.cpp:59-66), which the new "How UPDD 7 maps uinput touch to monitors" section describes. If UPDD 6 builds before the 2021 repository take-on read it, a UPDD 6 note may be wanted.
  • linux_display defaults corrected. 50769 said monitor 2 defaults to DISPLAY :1; the code maps monitor N to :0.(N-1) when no linux_display setting exists, and maps only the monitors that have a setting once any exists (7.1 osconnectorlinux.cpp:488-517; same in 6.0 updd/unix/xtouch.cpp:65-90). This contradicts 50496's "it is not necessary to set the value for monitor 1", so that note was replaced. linux_display is read only by the X interface code; 50512's instruction to set it for uinput is dropped. Please confirm with a test.
  • touch.metrics.N.l/.t/.r/.b confirmed in updd/connection.cpp:846-866 (N = monitor number).
  • Screenshots dropped: Linuxmm3/4/5/6.png (V6 Console "Touch interface" label and active_touch_interface values; 7.1 labels it "Pointer interface"), the duplicate segmentation shots of 50496/50512 (LinuxMMMonList, LinuxMMMon1V2P(Map), MMLinux2P1L, MMLinuxSeg, MMLinuxDisplay, MMLinuxAutoConf). The remaining Linuxmm screenshots are UPDD 6 era terminal shots.
  • Version notes dropped: "prior to UPDD version 379", "6.0.379", segmentation.force_geometry before/after 6.0.655.