Ubuntu – Multi-monitor setup with xrandr


Up to now, I have been using my laptop screen (3840×2160) alone, and I'm now trying to set up a secondary monitor (1920×1080). Since my primary monitor is double the resolution of my secondary, this has proven quite awkward to configure how I want it. Initially, when I connected the second monitor, my laptop was reduced to 1920×1080, and my scaling to 100%. This leads to problems for two reasons:

  • I want to retain the 3840×2160 my laptop monitor supports
  • My application scaling was set to 200% as otherwise, many applications don't look good on the 4K monitor

Setting the monitor back to 3840×2160 creates another problem: with the laptop monitor being double the size of the secondary one, the cursor only transitions from the laptop to the external monitor if it moves through the top half of the right side of my screen. The cursor cannot move through the bottom half.

Additionally, if I set the scaling back to 200%, the applications which are scaling to display well on the 4K monitor look bad on the FHD monitor.

In an attempt to resolve the problem, I've been looking at this answer: Is it possible to have different DPI configurations for two different screens?
. Following its instructions whilst adjusting for my monitors, I found that whilst the second monitor did display as I hoped, I could not move my cursor outside of its first quadrant. These are the commands I executed (DP-1 is my external monitor, and eDP-1 is my laptop one):

xrandr --output DP-1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output eDP-1 --scale 1x1 --pos 0x0

After running various other commands in an attempt to achieve what I'm after, I managed to get it working – though not in such a way that it's clear to see which of my steps did the job. I essentially ran xrandr with various options I was testing until it worked. I've restarted my system since, and I've recorded one set of commands that sets the monitor configuration to how I want it, listed below (note that after restart the dash was no longer in my output names).

xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output DP1 --panning 3840x2160
xrandr --output DP1 --panning 1920x1080
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  7 (RRSetScreenSize)
  Serial number of failed request:  40
  Current serial number in output stream:  41
xrandr --output DP1 --scale 1x1
xrandr --output DP1 --scale 2x2
xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output DP1 --panning 1920x1080
xrandr --output DP1 --scale 2x2 --mode 1920x1080 --fb 7680x2160 --pos 3840x0
xrandr --output eDP1 --scale 1x1 --pos 0x0
xrandr --output DP1 --pos 3840x0
xrandr --output eDP1 --pos 0x0

In an attempt to figure out which steps are necessary and which aren't, I've tried omitting commands I didn't think were responsible when configuring the setup. The problem is, messing it up can cause my displays to get in a pseudo-frozen state, where I can move my mouse but none of the other graphical elements will move – I have to restart when experiencing this.

Initially, when the system boots, my external monitor's application content (including the cursor) appears quite zoomed in. I run the commands in the order that they are listed, and on the penultimate step the graphics freeze like I described in the last section – though continuing to type in the final command despite this causes the system to return to normal, and to be configured how I hoped.

Note that the "X Error of failed request" message doesn't seem to be tied to the panning command directly – in one test where I omitted this line, the message appeared instead for the line that took its place (the scale line).

What's the best way for me to resolve my problem directly, rather than running the series of commands that (somehow) work for me currently?

EDIT: These commands aren't absolute either – they seem to be only guaranteed to work relative to the default configuration of xrandr. If I mess with xrandr before running these, it may not work.

EDIT2: I also saw this, which sounds like what I'm facing, but it is apparently fixed (I'm running version 1.5).

Best Answer

  • Today (2019-02-15) saw a new point release of 18.04, 18.04.02. It includes a new Xserver which fixes the problem of the mouse being constrained to a quarter of the external monitor screen. I have spent days trying to find a workaround, and ot now works as you expect! :-)

    But if you are on 18.04 LTS you won't get the fix through the update system! You need to install the new kernel and hardware drivers, which also includes the new xserver, with sudo apt-get install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04 (thanks omgubuntu.co.uk for pointing out that you don't get the update automagically).

    As an update to my script posted above, the magic line for putting the external monitor on the right, now working without mouse constraint, is: xrandr --output DP-1 --auto --scale 2x2 --pos 3840x0 --fb 6000x3840 --right-of eDP-1 --rotate left --output eDP-1 --auto --scale 1x1 --pos 0x0 --primary

    I have found that if I have been playing with --panning (which cancels the 2x2 scaling in my experience), a new xrandr command does not cancel the panning: I have to reboot.