Tuesday, 23 February 2016

Ubuntu linux: how to restrict a graphic tablet to only one monitor (in a dual monitor setup ;)

I have 2 monitors that are placed on top of each other, like this:

My graphical tablet (Genius EasyPen i405X) is covering by default the entire (summed-up) area, which means that only about half of the tablet is usable for a MyPaint drawing that is opened only on the Benq monitor.

What I want to do is to restrict the tablet movement only to Benq, ie: tablet's physical margins should correspond to Benq ones.

Let's get the needed parameters. The monitors resolution and offset can be seen by launching xrandr in command line:

The first screen is laptop's one that is inactive. Then, each monitor can be found based on the cable/socket it's on. In my case Benq is on HDMI and AOC is on VGA.

Xrandr displays all possible resolutions for each monitor but we need only the one that is active, marked with * (btw, the "+" means it is the recommended resolution). I have trimmed many of those for brevity and in fact we need only the first line of each, the long one where we have the resolution and also the offset.
As you can see (see also the picture) AOC (on VGA) has a resolution of 2560x1080 and it has offset 0 and 0 (it's top left corner is in the zero of the axis system).
More interesting for me, BenQ has resolution of 1920x1080 and horizontal offset 338, while the vertical one is 1080, i.e. Benq is lower that the 0 axis point with exactly the height of AOC. (There are some distances in reality between monitor margins, but obviously these are not taken into account.)

This will not survive a reboot so you should do something about it if you care. Personally, I have just added the above line in a script that I run each time I use the tablet (which is quite rare in my case).