linuxmint / cinnamon

A Linux desktop featuring a traditional layout, built from modern technology and introducing brand new innovative features.
GNU General Public License v2.0
4.49k stars 732 forks source link

Dual Monitors: Screen Lock and sleep moves windows to one monitor #9659

Open cems2 opened 3 years ago

cems2 commented 3 years ago

Problem: it is widely observed in cinnamon mint since atleast 2016 that when a computer sleeps or locks the screen windows that upon wake (sometimes but not always) all get moved and re-sized to one of the two monitors.

Since this has gone on for so long there's been a lot of witchdoctor voodoo "fixes" that work for some people but not others gathered on the very long but infrequently updated issue #5487 where this was originally filed. I am creating this new issue to try to summarize the emerged contours of this over the last few years of frustrations.

Regression: It may be that this is not one problem but maybe three problems that look similar and are related. It may be the problem happens in some cases at "sleep time", and it may be that some times the problem happens at "wake". There may be also complications with Cinnamon and Nvidia both trying to manage the same configuration files.

observations and suspicions:

  1. It appears that the problem with sleep may be related to some interaction of screen blanking (black screen) triggering some monitors to go into a hibernation mode. And then some graphics cards (Nvidia) not detecting the monitors, leading to the windows being moved. In this situation the problem may actually be occurring when the system is going into screen-save or sleep. evidence for this is that edit cinnamon-settings-daemon-xrandr.desktop to include an exit-time seems to be a fix for many people.

Exec=/usr/lib/cinnamon-settings-daemon/csd-xrandr --exit-time 1

There is some suscpicion that when one has different models of monitors, some of these may not have power saving features and some do, or that they may not have the same time-to-power-save. Thus different people may see different outcomes.

While seems to be a miracle cure for some folks, the problem with that 'fix' is that for some people if they manually turn off their monitors, the computer does not wake from sleep(!). (this hints that the problem here is much deeper than it seems, since that should not happen just by changing that setting).

  1. It may be this is a wake from sleep or wake from screen-blank issue. In this case the supposition would be almost the mirror image of the above issues. There the monitors may be in power save mode and not detected by the Nvidia graphics card. Or it may be that the Nvidia card is detecting them but something about this is not relayed to the system's window manager.

evidence for this is that changing the default settings for monitor detection to False sometimes fixes this for some people. dconf write /org/cinnamon/settings-daemon/plugins/xrandr/active false

  1. there may also be some problem with configuration file management is the observation that the behaviour is different if the Nvidia system monitoring tool is left running all the time or not. People have speculated that both the cinnamon and the Nvidia are competing to reset the configuration file on monitor detection.

While the last observation hints that Cinammon may be at fault in some cases, the prior cases of the nvidia card not detecting the monitors may be not strictly a cinammon problem. Evidence for this is the some people report some similar observations for other desktop environments: "I'm experiencing something similar with a triple monitor setup on Fedora 31, Xfce 4.14. It is possible that this is an Xorg bug? there are similar relevant report for KDE on Ubuntu. I've also found some Xfce forum posts here and here."

Finally, there is one report of this happening on an AMD graphics card.

jave808 commented 3 years ago

I can add a bit to this. My Issue #9655 only started when I installed a new Acer UHD monitor. I did not have this problem of windows "shifting" with my old setup - an AOC 27" 1920x1200 monitor as primary and a Dell 24" 1920x1200 monitor as secondary. Maybe the fact that I had two monitors of the same resolution means something to someone?

cems2 commented 3 years ago

@jave808 it may have to do with switching from HDMI to DP or another type for your UHD monitor.

jave808 commented 3 years ago

@cems2 yes, this may be the case. My old AOC monitor was connected via a DP to DVI adapter on the video card side. DP port on video card and DVI port on monitor.

iamapez commented 3 years ago

Having the same issue here with 2 AOC monitors (215LM00055) connected to an AMD RX570 graphics card via HDMI. Pretty annoying bug, seems this issue has persisted for years with still no fix...

nickstock commented 3 years ago

My two pence worth... i run three identical monitors via display port and and don't have this issue, I did used to get it on a previous set up when using a mix of vga and dvi but now all three are on dp its is solid.

jave808 commented 3 years ago

@nickstock yeah, my current setup is with a new Acer monitor and an old Dell monitor. I'm thinking of selling off the Dell for a newer Acer - not identical but with similar sleep characteristics. The Dell wakes up in an instant! I shouldn't have to go this far but it's an annoying bug.

cems2 commented 3 years ago

