If you have a touchscreen device running Ubuntu, Linux Mint, or another Linux distribution with an external monitor setup, you likely have encountered a bug in which the pointer does not go right where you touched. It turns out that by default, it offsets to the relative position on the combined screens rather than to the position on the touch screen, a pointless and disorienting problem. It will do this horizontally for horizontal layouts as shown above, or vertically for vertical layouts. Fortunately, this problem is easy to solve with some very simple commands in the Terminal.
First enter xrandr --query
to get a list of displays that are connected. If the device is a touchscreen laptop or tablet, the touchscreen is usually the first one, and it will have “primary
” near its name. In the following example, the touch display is identified in blue as eDP-1
.

Now, we need the name of the touchscreen input. Type in xinput list
, and look for an entry called "Finger Touch."
Remember the id number, where it says id=##
. In this example, the id is 12, as circled in yellow. Be careful NOT to use “Touchpad
,” this will not work.

Finally, enter in xinput map-to-output <id> <display_name>
<id>
is the number from xinput list.
<display_name>
is the name from xrandr --query.
The colors are consistent across the example code; yours will look similar but likely be a different number or letter sequence.
Now the touchscreen should map correctly to where you touch it.
This process must be repeated after the monitors are connected or disconnected, and after each reboot. The display name of your touchscreen in the first step does not change. However, the device id number is often different each time. I memorized my display name, then just do the last two steps every time.