Linux 1050ti monitor layout screwed up on DisplayPort disconnect/reconnect

Lets start with the good news, this works when I log in. My xorg.conf seems to configure the X Server, Displays, Devices, Layouts and Monitors just fine (at first). I am currently running one DisplayPort Monitor and one DVI monitor. When I power the monitors off and then back on the layout gets screwed up. The position of the displays are normally side-by-side, but after power-off/power-on they are over the top of one another.

When X starts I have the
DisplayPort monitor on the left (1920x1080 @ 144) (position 0,0) and the
DVI monitor is to the right of it (1600x1024 @ 60) (position +1920,0)

So there is a 3520 x 1080 Virtual panel with the DisplayPort on the left and the DVI on the right.

When I power off the DisplayPort monitor, everything is fine. No changes are made. I still have a virtual buffer that is bigger than the screens I am looking at, which is now just a single 1600x1024. But I expect that, and I want that. I am not moving monitors around all the time, I just like to shut them off to save power.

When I then power the DisplayPort monitor back on, the other monitor immediately stops displaying, and after a second or two, they both come back on but they are drawing the same space. They are both drawing the position 0,0 but with slightly different resolutions (1920x1080 vs 1600x1024).

I can run an xrandr script to fix it but I would prefer to not have to do that. I have made tons of changes to the xorg.conf file to no avail. What am I missing?

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 418.74

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "Monitor"
    Identifier     "DVI-D-0"
    VendorName     "SGI"
    ModelName      "1600SW"
    Option	   "DPMS"
    #Option	   "PreferredMode" "1600x1024_60"
    #Option         "Primary" "true"
    #Option         "RightOf" "DP-0"
    #Option         "Position" "1920 0"
EndSection

Section "Monitor"
    Identifier     "DP-0"
    VendorName     "BenQ"
    ModelName      "BenQ ZOWIE XL LCD"
    Option         "DPMS"
    #Option	   "PreferredMode" "1920x1080_144"
    Option	   "LeftOf" "DVI-D-0"
    Option         "Position" "0 0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1050 Ti"
    Option         "MetaModes" "DVI-D-0: 1600x1024 +1920+0, DP-0: 1920x1080 +0+0; DVI-D-0: 1600x1024 +1920+0, DP-1: 1920x1080 +0+0"
    Option         "VertRefresh" "DVI-D-0:60; DP-0:144; DP-1:144"
    Option         "UseHotplugEvents" "true"
    Option         "AllowEmptyInitialConfiguration" "true"
    Option         "SLI" "false"
    Option         "MultiGPU" "false"
    Option         "HardDPMS" "true"
    Option         "ConnectToAcpid" "true"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "DVI-D-0"
    DefaultDepth    24
    Option         "Stereo" "0"
    SubSection     "Display"
        Depth       24
	Virtual     3520 1080 # 1920 + 1600 = 3520 //  MAX(1080, 1024) = 1080 
    EndSubSection
EndSection

What desktop environment are you using? It sounds like it’s responding to monitor hotplug events by rearranging the monitor layout based on what it thinks the correct layout should be. If your environment provides a control panel for configuring the display layout, you might try setting it up the way you want it there.

I am running Debian Buster with xfce. This is what the Xorg.0.log shows on poweron:

Imediately after poweron:

[352705.918] (--) NVIDIA(GPU-0): 
[352705.949] (II) NVIDIA(0): Setting mode "DVI-D-0: nvidia-auto-select @1600x1024 +0+0 {ViewPortIn=1600x1024, ViewPortOut=1600x1024+0+0}, DP-0: nvidia-auto-select @1920x1080 +0+0 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0}"
[352706.047] (--) NVIDIA(GPU-0): UFC (DFP-0): connected
[352706.048] (--) NVIDIA(GPU-0): UFC (DFP-0): Internal TMDS
[352706.048] (--) NVIDIA(GPU-0): UFC (DFP-0): 330.0 MHz maximum pixel clock
[352706.048] (--) NVIDIA(GPU-0): 
[352706.048] (--) NVIDIA(GPU-0): DFP-1: disconnected
[352706.048] (--) NVIDIA(GPU-0): DFP-1: Internal TMDS
[352706.048] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock
[352706.048] (--) NVIDIA(GPU-0): 
[352706.048] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): connected
[352706.048] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): Internal DisplayPort
[352706.048] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): 1440.0 MHz maximum pixel clock
[352706.049] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): supports NVIDIA 3D Vision stereo.
[352706.049] (--) NVIDIA(GPU-0): 
[352706.050] (--) NVIDIA(GPU-0): DFP-3: disconnected
[352706.050] (--) NVIDIA(GPU-0): DFP-3: Internal TMDS
[352706.050] (--) NVIDIA(GPU-0): DFP-3: 165.0 MHz maximum pixel clock
[352706.050] (--) NVIDIA(GPU-0): 
[352706.066] (--) NVIDIA(GPU-0): UFC (DFP-0): connected
[352706.066] (--) NVIDIA(GPU-0): UFC (DFP-0): Internal TMDS
[352706.066] (--) NVIDIA(GPU-0): UFC (DFP-0): 330.0 MHz maximum pixel clock
[352706.066] (--) NVIDIA(GPU-0): 
[352706.067] (--) NVIDIA(GPU-0): DFP-1: disconnected
[352706.067] (--) NVIDIA(GPU-0): DFP-1: Internal TMDS
[352706.067] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock
[352706.067] (--) NVIDIA(GPU-0): 
[352706.067] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): connected
[352706.067] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): Internal DisplayPort
[352706.067] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): 1440.0 MHz maximum pixel clock
[352706.067] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): supports NVIDIA 3D Vision stereo.
[352706.067] (--) NVIDIA(GPU-0): 
[352706.071] (--) NVIDIA(GPU-0): DFP-3: disconnected
[352706.071] (--) NVIDIA(GPU-0): DFP-3: Internal TMDS
[352706.071] (--) NVIDIA(GPU-0): DFP-3: 165.0 MHz maximum pixel clock
[352706.071] (--) NVIDIA(GPU-0): 

Then I run my xrandr script:

[352725.886] (II) NVIDIA(0): Setting mode "DVI-D-0: nvidia-auto-select @1600x1024 +1920+0 {ViewPortIn=1600x1024, ViewPortOut=1600x1024+0+0}, DP-0: nvidia-auto-select @1920x1080 +0+0 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0}"
[352726.011] (--) NVIDIA(GPU-0): UFC (DFP-0): connected
[352726.011] (--) NVIDIA(GPU-0): UFC (DFP-0): Internal TMDS
[352726.011] (--) NVIDIA(GPU-0): UFC (DFP-0): 330.0 MHz maximum pixel clock
[352726.011] (--) NVIDIA(GPU-0): 
[352726.011] (--) NVIDIA(GPU-0): DFP-1: disconnected
[352726.011] (--) NVIDIA(GPU-0): DFP-1: Internal TMDS
[352726.011] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock
[352726.011] (--) NVIDIA(GPU-0): 
[352726.012] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): connected
[352726.012] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): Internal DisplayPort
[352726.012] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): 1440.0 MHz maximum pixel clock
[352726.012] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): supports NVIDIA 3D Vision stereo.
[352726.012] (--) NVIDIA(GPU-0): 
[352726.013] (--) NVIDIA(GPU-0): DFP-3: disconnected
[352726.013] (--) NVIDIA(GPU-0): DFP-3: Internal TMDS
[352726.013] (--) NVIDIA(GPU-0): DFP-3: 165.0 MHz maximum pixel clock
[352726.013] (--) NVIDIA(GPU-0): 
[352726.032] (--) NVIDIA(GPU-0): UFC (DFP-0): connected
[352726.032] (--) NVIDIA(GPU-0): UFC (DFP-0): Internal TMDS
[352726.032] (--) NVIDIA(GPU-0): UFC (DFP-0): 330.0 MHz maximum pixel clock
[352726.032] (--) NVIDIA(GPU-0): 
[352726.032] (--) NVIDIA(GPU-0): DFP-1: disconnected
[352726.032] (--) NVIDIA(GPU-0): DFP-1: Internal TMDS
[352726.032] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock
[352726.032] (--) NVIDIA(GPU-0): 
[352726.033] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): connected
[352726.033] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): Internal DisplayPort
[352726.033] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): 1440.0 MHz maximum pixel clock
[352726.033] (--) NVIDIA(GPU-0): BenQ ZOWIE XL LCD (DFP-2): supports NVIDIA 3D Vision stereo.
[352726.033] (--) NVIDIA(GPU-0): 
[352726.034] (--) NVIDIA(GPU-0): DFP-3: disconnected
[352726.034] (--) NVIDIA(GPU-0): DFP-3: Internal TMDS
[352726.034] (--) NVIDIA(GPU-0): DFP-3: 165.0 MHz maximum pixel clock
[352726.034] (--) NVIDIA(GPU-0):

