mate-desktop / mate-settings-daemon

MATE settings daemon
https://mate-desktop.org
GNU General Public License v2.0
43 stars 47 forks source link

xrandr-applet-popup: add item to mirror displays #227

Closed lukefromdc closed 6 years ago

lukefromdc commented 6 years ago

Add menuitem for mirroring same output to all displays

Very useful for laptop users running projectors in public settings. Quite common to see people fumble with trying to get mirroring a laptop to a projector or a big screen working under pressure. This enables it with a single click.

lukefromdc commented 6 years ago

Note that on switching back to a single monitor from mirror mode, Caja and also compiz-reloaded can experience issues with redrawing the desktop back to a larger resolution if the monitor being mirrored to is smaller. Note that there are a lot of low resolution projectors out there. Switching out of mirror mode from this menu item is the same as switching out of mirrored mode and resetting the primary monitor's resolution at the same time from M-C-C's display capplet, so the issue is not new to this PR.

Follow-on to https://github.com/mate-desktop/mate-settings-daemon/pull/226 but separate as this functionality is a bit more complex and the issue with switching back out of mirrored mode and resetting resolution by any means within m-s-d and m-c-c exists. Desktop rendering is correct on new session or restarting Caja. No issue if resolution of primary monitor is the same in mirrored mode.

In the usual laptop use case, it is getting the big screen or projector to work that causes hurried users to make mistakes. The problems we already have getting back out of mirrored mode occur after the projection or whatever is over and in any rate do not persist into a new session.

raveit65 commented 6 years ago

Yeah, i know there are redraw issues of the desktop if you use several monitors and switch resolutions. I am using a panel launcher with those commands to correct the desktop without restarting caja. redraw-desktop.sh

#!/bin/bash

/usr/bin/gsettings set org.mate.background show-desktop-icons false && \
/usr/bin/gsettings set org.mate.background show-desktop-icons true
raveit65 commented 6 years ago

Enabling mirror displays is working but i can't disable this setting from menu. This works only from GUI. Tested with notebook (1600x900) and an external monitor (1920x1080, primary-display).

lukefromdc commented 6 years ago

I assume by "disable from the menu" you mean switch back out of mirrored mode, and that that is what is not working for you?

One thing that might do that is if your machine is not defaulting to any available mode in the "make_primary_only" function, or if "is_laptop" function does not actually work. When you open the main GUI, does your laptop's main screen get named "laptop" or is it listed as a primary monitor? If by any chance neither one is true, than the function I wrote cannot work. Maybe I should have it pop up that main GUI when coming back out of mirrored mode both to cover this case and to deal with possible configuration issues? If laptops are not reliable for this, I will have to switch the code to always open the GUI to switch back out.

Also, do you get a confirmation dialog but no actual change of monitor configuration? That might indicate a problem in changing modes, maybe because the primary monitor resolution does not change the code thinks nothing is changing, so the apply code sees nothing to do and returns. On my desktop I have two different monitors, the secondary is smaller so the primary has to change resolution. I will go to my "test" account with an empty desktop and try switching in and out with the secondary monitor set as the primary and see what happens.

The only laptop I have has a HDMI output only, all my monitors are VGA. My test with a desktop worked, but I'm wondering if the "is_laptop" feature works on modern laptops. There is a lot of old code that no longer works right buried in plugins/xrandr/msd-xrandr-manager.c , I know I had to change the refresh rate code in make_clone_setup to stop it from adding together the refresh rates of two monitors.

lukefromdc commented 6 years ago

I just tested the smaller monitor as primary on the desktop (AMD graphics if it makes any difference), and found that switching both into and back out of mirrored mode performed flawlessly on that setup, with none of the display issues I got with the large monitor as primary(known issues predating this PR).

Thus, your issue may be the monitor not being called "laptop" or set as primary, or the is_laptop function not working with today's laptops, video drivers, etc. if there is no clean way to do this, I can modify the PR so switching into mirrored mode works as not, but deselecting it just calls the configuration GUI, calls it if the switch back out fails, or both attempts to switch back out and also calls it.

raveit65 commented 6 years ago

I assume by "disable from the menu" you mean switch back out of mirrored mode, and that that is what is not working for you?

Yes, exactly, but it is working from mate-display-properties.

When you open the main GUI, does your laptop's main screen get named "laptop" or is it listed as a primary monitor?

My laptop display is named "laptop" and the external monitor have a manufacturer name. xrandr-applet-mirror-mon

Also, do you get a confirmation dialog but no actual change of monitor configuration?

Yes, this dialog pops up after boths displays goes black for a moment, but both display are mirrored at this point and confirming the setting has no effect, btw. i confirm the wrong state, imho.

The only laptop I have has a HDMI output only

My notebook have both , HDMI and vga, but i am using HDMI for the external display.

Thus, your issue may be the monitor not being called "laptop" or set as primary,

Yes, that's the problem, During reading you posts i tested it again. If i set the notebook display as primary and switching back to non-mirror mode, than it is working. But with my current setup where the external monitor is primary it doesn't.

vkareh commented 6 years ago

I just tested with my laptop as the primary (which is my usual case), and after fiddling with the resolution (my laptop is HiDPI, but not my monitor, so I use xrandr to scale the external monitor) I was able to find the applet to disable it successfully, however, my external monitor was set to Off when disabling the mirrored output - is that expected?

lukefromdc commented 6 years ago

Yes, it is expected that all but the primary/laptop monitor are set to OFF on switching out of mirrored mode, as nothing else works. The "make_xinerama_setup function does not work on my setup at least, and to rewrite it would be quite complex.

Apparently the case of one monitor the laptop and the other set as primary is causing the failures, confusing my code. Thus, I might need to split the code, having it look for laptop first, settung up and exiting if "laptop" is found, otherwise looking for "primary." I probably should also add a fallback for the case of neither being detected, posibly just using the first monitor detected in that case.

lukefromdc commented 6 years ago

Please retest, and both with the laptop screen set as primary and with the external monitor set as primary. https://github.com/mate-desktop/mate-settings-daemon/pull/227/commits/b2d2d1038888672652cff526a3fc32c9880bc6ef Adds more robust code to first see if a laptop screen exists, then see if a primary screen is detected. If a laptop is detected, it is turned on first and everything else turned off. If no laptop is detected but a primary screen is detected, the primary is turned on and all others turned off. If that is not detected either, the first monitor detected is turned on. If nothing works and the function returns NULL, the display cappet pops up.

This does mean that if you have a laptop running with an external monitor as primary you will need to reconfigure, but previously the only way out of mirror was to reconfigure anyway. This is intended to return to defaults that will suit most users most of the time, so the display capplet only needs to be used in less common cases and hopefully never needs to be used under pressure before a big crowd while trying to get a projector to work.

lukefromdc commented 6 years ago

https://github.com/mate-desktop/mate-settings-daemon/pull/227/commits/1c544500f3dfc07594e0a525b2670e17f0a0c026 is a better approach: This way, all displays stay turned on, just laid out left to right. Does not require finding the laptop or prinary display so should always work. Keeping all monitors on also prevents background corruption on leaving mirror mode at least in my case, secondary monitors can then be turned off individually without issue.

lukefromdc commented 6 years ago

Branch rebased and partially squashed to clean up final merge