the --exit-time 1 trick was working for me up until a recent update of linux mint. Now it fails one screen stays dark at boot and the other has it's settings unchangeable because of an error message saying the xrandr_2 is missing. When I remove the --exit-time flag then I can adjust my screen setting without that error message, but I'm back to having all the windows coalesce onto one monitor every wake from sleep.
Linux Mint 20 Cinnamon version 4.6.7

And in reply to @nickstock, I'm running two DP monitors off my Nvidia card which only has DP ports. one is a samsung and the other an older HP.

acidkewpie commented 3 years ago

A simple permutation that I've not seen discussed - 3 identical monitors connected to onboard graphics, by HDMI, VGA and DVI. Directly removing power from VGA and DVI has no consequences to window layout. Removing HDMI power pushes all windows immediately to the VGA screen.

cems2 commented 3 years ago

I think your observations are explained because the vga is analog so the computer can tell it is connected to a monitor but can't tell if the monitor is on. DVI also has a analog optional channel so the same thing may be going on but I'm less sure. HDMI is a fully handshaked digital connection so depowering it makes it seem unresponsive hence the monitor shift. However I don't think this observation fits into the pathology being discussed in this issue.

Sent from my shoePhone

On Feb 10, 2021, at 2:00 AM, TheRocketSurgeon notifications@github.com wrote:

 A simple permutation that I've not seen discussed - 3 identical monitors connected to onboard graphics, by HDMI, VGA and DVI. Directly removing power from VGA and DVI has no consequences to window layout. Removing HDMI power pushes all windows immediately to the VGA screen.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

acidkewpie commented 3 years ago

Yes, it certainly feels like like it's part of the HDMI protocol, but it's only happening on Cinnamon. Gnome 3.38 doesn't do this.

brothertoad commented 3 years ago

I saw this under Mint 18.3, but resolved it with the --exit-time option. I upgraded (via reinstall) to 20.1 yesterday, and am seeing it again. The --exit-time option does not seem to help. I copied /etc/xdg/autostart/cinnamon-settings-daemon-xrandr.desktop to ~/.config/autostart and added the --exit-time. I did not remove the original in /etc/xdg/autostart. I have two identical monitors, ASUS PB278Q, connected to a ASRock Radeon RX 570 graphics card via DisplayPort, both running at 2560x1440. I've just noticed that one of my monitor goes blank for a few seconds every once in a while. This seems to be based on the exit-time parameter. That is annoying, but nothing compared to the moving of windows to one screen. I'm going to try connecting one monitor to HDMI and see if that helps.

cems2 commented 3 years ago

It's not clear from your description if the extra steps you follwed after upgrading to 20.1 fixed the window coalescing problem or not. could you clarify this. also did you copy to "autostart" or append to the end of autostart?  What is also interesting is that you have two identical monitors and this still happens-- are your monitors connected via different interfaces?

brothertoad commented 3 years ago

Sorry I wasn't clear. The problem is still occurring with 20.1. My monitors are connected to the same graphics card, both via DisplayPort. They are running at the same resolution. I have noticed that when I wake the computer, the monitor on the left comes back to life a few seconds before the one on the right. The one on the right is my primary screen, and this is where the windows all move to.

My autostart directory was empty to begin with. (Note that this is my user-level directory, under ~/.config.) This is a directory, not an ordinary file, so I'm not sure what you mean by "append".

I have since removed the file from my autostart directory, executed the following command

dconf write /org/cinnamon/settings-daemon/plugins/xrandr/active false

and to see if that fixes the problem, and I will update this post after more testing.

I'll also mention that I did not do an upgrade to my existing system per se. I installed 20.1 on a brand new drive, and replaced the existing drive (that had 18.3 on it) with the new one. So there isn't any residue from 18.3.

brothertoad commented 3 years ago

OK, the dconf command didn't fix it, but I did find a workaround. It is similar to what worked before, but there was an extra step I was missing. Per @cems2 request, I'll try to explain what each step does.

The issue is caused by the xrandr daemon, which is part of Cinnamon. We need to override the default settings of this daemon to work around this issue. Here's what I did:

  1. The default configuration for the xrandr daemon are in /etc/xdg/autostart/cinnamon-settings-daemon-xrandr.desktop. Copy this file to ~/.config/autostart/cinnamon-settings-daemon-xrandr.desktop. Cinnamon will now use the values in the file under ~/.config/autostart and ignore the values under /etc/xdg/autostart. This allows us to customize the values for a particular user.
  2. Open the ~/.config/autostart/cinnamon-settings-daemon-xrandr.desktop file in your favorite editor. You will need to make two changes to this file.
  3. By default, the daemon will never terminate, but we want it to terminate after a brief amount of time. To make this happen, add --exit-time 60 to the end of the Exec= line. This causes the daemon to exit after 60 seconds. You can use any value you want, but bear in mind that after the daemon exits, you won't be able to arrange monitors.
  4. Here's the tricky part. By default, if the daemon terminates, Cinnamon will automatically restart it - thus effectively overriding the exit-time value. We do not want this, so change the value of X-GNOME-AutoRestart from true to false.
  5. Log out and log back in again.

