Ubuntu – Dual screen stretching with nvidia proprietary driver

displaydriversmultiple-monitorsnvidiaxorg

I have a laptop with a nvidia card and an integrated intel card, and a HDMI screen connected to it. I understand PRIME support has been problematic in the past, but the newer nvidia drivers are quite good. I'm using driver version 375.66.

I can use either screens fine, or both with mirroring, but trying to use both as independent screens results in this strange stretching:

enter image description here

Both screens are 1920×1080. As can be seen in the screenshot, some GUI elements (e.g. unity-panel) are scaled correctly to a single screen, while most others (e.g. windows) are stretched through both screens. Interestingly, nvidia's applet does not detect both monitors, while ubuntu's display applet does, as can be seen in the screenshot.

This is my xorg.conf (although I'm not sure if the nvidia driver even uses it at all):

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "None"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

What am I missing?

Best Answer

Why don't you try this out -

According to NVIDIA, it's because the built in display is connected to intel iGPU. ( source: https://devtalk.nvidia.com/default/topic/807239/nvidia-server-setting-utility-doesn-t-see-laptop-screen/)

Which basically means that Nvidia x server has no control over your built in display.

To solve this, switch graphic mode from MShybrid to discrete in BIOS setting, which can force the built in monitor to be driven by you discrete GPU, and x server will work correctly to recognize both built in and external display.