Windows move to secondary display after waking from power save mode

I have two display setup on my desktop rig. Primary LG 4k and secondary Samsung. When computer wakes up from power save mode, all windows from primary are moved to secondary display. It’s pretty annoying X times a day to move 10+ windows back from secondary to primary display and position it where they belong.

It seems that it takes a split second longer for primary display to turn on than secondary, so I guess that OS thinks primary is disconnected and moves all windows to secondary. This is a new LG display I bought few weeks ago and it’s driving me nuts.

I tried changing DP/HDMI ports for both displays, but it didn’t help.

Any idea how can I fix it? I know I can turn power saving off, but I don’t even consider this option.

Thanks!

eden@sunce:[~]: inxi -GSa
System:
  Host: sunce Kernel: 5.19.1-3-MANJARO arch: x86_64 bits: 64 compiler: gcc
    v: 12.1.1 parameters: BOOT_IMAGE=/boot/vmlinuz-5.19-x86_64
    root=UUID=8e54b3e5-faff-4f7f-bde6-1e055ed78e1c rw quiet apparmor=1
    security=apparmor udev.log_priority=3
  Desktop: KDE Plasma v: 5.24.6 tk: Qt v: 5.15.5 wm: kwin_x11 vt: 1
    dm: SDDM Distro: Manjaro Linux base: Arch Linux