I don't remember having to do step 4 on my old system, which was Linux Mint 18.3. Sorry, but I don't know what version of Cinnamon that was. The version I'm using now is 4.8, with Mint 20.1.

twonintynine commented 3 years ago

Uh, am I the only one that has noticed that HDMI has had horrible, horrible, wHOReRIBLE issues with standby/wake detection in the past, uh, forever?

yeah, all OS'es ASFAIK

cems2 commented 3 years ago

@brothertoad Could you annotate your work around so that I can understand what each step is doing?

mxr576 commented 2 years ago

@brothertoad How does the fix you described is working so far? Is it still working? Any unexpected side effects so far?

cems2 commented 2 years ago

Works.

Currently after a system update I now have a different monitor problem of not being able to get it to recognize a second monitor attached after boot. I suspect this be related but it didn't occur until a system update .

Sent from my shoePhone

On Oct 16, 2021, at 2:25 AM, Dezső BICZÓ @.***> wrote:

 @brothertoad How does the fix you described is working so far? Is it still working? Any unexpected side effects so far?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

brothertoad commented 2 years ago

@brothertoad How does the fix you described is working so far? Is it still working? Any unexpected side effects so far?

Yes, it is still working fine. I have not seen any side effects.

j1elo commented 2 years ago

Another confirmation here, the solution proposed in https://github.com/linuxmint/cinnamon/issues/9659#issuecomment-797158818 works for me too! Without any noticeable downside apart from the main known one (no further detection of monitors).

My system is a cleanly installed Linux Mint 20.2 Uma, with a modern-ish ViewSonic XG2405 as primary monitor (DisplayPort, 1920x1080) and a much older Dell 2407WFP as secondary (DVI, 1920x1200).

The issue is as described: it is not the screensaver, but the automatic power-off, that triggers moving windows to the secondary one (Dell). I think it only happens with the windows that were maximized on the primary screen, and I've always thought it is caused by the bigger resolution of the secondary one. But the actual cause might be some compatibility issue, of course. Although I'd be hard pressed to believe that a 2020 ViewSonic monitor is behaving worse than the old Dell one... but I guess the probability is not 0.0% that this happens.

So, is this a bug in Cinnamon, or in xrandr? What should be the next steps to follow with this? I'm a software dev so I can work my way to provide whatever advanced feedback might be needed.

brothertoad commented 2 years ago

@j1elo I have loaded Zorin 16, which uses GNOME as its desktop, and the problem is there too, so it isn't just a Cinnamon bug.

HighOnVoltage commented 2 years ago

Another confirmation here, the solution proposed in #9659 (comment) works for me too! Without any noticeable downside apart from the main known one (no further detection of monitors).

Is this a bug in Cinnamon, or in xrandr? What should be the next steps to follow with this? I'm a software dev so I can work my way to provide whatever advanced feedback might be needed.

Running Debian 11 Buster with Cinnamon here, same issue. Seems like it doesn't matter what distro we use it's related to the WM or xrandr. @j1elo Is there any suitable logs I can help with as KDE doesn't have this issue.

fg-ok commented 2 years ago

@brothertoad How does the fix you described is working so far? Is it still working? Any unexpected side effects so far?

Yes, it is still working fine. I have not seen any side effects.

I have encountered a quite annoying side effect. With the solution from brothertoad the problem with the windows on wrong monitor seems fixed, but if I had turned my secondary monitor off, and PC went to standby after waking the PC up again the primary monitor won't wake up, secondary monitor stays off. So here I have to restart the window manager to get back in system.

cxrodgers commented 2 years ago

For me, disabling DPMS fixes this problem. You can type xset -dpms to disable it, and check whether it worked with xset q. In the past I've had issues with something turning DPMS back on, and fixed it by adding a cronjob to disable it every 10 minutes or so. I don't know if this is helpful for anyone just wanted to share my experience.

ghost commented 2 years ago

I have two monitors, After screen lock, it moves main monitor to the right when it was on the left. Also after display the time for a few minutes, when I come back, it displays the time on the "now" main monitor and the second monitor shows the desktop, before locking. This is not just a Cinnamon problem, Plasma is also terrible with dual monitors. Too many problems in one feature and plasma also disables the second monitor when playing a video... sometimes. Not consistent. So for Cinnamon, the dual setup is also something that does not work. The only DE that is acceptable with dual monitor is Gnome. Screen lock cannot show the desktop. Moving the primary monitor or changing monitors position cannot happen ever. So this looks that is not only a Cinnamon problem. Any idea?