And to better answer your question, there is a “Display” settings widget, but it is set to “Configure new displays when connected” == OFF.
Screenshot_2020-03-27_14-00-39

When you say “poweron” you mean when you power on the monitor, right?

The Setting mode message in the log indicates that some X client requested a mode change. So it seems like either the “Configure new displays when connected” checkbox isn’t actually working, or some other component of your desktop environment is responding to hotplugs.

After the X server has finished initializing, the driver does not do mode switches on its own.

Yes, “poweron” means to turn on the DisplayPort monitor. I am using the power button. The light is off, then I press the power button and the light goes orange until the display is configured, then it goes green. So I assume thisis a physical poweron.

Okay, I’ll keep looking into it. I have tried to set up a UDEV rule to catch it and that isn’t working either. It runs the UDEV script just fine, but it does not correct the displays. If I run the script a moment later by hand it does correct the displays.

Okay, I think I am closing in on the problem. I now believe that the problem lies in the xfce4-settingsd. Here are the relevant lines from my debugging session.

(started xfsettingsd like this) user:~$ XFSETTINGSD_DEBUG=1 xfsettingsd --replace --no-daemon

removed (what I believe to be) irrelevant lines: Note the Position 0x0 for both CRTC.

xfce4-settings(xsettings): _XSETTINGS_S0 registered on screen 0
xfce4-settings(xsettings): 28 settings changed (serial=0, len=1100)
xfce4-settings(xsettings): resource manager (xft) changed (len=158)
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): CRTC 442 assigned to DVI-D-0.
xfce4-settings(displays): CRTC 442, output list[0] -> 446.
xfce4-settings(displays): CRTC 443 assigned to DP-0.
xfce4-settings(displays): CRTC 443, output list[0] -> 450.
xfce4-settings(displays): Total 2 active output(s).
xfce4-settings(displays): Normalized CRTC 442: size=1600x1024, pos=0x0.
xfce4-settings(displays): Normalized CRTC 443: size=1920x1080, pos=0x0.
xfce4-settings(displays): CRTC 442 must be temporarily disabled.
xfce4-settings(displays): Disabling CRTC 442.
xfce4-settings(displays): min_h = 8, min_w = 8, max_h = 32767, max_w = 32767, prev_h = 1080, prev_w = 3520, prev_hmm = 286, prev_wmm = 932, h = 
1080, w = 1920, hmm = 286, wmm = 508.
xfce4-settings(displays): Applying desktop dimensions: 1920x1080 (px), 508x286 (mm).
xfce4-settings(displays): Configuring CRTC 442.
xfce4-settings(displays): Applying changes to CRTC 442.
xfce4-settings(displays): Configuring CRTC 443.
xfce4-settings(displays): Configuring CRTC 444.
xfce4-settings(displays): Configuring CRTC 445.
xfce4-settings(displays): RRScreenChangeNotify event received.
xfce4-settings(displays): Refreshing RandR cache.
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): Noutput: before = 2, after = 2.
xfce4-settings(displays): RRScreenChangeNotify event received.
xfce4-settings(displays): Refreshing RandR cache.
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): Noutput: before = 2, after = 2.
xfce4-settings(displays): RRScreenChangeNotify event received.
xfce4-settings(displays): Refreshing RandR cache.
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): Noutput: before = 2, after = 2.
xfce4-settings(displays): RRScreenChangeNotify event received.
xfce4-settings(displays): Refreshing RandR cache.
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): Noutput: before = 2, after = 2.
xfce4-settings(displays): RRScreenChangeNotify event received.
xfce4-settings(displays): Refreshing RandR cache.
xfce4-settings(displays): Detected CRTC 442.
xfce4-settings(displays): Detected CRTC 443.
xfce4-settings(displays): Detected CRTC 444.
xfce4-settings(displays): Detected CRTC 445.
xfce4-settings(displays): Detected output 446 DVI-D-0.
xfce4-settings(displays): Detected output 450 DP-0.
xfce4-settings(displays): Noutput: before = 2, after = 2.