Graphics:
  Device-1: NVIDIA GA104 [GeForce RTX 3060 Ti Lite Hash Rate]
    vendor: Gigabyte driver: nvidia v: 515.65.01 alternate: nouveau,nvidia_drm
    non-free: 515.xx+ status: current (as of 2022-07) arch: Ampere
    code: GAxxx process: TSMC n7 (7nm) built: 2020-22 pcie: gen: 4
    speed: 16 GT/s lanes: 16 bus-ID: 07:00.0 chip-ID: 10de:2489
    class-ID: 0300
  Display: x11 server: X.Org v: 21.1.4 compositor: kwin_x11 driver: X:
    loaded: nvidia gpu: nvidia display-ID: :0 screens: 1
  Screen-1: 0 s-res: 5760x2160 s-dpi: 120 s-size: 1218x457mm (47.95x17.99")
    s-diag: 1301mm (51.22")
  Monitor-1: DP-0 pos: primary,top-left res: 3840x2160 hz: 60 dpi: 140
    size: 697x392mm (27.44x15.43") diag: 800mm (31.48") modes: N/A
  Monitor-2: HDMI-1 pos: bottom-r res: 1920x1200 hz: 60 dpi: 94
    size: 518x324mm (20.39x12.76") diag: 611mm (24.05") modes: N/A
  OpenGL: renderer: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA
    515.65.01 direct render: Yes

3 Likes

From BIOS post to GRUB the dGPU aka PEG aka PCIE will have a order to activate the ports like this
VGA > DVI-I > DVI-D > HDMI > Displayport

So, in your case

that DP is Displayport - will activate after

You could eventually try to create a fixed Layout from Nvidia X Server Settings and append that modified information in /etc/X11/mhwd.d/nvidia.conf and also change the "nvidiaXineramaInfoOrder" port in the Section "Screen", but still not sure that will help very much.
This is how i always set it on my end, maybe the example will help you:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

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

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "LG Electronics"
    ModelName      "LG Electronics W2253"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 960"
    Option         "TripleBuffer"  "On"
    Option  "ConnectToAcpid"    "Off"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-1: 1920x1080_60 +0+0 {ForceCompositionPipeline=On}, DVI-D-0: 1920x1080_60 +1920+0 {ForceCompositionPipeline=On}"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Extensions"
    Option         "COMPOSITE" "Enable"
EndSection

 
Section "InputClass"
    Identifier          "Keyboard Defaults"
    MatchIsKeyboard        "yes"
    Option              "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection
 

Thanks for suggestion. I have actually two configs related to x11:

  • /etc/X11/xorg.conf
  • /etc/X11/mhwd.d/nvidia.conf

Also, I have nvidia-settings utility which is writting config to /etc/X11/xorg.conf. I set config using this utility similar to yours. As far as I understand, manjaro uses the latter config file, so I linked /etc/X11/xorg.conf to /etc/X11/mhwd.d/nvidia.conf.

I’ll see if it will be better with new config.

That needs to be removed.
MHWD creates the default config in /etc/X11/mhwd.d/nvidia.conf as i already mentioned. The only symlink required and present should be /etc/X11/xorg.conf.d/90-mhwd.conf that points to the /etc/X11/mhwd.d/nvidia.conf

Then to make sure things are correct, you run:

sudo mhwd-gpu --setmod nvidia --setxorg /etc/X11/mhwd.d/nvidia.conf
1 Like

Thanks for all the help. I will let you know if it solved the problem.

I also face this problem, would love to see a working solution too.

Related: in the past I faced a similar problem where my entire desktop (panels and backgrounds included) would swap between my two external monitors, but I can’t seem to reproduce that anymore. Unfortunately there was no solution at the time.

Unfortunately, it didn’t help.

Can you share the content of /etc/X11/mhwd.d/nvidia.conf
Also, did you set early KMS ? Skip the first part from here, and just do the /etc/mkinitcpio.conf part

A post was split to a new topic: Windows move to secondary display after waking from power save mode Radeon GPU

OK, moving my topic to an new one was surprising for me. I thing the problem is not graphic card relevant. It looks like a plasma problem for me.
But alright. Your will know more like I.

Please read the Forum Rules - Manjaro

Most likely is a KDE Plasma issue on some systems. Is not happening on mine, dual monitor and Nvidia GPU and KDE Plasma 5.24.6, so, till we can identify the exact issue, is better to keep things separate.

Sorry for late reply.

Maybe is worth mentioning that I had another 4k display (benq) for like year or so instead of this new LG and I had no similar issues with it. As I wrote in my initial post, this is what I think it’s happening:

It seems that it takes a split second longer for primary display to turn on than secondary, so I guess that OS thinks primary is disconnected and moves all windows to secondary.

Here’s my configs:

/etc/X11/mhwd.d/nvidia.conf

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "LG Electronics LG HDR 4K"
    HorizSync       30.0 - 135.0
    VertRefresh     40.0 - 60.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "NVIDIA GeForce RTX 3060 Ti"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-1"
    Option         "metamodes" "DP-0: 3840x2160_60 +0+0 {ForceCompositionPipeline=On}, HDMI-1: 1920x1200_60 +3840+480 {ForceCompositionPipeline=On}"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

/etc/mkinitcpio.conf (I removed all commented lines)

MODULES=""

BINARIES=()

FILES=""

HOOKS="base udev autodetect modconf block keyboard keymap filesystems"

Try DFP-0

Also, you are missing this last lines in your conf

You only need to add to the modules if you enable early KMS, and is already explained

Now, with the latest mkinitcpio the entries are all between ( ) and not " " but still is not a big issue, because will work with both …

Well, if the LG is initiating slower than the Benq and your Samsung, then that might be an explanation, but i’m not 100% sure.

Unfortunately, with all the modifications you suggested, no changes at all. Thanks for the effort, I guess I will need to wait for some general kwin fixes. I saw people a lot of users complaining on KDE with broken multi-display support.

which monitor is connected to which output on the gpu? IIRC there’s some prioritized order to them. Note that I’m not talking about the order mentioned in second post of the topic. I’m talking about on HW Firmware level. See for an example:
https://www.evga.com/support/faq/FAQdetails.aspx?faqid=59560

Note that it can also change depending on if you are using legacy bios system or UEFI.

Yeah, linux is in general pretty bad with this, but then windows isn’t perfect either.

I finally fixed the problem by disabling deep sleep option on LG monitor.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.