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: enable turning monitors on an off #226

Closed lukefromdc closed 6 years ago

lukefromdc commented 6 years ago

Add menu item to allow turning a monitor on or off from the popup menu. Borrow code from m-s-d display capplet to set geometry when a monitor is turned on. Turning on a monitor now works the same was as when turning it on but not reconfiguring it in mate-control-center's display capplet. The configuration capplet of course remains available from the popup if further configuration is needed, and all changes revert unless confirmed by the user in the "does the display look OK? dialog, same as from the capplet. Tooltip added to the enable/disable menu item to aid discoverability by users.

lukefromdc commented 6 years ago

cppcheck found no new warnings (including style warnings) in the added code. Also I didn't get any new build warnings.

lukefromdc commented 6 years ago

Since rotation items on a disabled monitor are not applied, the latest PR disabled rotations menu items for disabled monitors. I also switched the default label background on a disabled monitor to be reasonablly close to the darkened background for a disabled (dark) monitor on the display capplet, and added a style class to allow setting light text when that label is used.

In the MATE themes where the default label backgrounds are not shown, the only visible change is the addition of the checkboxes to turn monitors on and off, and the disabled theming being applied not to the monitor label for a disabled monitor but to the rotation items under it. In the GNOME and Blackbird themes, the style class is used to turn the label text white on the dark color for a disabled monitor, and in my theme (which uses the label backgrounds) I apply it in the theme.

Here's the results in a variety of themes, shown with one monitor on and one monitor off:

xrandr_popup_one_monitor_on_and_one_monitor_off

raveit65 commented 6 years ago

I like the idea, switching the monitors off/on is working well from menu. What do you think about to using alpha colors for monitor off state? Eg. something like this.

From e1a689d77cc7b0204f6ab8ea002861229556771b Mon Sep 17 00:00:00 2001
From: raveit65 <mate@raveit.de>
Date: Sun, 27 May 2018 10:24:01 +0200
Subject: [PATCH] xrandr-applet: use alpha colors for monitor off title

---
 plugins/xrandr/msd-xrandr-manager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/xrandr/msd-xrandr-manager.c b/plugins/xrandr/msd-xrandr-manager.c
index 8122677..6d88db1 100644
--- a/plugins/xrandr/msd-xrandr-manager.c
+++ b/plugins/xrandr/msd-xrandr-manager.c
@@ -1780,9 +1780,9 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
                 g_string_append (string," }");
         }
         else{
-                g_string_append (string, "background-color: shade(");
+                g_string_append (string, "background-color: alpha(");
                 g_string_append (string, color_string);
-                g_string_append (string, ", 0.2);");
+                g_string_append (string, ", 0.6);");
                 g_string_append (string," }");
                 gtk_style_context_add_class (context, "monitor-off");
         }
@@ -1838,7 +1838,7 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
                     "color: black;\n"
                     "}"
                     ".mate-panel-menu-bar menuitem.xrandr-applet.monitor-off:disabled>box>label{\n"
-                    "color: white;\n"
+                    "color: alpha (black, 0.6);\n"
                     "}",
                     -1, NULL);
             gtk_style_context_add_provider(context,
-- 
2.13.6

With adwaita and adwaita-dark. xrandr-applet-mon-dis-adwaita xrandr-applet-mon-dis-adwaita-dark

raveit65 commented 6 years ago

I updated Menta themes to reflect changes from this PR in https://github.com/mate-desktop/mate-themes/pull/225

lukefromdc commented 6 years ago

Using an alpha to dim the labels for turned off monitors worked fine: a bit less jarring in the menus though not as good a match for what's on the display capplet. Since the rectangle cannot be displayed on an monitor that is not turned on, that is not much of an issue.

Had to reduce the alpha value from 0.6 to 0.4 as otherwise it was not a clear enough difference in some themes, notably my own. This favors dark themes by darkening a turned off monitor, though I suppose in a light theme there is no good way to do that without getting one highly contrasting menuitem. Anyway, here's Greybird and Blackbird with this:

bird_themes_popup

raveit65 commented 6 years ago

This looks fine:)