brothertoad commented 2 years ago

I discovered something interesting. I switched to Manjaro for a while, and using Cinnamon, did not have this problem. Significantly, Manjaro uses a much more recent kernel than Mint. I think Manjaro used 5.9 or later, whereas Mint is still using 5.4. I had issues with Manjaro (sidenote: never going back a rolling distribution), so I reloaded Mint. Once Mint was loaded, I updated the kernel - I'm currently using 5.13.0.41, and have not seen the issue. If you're willing to update your kernel, you might try this.

slano commented 2 years ago

The issue is still present on Linux Mint 21, but unfortunately, since csd-xrandr has been merged into Muffin, @brothertoad workaround doesn't work anymore (workaround was working just fine on 20.3).

Any idea what a next workaround should be?

j1elo commented 2 years ago

The issue is still present on Linux Mint 21, but unfortunately, since csd-xrandr has been merged into Muffin, @brothertoad workaround doesn't work anymore (workaround was working just fine on 20.3).

Noooo, so we're back to square 1 again? :-(

@j1elo Is there any suitable logs I can help with as KDE doesn't have this issue.

I'd need a bit of guidance to know which logs should be checked, as I'm still not even sure of what is the component that is causing this bug.

georgehank commented 1 year ago

Why is it so hard to just give the DE/WM an option "DO NOT REARRANGE WINDOWS EXCEPT WHEN I TURN OFF THIS OPTION OR I EXPLICITLY COMMAND YOU TO!".

Sheesh.

(And I'm not even using Mint/Cinnamon, I'm on Devuan/XFCE4 but have the very same problem… obviously tied to DP/HDMI, but also to this "wonderful" new RX 6600 I just installed three days ago… my R9 380 didn't show any of this, but then again, only one monitor was connected via DP, while the other two were on DVI) (Yes, Google brought me here, blame them ;-))

allpoints commented 1 year ago

I did not have this problem under "Linux Mint 20.1 Ulyssa". However, I also was not able to get my screens to work properly using the standard, Cinnamon Preferences > Display GUI tool. I had to resort to running the following on login. Note that it was fine after that. i.e. the screens restored as expected resuming from a screen lock.

xrandr --output eDP-1  --scale 1x1 --pos 2880x275
xrandr --output HDMI-1 --scale .75x.75

Where eDP-1 is an external monitor to the left of the laptop display, eDP-1

I have since rebuilt, not upgraded, the system with "Linux Mint 21 Vanessa". The GUI tool now works as expected but I am also now experiencing this bug.

FWIW:

> inxi --no-host -SMGay
System:
  Kernel: 5.15.0-48-generic x86_64 bits: 64 compiler: gcc v: 11.2.0
    parameters: BOOT_IMAGE=/vmlinuz-5.15.0-48-generic
    root=/dev/mapper/vgmint-root ro quiet splash
  Desktop: Cinnamon 5.4.12 tk: GTK 3.24.33 wm: Mutter dm: LightDM 1.30.0
    Distro: Linux Mint 21 Vanessa base: Ubuntu 22.04 jammy
Machine:
  Type: Laptop System: Purism product: Librem 15 v3 v: 1.0
    serial: <superuser required> Chassis: type: 9 serial: <superuser required>
  Mobo: Purism model: Librem 15 v3 v: 1.0 serial: <superuser required>
    BIOS: coreboot v: 4.11-Purism-1 date: 11/26/2019
Graphics:
  Device-1: Intel Skylake GT2 [HD Graphics 520] driver: i915 v: kernel ports:
    active: HDMI-A-1,eDP-1 empty: DP-1 bus-ID: 00:02.0 chip-ID: 8086:1916
    class-ID: 0300
  Device-2: Alcor Micro HD WebCam type: USB driver: uvcvideo bus-ID: 1-7:4
    chip-ID: 058f:d102 class-ID: 0e02
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: modesetting
    unloaded: fbdev,vesa gpu: i915 display-ID: :0 screens: 1
  Screen-1: 0 s-res: 9984x3456 s-dpi: 108 s-size: 2348x813mm (92.4x32.0")
    s-diag: 2485mm (97.8")
  Monitor-1: HDMI-1 mapped: HDMI-A-1 pos: primary,top-left
    model: Samsung U24E590 serial: HTPH400745 built: 2016 res: 6144x3456 hz: 30
    dpi: 300 gamma: 1.2 size: 521x293mm (20.5x11.5") diag: 598mm (23.5")
    ratio: 16:9 modes: max: 3840x2160 min: 720x400
  Monitor-2: eDP-1 pos: primary,bottom-r model: BOE Display built: 2014
    res: 3840x2160 hz: 60 dpi: 284 gamma: 1.2 size: 344x193mm (13.5x7.6")
    diag: 394mm (15.5") ratio: 16:9 modes: 1920x1080
  OpenGL: renderer: Mesa Intel HD Graphics 520 (SKL GT2) v: 4.6 Mesa 22.0.5
    direct render: Yes
mtwebster commented 1 year ago

@allpoints,

Please have a look at this comment: https://github.com/linuxmint/cinnamon-screensaver/issues/416#issuecomment-1256233029

I'm thinking the changes in those packages may address this issue also. The fixes should also be in the next cinnamon-screensaver release as well.

allpoints commented 1 year ago

@mtwebster,

I installed the https://github.com/linuxmint/cinnamon-screensaver/releases/tag/master.mint21 packages and the problem has been resolved. Very much appreciated. Thank you.

ddouglas87 commented 1 year ago

I upgraded to Mint 21 a couple of days ago and am now having this issue where before I never did. Some things of note:

It looks like something changed and my second monitor isn't being correctly detected any more, from the 30 fps to not recognizing sleep state.

I've had issues with all versions of Mint where if I turn off my primary monitor (manually, not sleep) there is about a 1 in 5 chance turning it back on will have a blank screen. I do not know how to get out of this state without a forceful reboot of the computer. So this issue runs deeper than meets the eye. When a monitor turns off, sleep or otherwise, the desktop should stick around, not disappear.

In an ideal world each display is represented by a different workspace, so if you go from a dual monitor setup to a single monitor setup you can press a key bind (ctrl+alt+right arrow) that moves to the next workspace on the primary monitor. This would be ideal, because few people ever want their desktop settings automatically messed with, they'd rather have a way to access the secondary screen on the primary display. (If both monitors are on, ctrl+alt+right arrow does the default behavior it's currently doing. If there has been one monitor the entire time it does the default behavior. This doesn't mess with old behavior.)


Being stuck in mirrored mode is a show stopper for me. I've been using Mint since, I think, version 2. I've been a long time user. Having to go into a gui window every time my monitor goes to sleep or is turned off is horrible. If I could find a terminal command that has the same effect as going into the Display window it would be less of a show stopper. If I can figure out how to have the command automatically called when the second monitor turns on, even better. I'm not a fan of having the windows from my secondary screen merge into my primary every time, but I'll put up with it, if I can find a way to get out of being stuck in mirroring mode. Don't force me into mirroring mode please!

mattsmi commented 1 year ago

I am seeing this in Linux Mint 21.1, new installation. Two screens using HDMI, one via a DELL Thunderbolt dock. Have not seen it using the same version of Linux Mint on a different laptop with one screen using HDMI and the other using a display port — both directly connected to the laptop. It is very annoying and confusing. What I have also noted is that the number assigned to the screens (there are two external plus the laptop screen) changes. It seems to change after the windows move to a different screen. The numbers remain as set when you open the Display app, but when right-clicking an app and attempting to send it to a screen the numbers have all gone awry.

Majki commented 1 year ago

Linux Mint 21.1 Vera here, Cinnamon, I can confirm the bug is still here.

allpoints commented 1 year ago

I'm running 21/Vanessa but have kept it up to date. The patches referenced above made it into the update cycle a few months ago and the problem was resolved for me.

For the maintainer, if you there's some specific hardware and/or config information you're interested in I'm happy to provide it.

pine3ree commented 1 year ago

Hello, I started having the same problem (on 21.1 xfce, so it's not only affecting cinnamon) a couple of days ago when I changed (only) my secondary monitor with a new monitor connected directly via hdmi.

Before that I used an old (2008) LCD monitor with vga-to-hdmi adapter without this issue. I also used the same old monitor vga-to-vga with 2 different laptops: one on mint-18-mate for years and before that one with ubuntu-lucid-gnome without this bug.

I remember that I also had the previous notebook (the one with mint-18-mate) coupled with a secondary hdmi-monitor of the same brand and features similar of the new one, without this bug.

@mattsmi I also am using a dell laptop, but I did not had this issue with old (hdmi-to-vga) monitor

pine3ree commented 1 year ago

In my case (xfce 21.1) I was able to solve the issue by saving a profile and setting "automatically configure monitors when connected" and "automatically load profiles for know monitors". Now all windows are in the original monitor and the frequency rate is preserved.